### Example Blacklist Configuration Source: https://docs.coreprotect.net/config This example shows how to configure the blacklist.txt file to disable logging for specific users, commands, blocks, and entities. Ensure you include namespaces for blocks and entities. ```text Notch ; User #tnt ; TNT explosions /help ; Help command minecraft:stone ; Stone blocks minecraft:creeper ; Creeper entity minecraft:shears@#dispenser ; Shears being dispensed ``` -------------------------------- ### Hashtag Example Source: https://docs.coreprotect.net/commands Applies additional actions to a command, such as performing a rollback preview. ```text #preview ``` -------------------------------- ### Rollback Command Examples Source: https://docs.coreprotect.net/commands Demonstrates various rollback commands with different parameters like user, time, radius, inclusion, exclusion, and hashtags. ```text /co rollback Notch t:1h ``` ```text /co rollback u:Notch,Intelli t:1h #preview ``` ```text /co rollback u:Notch t:23h17m ``` ```text /co rollback u:Notch t:1h i:stone ``` ```text /co rollback u:Notch t:1h i:stone a:-block ``` ```text /co rollback u:Notch t:1h r:#global e:stone,dirt ``` ```text /co rollback u:Notch t:1h r:20 ``` ```text /co rollback u:Notch t:1h r:#nether ``` ```text /co rollback u:Notch t:5m a:inventory ``` ```text /co rollback t:15m r:30 ``` ```text /co rollback t:15m r:#worldedit ``` -------------------------------- ### LookupOptions Builder Example Source: https://docs.coreprotect.net/api/version/v12 Demonstrates how to build a LookupOptions object to filter API lookups by user, time, location, radius, and result limits. ```java LookupOptions options = LookupOptions.builder() .user("Notch") .time(60) .radius(location, 5) .limit(0, 100) .build(); ``` -------------------------------- ### Include Filter Example Source: https://docs.coreprotect.net/commands Specifies blocks, items, or entities to include in the command's scope. Multiple items can be specified. ```text i:stone ``` ```text i:stone,oak_wood,bedrock ``` -------------------------------- ### Lookup Command Examples Source: https://docs.coreprotect.net/commands Illustrates lookup commands, which are similar to rollback commands but perform global searches by default. Includes filters for item, time, action, and user. ```text /co lookup i:diamond_ore t:1h a:-block ``` ```text /co lookup u:Notch t:30m a:chat ``` ```text /co lookup u:Notch t:3d a:inventory ``` ```text /co lookup u:Notch a:login ``` ```text /co lookup u:Notch a:username ``` -------------------------------- ### Action Filter Example Source: https://docs.coreprotect.net/commands Restricts commands to specific actions. For example, only include blocks that were placed. ```text a:+block ``` -------------------------------- ### Getting CoreProtect API Instance Source: https://docs.coreprotect.net/api/version/v12 This Java code snippet demonstrates how to safely obtain an instance of the CoreProtectAPI, checking for plugin presence, API enablement, and version compatibility. ```java import net.coreprotect.CoreProtect; import net.coreprotect.CoreProtectAPI; private CoreProtectAPI getCoreProtect() { Plugin plugin = getServer().getPluginManager().getPlugin("CoreProtect"); // Check that CoreProtect is loaded if (plugin == null || !(plugin instanceof CoreProtect)) { return null; } // Check that the API is enabled CoreProtectAPI CoreProtect = ((CoreProtect) plugin).getAPI(); if (CoreProtect.isEnabled() == false) { return null; } // Check that a compatible version of the API is loaded if (CoreProtect.APIVersion() < 12) { return null; } return CoreProtect; } ``` -------------------------------- ### Radius Filter Example Source: https://docs.coreprotect.net/commands Targets entities within a specified block radius of the player. Can also target specific worlds or the entire server. ```text r:10 ``` ```text r:#world_the_end ``` ```text r:#global ``` ```text r:#worldedit ``` ```text r:#we ``` -------------------------------- ### Enable Auto-Purge in config.yml Source: https://docs.coreprotect.net/auto-purge Set the `auto-purge` option in `config.yml` to specify the retention period for CoreProtect data. This example keeps the most recent 180 days of data. ```yaml auto-purge: 180d ``` -------------------------------- ### Exclude Filter Example Source: https://docs.coreprotect.net/commands Excludes specific blocks, items, entities, or users from the command's scope. ```text e:tnt ``` -------------------------------- ### General Migration Command Source: https://docs.coreprotect.net/database-migration The base command for initiating a database migration. Specify 'mysql' to migrate to MySQL or 'sqlite' to migrate to SQLite. This command is console-only. ```command co migrate-db ``` -------------------------------- ### Migrate to SQLite Source: https://docs.coreprotect.net/database-migration Use this command to migrate your CoreProtect database from MySQL back to SQLite. Ensure your SQLite database is configured in config.yml before execution. ```command co migrate-db sqlite ``` -------------------------------- ### Perform Block Lookup by Radius Source: https://docs.coreprotect.net/api/version/v12 Get block data changes within a specified radius of a location. This is useful for analyzing changes in a specific area. ```java CoreProtectAPI CoreProtect = getCoreProtect(); if (CoreProtect != null){ // Ensure we have access to the API List lookup = CoreProtect.performLookup(60, null, null, null, null, null, 5, location); if (lookup != null){ for (String[] value : lookup){ ParseResult result = CoreProtect.parseResult(value); int x = result.getX(); int y = result.getY(); int z = result.getZ(); // ... } } } ``` -------------------------------- ### Manual Purge with Optimization for MySQL Source: https://docs.coreprotect.net/auto-purge For MySQL databases, add `#optimize` to the manual purge command to reclaim disk space during the initial cleanup when enabling automatic purging. ```minecraft-commands /co purge t:180d #optimize ``` -------------------------------- ### Manual Purge for Existing Databases Source: https://docs.coreprotect.net/auto-purge When enabling automatic purging on an existing database, it's recommended to run a manual purge first with the same time value. This helps reduce the current database size. ```minecraft-commands /co purge t:180d ``` -------------------------------- ### Log Block Placement by User, Location, and Material Source: https://docs.coreprotect.net/api/version/v12 Logs the placement of a block by a user, specifying location, material type, and block data. Returns a boolean indicating success. ```java boolean logPlacement(String user, Location location, Material type, BlockData blockData) ``` -------------------------------- ### Migrate to MySQL Source: https://docs.coreprotect.net/database-migration Use this command to migrate your CoreProtect database from SQLite to MySQL. Ensure your new MySQL database is configured in config.yml before execution. ```command co migrate-db mysql ``` -------------------------------- ### logPlacement Source: https://docs.coreprotect.net/api/version/v12 Logs a block placement action. ```APIDOC ## `logPlacement(String user, BlockState blockState)` ### Description Logs a block as being placed. (Thread safe) ### Parameters #### Request Body - **user** (String) - Required - The username to log as having placed the block. - **blockState** (BlockState) - Required - The BlockState of the block being logged. ### Method POST ``` ```APIDOC ## `logPlacement(String user, Location location, Material type, BlockData blockData)` ### Description Logs a block as being placed. ### Parameters #### Request Body - **user** (String) - Required - The username to log as having placed the block. - **location** (Location) - Required - The location of the block being logged. - **type** (Material) - Required - The Material of the block being logged. - **blockData** (BlockData) - Required - The BlockData of the block being logged. Can be set to "null". ### Method POST ``` -------------------------------- ### Log Block Placement by User and BlockState Source: https://docs.coreprotect.net/api/version/v12 Logs the placement of a block by a user, using the BlockState for details. Returns a boolean indicating success. ```java boolean logPlacement(String user, BlockState blockState) ``` -------------------------------- ### logPlacement(String user, Location location, Material type, BlockData blockData) Source: https://docs.coreprotect.net/api/version/v12 Logs a block placement event with detailed information. ```APIDOC ## logPlacement(String user, Location location, Material type, BlockData blockData) ### Description Logs a block placement event with detailed information including user, location, material type, and block data. ### Method POST (assumed, due to multiple parameters) ### Endpoint /api/v12/logPlacement ### Parameters #### Request Body - **user** (String) - Required - The user who placed the block. - **location** (Location) - Required - The location where the block was placed. - **type** (Material) - Required - The material type of the block. - **blockData** (BlockData) - Required - The data associated with the block. ### Response #### Success Response (200) - **boolean**: true if the placement was logged successfully, false otherwise. ``` -------------------------------- ### logCommand(Player player, String command) Source: https://docs.coreprotect.net/api/version/v12 Logs a command executed by a player. ```APIDOC ## logCommand(Player player, String command) ### Description Logs a command executed by a player. ### Method POST (assumed, due to player and command parameters) ### Endpoint /api/v12/logCommand ### Parameters #### Request Body - **player** (Player) - Required - The player who executed the command. - **command** (String) - Required - The command that was executed. ### Response #### Success Response (200) - **boolean**: true if the command was logged successfully, false otherwise. ``` -------------------------------- ### logPlacement(String user, BlockState blockState) Source: https://docs.coreprotect.net/api/version/v12 Logs a block placement event. ```APIDOC ## logPlacement(String user, BlockState blockState) ### Description Logs a block placement event performed by a user. ### Method POST (assumed, due to user and blockState parameters) ### Endpoint /api/v12/logPlacement ### Parameters #### Request Body - **user** (String) - Required - The user who placed the block. - **blockState** (BlockState) - Required - The state of the placed block. ### Response #### Success Response (200) - **boolean**: true if the placement was logged successfully, false otherwise. ``` -------------------------------- ### testAPI() Source: https://docs.coreprotect.net/api/version/v12 Executes a test of the CoreProtect API, printing a success message to the server console. ```APIDOC ## testAPI() ### Description Runs a test of the CoreProtect API. A success message will be printed to the server console. ### Method POST (assumed, as it performs an action) ### Endpoint /api/v12/testAPI ### Response #### Success Response (200) - **void**: No return value, but a console message indicates success. ``` -------------------------------- ### Sign Lookup with Options Source: https://docs.coreprotect.net/api/version/v12 Performs a sign lookup using LookupOptions for filtering. Returns a list of SignResult objects. ```java List signLookup(LookupOptions options) ``` -------------------------------- ### /co network-debug Source: https://docs.coreprotect.net/api/networking Allows debugging of the networking API for registered players with correct permissions. Requires 'network-debug: true' in CoreProtect config.yml. ```APIDOC ## /co network-debug ### Description Allows you to debug the networking API if you are registered and have correct permissions. To utilize the command, `network-debug: true` must be set in the CoreProtect `config.yml`. ### Usage `/co network-debug ` ``` -------------------------------- ### Log Block Placement Source: https://docs.coreprotect.net/api/version/v12 Logs the placement of a block at a specific location by a user. Ensure CoreProtectAPI is accessible. ```java CoreProtectAPI CoreProtect = getCoreProtect(); if (CoreProtect != null){ // Ensure we have access to the API boolean success = CoreProtect.logPlacement("Notch", block.getLocation(), block.getType(), block.getData()); } ``` -------------------------------- ### testAPI Source: https://docs.coreprotect.net/api/version/v12 Tests the CoreProtect API connection and prints a success message to the console. ```APIDOC ## testAPI ### Description Tests the CoreProtect API connection and prints a success message to the console. ### Method `void testAPI()` ### Usage This method is called on a valid `CoreProtectAPI` instance to verify the connection. ``` -------------------------------- ### Container Lookup with Radius and Time Source: https://docs.coreprotect.net/api/version/v12 Perform a container lookup within a specified radius and time frame using LookupOptions. This allows for broader analysis of container interactions. ```java CoreProtectAPI CoreProtect = getCoreProtect(); if (CoreProtect != null){ // Ensure we have access to the API LookupOptions options = LookupOptions.builder() .time(60) .radius(location, 5) .build(); List lookup = CoreProtect.containerLookup(options); if (lookup != null){ for (ContainerResult result : lookup){ int x = result.getX(); int y = result.getY(); int z = result.getZ(); Material type = result.getType(); int amount = result.getAmount(); // ... } } } ``` -------------------------------- ### Client to Server Handshake Packet Creation (Fabric) Source: https://docs.coreprotect.net/api/networking Creates a Handshake Packet to register with the server. Requires 'network-debug: true' in CoreProtect's config.yml for debugging. ```java PacketByteBuf packetByteBuf = new PacketByteBuf(Unpooled.buffer()); ByteArrayOutputStream msgBytes = new ByteArrayOutputStream(); DataOutputStream msgOut = new DataOutputStream(msgBytes); msgOut.writeUTF(modVersion); msgOut.writeUTF(modId); msgOut.writeInt(coreprotectProtocol); packetByteBuf.writeBytes(msgBytes.toByteArray()); ``` -------------------------------- ### Log Player Command Source: https://docs.coreprotect.net/api/version/v12 Logs a player's executed command to the CoreProtect database. Returns a boolean indicating success. ```java boolean logCommand(Player player, String command) ``` -------------------------------- ### commandLookup(String user, int time) Source: https://docs.coreprotect.net/api/version/v12 Performs a command lookup for a specific user within a given time frame. Use null or #global to search all users. ```APIDOC ## commandLookup(String user, int time) ### Description Performs a command lookup for a specific user within a given time frame. Use `null` or `#global` to search all users. ### Parameters #### Path Parameters - **user** (String) - Required - The username to perform the lookup on. Use `null` or `#global` to search all users. - **time** (int) - Required - Specify the amount of time to lookup. "5" would return results from the last 5 seconds. ### Response Returns `MessageResult` entries with typed access to message and command details. ``` -------------------------------- ### Container Lookup with Options Source: https://docs.coreprotect.net/api/version/v12 Performs a lookup for containers using LookupOptions for filtering. Returns a list of ContainerResult objects. ```java List containerLookup(LookupOptions options) ``` -------------------------------- ### commandLookup(LookupOptions options) Source: https://docs.coreprotect.net/api/version/v12 Looks up command executions using LookupOptions. ```APIDOC ## commandLookup(LookupOptions options) ### Description Looks up command executions using provided LookupOptions. ### Method POST (assumed, due to options parameter) ### Endpoint /api/v12/commandLookup ### Parameters #### Request Body - **options** (LookupOptions) - Required - The options to filter the lookup. ### Response #### Success Response (200) - **List**: A list of MessageResult objects. ``` -------------------------------- ### Command Lookup with Options Source: https://docs.coreprotect.net/api/version/v12 Performs a command lookup using LookupOptions for filtering. Returns a list of MessageResult objects. ```java List commandLookup(LookupOptions options) ``` -------------------------------- ### Testing CoreProtect API Connection Source: https://docs.coreprotect.net/api/version/v12 After obtaining the CoreProtectAPI instance, this code snippet shows how to test the connection by calling the testAPI() method. ```java CoreProtectAPI api = getCoreProtect(); if (api != null){ // Ensure we have access to the API api.testAPI(); // Will print out "[CoreProtect] API test successful." in the console. } ``` -------------------------------- ### Lookup Commands Source: https://docs.coreprotect.net/api/version/v12 Retrieves commands executed within a specified radius and time frame. Ensure CoreProtectAPI is accessible. ```java CoreProtectAPI CoreProtect = getCoreProtect(); if (CoreProtect != null){ // Ensure we have access to the API LookupOptions options = LookupOptions.builder() .time(60) .radius(location, 5) .build(); List lookup = CoreProtect.commandLookup(options); if (lookup != null){ for (MessageResult result : lookup){ String command = result.getMessage(); String player = result.getPlayer(); // ... } } } ``` -------------------------------- ### logPlacement Source: https://docs.coreprotect.net/api/version/v12 Logs the placement of a block at a specific location by a user. ```APIDOC ## logPlacement ### Description Logs the placement of a block at a specific location by a user. ### Method CoreProtectAPI.logPlacement(String user, Location location, Material type, Object data) ### Parameters #### Path Parameters - **user** (String) - Required - The username of the user placing the block. - **location** (Location) - Required - The location where the block was placed. - **type** (Material) - Required - The type of the block. - **data** (Object) - Required - The data associated with the block. ### Request Example ```java CoreProtectAPI CoreProtect = getCoreProtect(); if (CoreProtect != null) { boolean success = CoreProtect.logPlacement("Notch", block.getLocation(), block.getType(), block.getData()); } ``` ### Response #### Success Response - **boolean** - True if the placement was logged successfully, false otherwise. ``` -------------------------------- ### Block Lookup with Options Source: https://docs.coreprotect.net/api/version/v12 Perform a block lookup using a LookupOptions object for more granular control over search parameters like time. This is an alternative to the direct performLookup method. ```java CoreProtectAPI CoreProtect = getCoreProtect(); if (CoreProtect != null){ // Ensure we have access to the API LookupOptions options = LookupOptions.builder() .time(60) .build(); List lookup = CoreProtect.blockLookup(block, options); if (lookup != null){ for (BlockResult result : lookup){ int x = result.getX(); int y = result.getY(); int z = result.getZ(); // ... } } } ``` -------------------------------- ### logInteraction(String user, Location location) Source: https://docs.coreprotect.net/api/version/v12 Logs a general interaction event. ```APIDOC ## logInteraction(String user, Location location) ### Description Logs a general interaction event performed by a user at a specific location. ### Method POST (assumed, due to user and location parameters) ### Endpoint /api/v12/logInteraction ### Parameters #### Request Body - **user** (String) - Required - The user performing the interaction. - **location** (Location) - Required - The location of the interaction. ### Response #### Success Response (200) - **boolean**: true if the interaction was logged successfully, false otherwise. ``` -------------------------------- ### getCoreProtect Source: https://docs.coreprotect.net/api/version/v12 Retrieves an instance of the CoreProtectAPI, checking for plugin presence, API enablement, and version compatibility. ```APIDOC ## getCoreProtect ### Description Retrieves an instance of the CoreProtectAPI, checking for plugin presence, API enablement, and version compatibility. ### Method `private CoreProtectAPI getCoreProtect()` ### Returns - `CoreProtectAPI` - An instance of the CoreProtectAPI if available and compatible, otherwise `null`. ### Usage Example ```java CoreProtectAPI api = getCoreProtect(); if (api != null) { api.testAPI(); // Will print out "[CoreProtect] API test successful." in the console. } ``` ``` -------------------------------- ### containerLookup(LookupOptions options) Source: https://docs.coreprotect.net/api/version/v12 Looks up container changes using LookupOptions. ```APIDOC ## containerLookup(LookupOptions options) ### Description Looks up container changes using provided LookupOptions. ### Method POST (assumed, due to options parameter) ### Endpoint /api/v12/containerLookup ### Parameters #### Request Body - **options** (LookupOptions) - Required - The options to filter the lookup. ### Response #### Success Response (200) - **List**: A list of ContainerResult objects. ``` -------------------------------- ### Username Lookup with Options Source: https://docs.coreprotect.net/api/version/v12 Performs a username lookup using LookupOptions for filtering. Returns a list of UsernameResult objects. ```java List usernameLookup(LookupOptions options) ``` -------------------------------- ### Set Auto-Purge Time in config.yml Source: https://docs.coreprotect.net/auto-purge Manually set the daily runtime for automatic purging by adding `auto-purge-time` to `config.yml`. Use 24-hour `HH:mm` format. ```yaml auto-purge-time: 03:30 ``` -------------------------------- ### Command Lookup by User and Time Source: https://docs.coreprotect.net/api/version/v12 Retrieves command logs for a specific user within a given time frame. Returns a list of MessageResult objects. ```java List commandLookup(String user, int time) ``` -------------------------------- ### sessionLookup(String user, int time) Source: https://docs.coreprotect.net/api/version/v12 Performs a session lookup for a single player within a specified time frame. ```APIDOC ## sessionLookup(String user, int time) ### Description Performs a session lookup on a single player within a specified time frame. ### Parameters #### Path Parameters - **user** (String) - Required - The username to perform the lookup on. - **time** (int) - Required - Specify the amount of time to lookup. "5" would return results from the last 5 seconds. ### Response Returns `SessionResult` entries with typed access to session event details. ``` -------------------------------- ### commandLookup(String user, int time) Source: https://docs.coreprotect.net/api/version/v12 Looks up command executions for a specific user at a given time. ```APIDOC ## commandLookup(String user, int time) ### Description Looks up command executions for a specific user at a given time. ### Method POST (assumed, due to user parameter) ### Endpoint /api/v12/commandLookup ### Parameters #### Request Body - **user** (String) - Required - The username to look up. - **time** (int) - Required - The time in seconds to look back. ### Response #### Success Response (200) - **List**: A list of MessageResult objects. ``` -------------------------------- ### commandLookup(LookupOptions options) Source: https://docs.coreprotect.net/api/version/v12 Performs a command lookup using a set of shared lookup options. ```APIDOC ## commandLookup(LookupOptions options) ### Description Performs a command lookup using shared lookup options. ### Parameters #### Path Parameters - **options** (LookupOptions) - Required - Specify user, time, location, radius, and limit options. ### Response Returns `MessageResult` entries with typed access to message and command details. ``` -------------------------------- ### Perform Restore with Filters Source: https://docs.coreprotect.net/api/version/v12 Restores previous states based on filters including time, user restrictions, block restrictions, action types, and spatial radius. Returns a list of String arrays representing the restore results. ```java List performRestore(int time, List restrict_users, List exclude_users, List restrict_blocks, List exclude_blocks, List action_list, int radius, Location radius_location) ``` -------------------------------- ### inventoryLookup(LookupOptions options) Source: https://docs.coreprotect.net/api/version/v12 Looks up inventory changes using LookupOptions. ```APIDOC ## inventoryLookup(LookupOptions options) ### Description Looks up inventory changes using provided LookupOptions. ### Method POST (assumed, due to options parameter) ### Endpoint /api/v12/inventoryLookup ### Parameters #### Request Body - **options** (LookupOptions) - Required - The options to filter the lookup. ### Response #### Success Response (200) - **List**: A list of InventoryResult objects. ``` -------------------------------- ### Session Lookup by User and Time Source: https://docs.coreprotect.net/api/version/v12 Retrieves session data for a specific user within a given time frame. Returns a list of String arrays. ```java List sessionLookup(String user, int time) ``` -------------------------------- ### Test CoreProtect API Functionality Source: https://docs.coreprotect.net/api/version/v12 Executes a test that confirms the CoreProtect API is functioning correctly. A success message will appear in the server console. ```java void testAPI() ``` -------------------------------- ### Chat Lookup with Options Source: https://docs.coreprotect.net/api/version/v12 Performs a chat lookup using LookupOptions for filtering. Returns a list of MessageResult objects. ```java List chatLookup(LookupOptions options) ``` -------------------------------- ### sessionLookup(LookupOptions options) Source: https://docs.coreprotect.net/api/version/v12 Looks up session data using LookupOptions. ```APIDOC ## sessionLookup(LookupOptions options) ### Description Looks up session data using provided LookupOptions. ### Method POST (assumed, due to options parameter) ### Endpoint /api/v12/sessionLookup ### Parameters #### Request Body - **options** (LookupOptions) - Required - The options to filter the lookup. ### Response #### Success Response (200) - **List**: A list of SessionResult objects. ``` -------------------------------- ### signLookup(LookupOptions options) Source: https://docs.coreprotect.net/api/version/v12 Looks up sign changes using LookupOptions. ```APIDOC ## signLookup(LookupOptions options) ### Description Looks up sign changes using provided LookupOptions. ### Method POST (assumed, due to options parameter) ### Endpoint /api/v12/signLookup ### Parameters #### Request Body - **options** (LookupOptions) - Required - The options to filter the lookup. ### Response #### Success Response (200) - **List**: A list of SignResult objects. ``` -------------------------------- ### logChat(Player player, String message) Source: https://docs.coreprotect.net/api/version/v12 Logs a chat message. ```APIDOC ## logChat(Player player, String message) ### Description Logs a chat message sent by a player. ### Method POST (assumed, due to player and message parameters) ### Endpoint /api/v12/logChat ### Parameters #### Request Body - **player** (Player) - Required - The player who sent the message. - **message** (String) - Required - The content of the chat message. ### Response #### Success Response (200) - **boolean**: true if the message was logged successfully, false otherwise. ``` -------------------------------- ### containerLookup(Location location, int time) Source: https://docs.coreprotect.net/api/version/v12 Looks up container changes at a specific location at a given time. ```APIDOC ## containerLookup(Location location, int time) ### Description Looks up container changes at a specific location at a given time. ### Method POST (assumed, due to location parameter) ### Endpoint /api/v12/containerLookup ### Parameters #### Request Body - **location** (Location) - Required - The location to look up. - **time** (int) - Required - The time in seconds to look back. ### Response #### Success Response (200) - **List**: A list of ContainerResult objects. ``` -------------------------------- ### inventoryLookup(LookupOptions options) Source: https://docs.coreprotect.net/api/version/v12 Performs a typed player inventory transaction lookup, normalizing inventory additions and removals. ```APIDOC ## inventoryLookup(LookupOptions options) ### Description Performs a typed player inventory transaction lookup, similar to running `/co lookup a:inventory`. Inventory lookup can include block, container, and world item transaction sources, normalized around whether the item was added to or removed from the player's inventory. ### Method Not applicable (Java method signature) ### Parameters #### Path Parameters - **options** (LookupOptions) - Required - Specify user, time, location, radius, and limit options. ### Response Returns `InventoryResult` entries with typed access to transaction details. #### InventoryResult Fields - **getX()**: Get the X coordinate of the inventory transaction. - **getY()**: Get the Y coordinate of the inventory transaction. - **getZ()**: Get the Z coordinate of the inventory transaction. - **getType()**: Get the Material of the item. - **getData()**: Get the legacy item data value. - **getAmount()**: Get the item amount. - **getMetadata()**: Get a copy of the raw item metadata. - **getPlayer()**: Get the username as a string. - **getTimestamp()**: Get the time of the transaction. - **getActionId()**: Get the normalized inventory action ID. (0=removed from inventory, 1=added to inventory) - **getActionString()**: Get the normalized inventory action as a string. (remove, add) - **getTransactionActionId()**: Get the underlying transaction action ID. - **getTransactionActionString()**: Get the underlying transaction action as a string. (remove, add, drop, pickup, withdraw, deposit, throw, shoot, break, destroy, create, sell, buy) - **getSourceId()**: Get the source table ID. (0=block, 1=container, 2=item) - **getSource()**: Get the source as a string. (block, container, item) - **isRolledBack()**: If the transaction is currently rolled back or not. - **worldName()**: The name of the world where the inventory transaction occurred. ``` -------------------------------- ### logInteraction Source: https://docs.coreprotect.net/api/version/v12 Logs a block interaction. ```APIDOC ## `logInteraction(String user, Location location)` ### Description Logs a block as having been interacted with. ### Parameters #### Request Body - **user** (String) - Required - The username to log as having caused the interaction. - **location** (Location) - Required - The location of the interaction being logged. ### Method POST ``` -------------------------------- ### itemLookup(LookupOptions options) Source: https://docs.coreprotect.net/api/version/v12 Performs a typed world item transaction lookup, returning drops and pickups. ```APIDOC ## itemLookup(LookupOptions options) ### Description Performs a typed world item transaction lookup, similar to running `/co lookup a:item`. This returns world item transactions such as drops and pickups. Use `inventoryLookup(LookupOptions)` for player inventory transactions. ### Method Not applicable (Java method signature) ### Parameters #### Path Parameters - **options** (LookupOptions) - Required - Specify user, time, location, radius, and limit options. ### Response Returns `ItemResult` entries with typed access to transaction details. #### ItemResult Fields - **getX()**: Get the X coordinate of the item transaction. - **getY()**: Get the Y coordinate of the item transaction. - **getZ()**: Get the Z coordinate of the item transaction. - **getType()**: Get the Material of the item. - **getAmount()**: Get the item amount. - **getMetadata()**: Get a copy of the raw item metadata. - **getPlayer()**: Get the username as a string. - **getTimestamp()**: Get the time of the transaction. - **getActionId()**: Get the item transaction action ID. - **getActionString()**: Get the item action as a string. (remove, add, drop, pickup, withdraw, deposit, throw, shoot) - **isRolledBack()**: If the transaction is currently rolled back or not. - **worldName()**: The name of the world where the item transaction occurred. ``` -------------------------------- ### Log Block Removal by User and BlockState Source: https://docs.coreprotect.net/api/version/v12 Logs the removal of a block by a user, using the BlockState for details. Returns a boolean indicating success. ```java boolean logRemoval(String user, BlockState blockState) ``` -------------------------------- ### usernameLookup(LookupOptions options) Source: https://docs.coreprotect.net/api/version/v12 Looks up username changes using LookupOptions. ```APIDOC ## usernameLookup(LookupOptions options) ### Description Looks up username changes using provided LookupOptions. ### Method POST (assumed, due to options parameter) ### Endpoint /api/v12/usernameLookup ### Parameters #### Request Body - **options** (LookupOptions) - Required - The options to filter the lookup. ### Response #### Success Response (200) - **List**: A list of UsernameResult objects. ``` -------------------------------- ### Perform Lookup with Filters Source: https://docs.coreprotect.net/api/version/v12 Retrieves a list of String arrays representing lookup results based on various filters including time, user restrictions, block restrictions, action types, and spatial radius. ```java List performLookup(int time, List restrict_users, List exclude_users, List restrict_blocks, List exclude_blocks, List action_list, int radius, Location radius_location) ``` -------------------------------- ### Block Lookup by Block and Time Source: https://docs.coreprotect.net/api/version/v12 Retrieves lookup results for a specific block at a given time. Returns a list of String arrays. ```java List blockLookup(Block block, int time) ``` -------------------------------- ### containerLookup(LookupOptions options) Source: https://docs.coreprotect.net/api/version/v12 Performs a container transaction lookup using a set of shared lookup options. ```APIDOC ## containerLookup(LookupOptions options) ### Description Performs a container transaction lookup using shared lookup options, which can include user, time, location, radius, and limit. ### Method Not applicable (Java method signature) ### Parameters #### Path Parameters - **options** (LookupOptions) - Required - Specify user, time, location, radius, and limit options. ### Response Returns `ContainerResult` entries with typed access to transaction details. #### ContainerResult Fields - **getX()**: Get the X coordinate of the container. - **getY()**: Get the Y coordinate of the container. - **getZ()**: Get the Z coordinate of the container. - **getType()**: Get the Material of the item. - **getData()**: Get the item data value. - **getAmount()**: Get the item amount. - **getMetadata()**: Get a copy of the raw item metadata. - **getPlayer()**: Get the username as a string. - **getTimestamp()**: Get the time of the transaction. - **getActionId()**: Get the action ID. (0=removed, 1=added) - **getActionString()**: Get the action as a string. (remove, add) - **isRolledBack()**: If the transaction is currently rolled back or not. - **worldName()**: The name of the world the container is located in. ``` -------------------------------- ### containerLookup(Location location, int time) Source: https://docs.coreprotect.net/api/version/v12 Performs a container transaction lookup at a specific location for a given time duration. ```APIDOC ## containerLookup(Location location, int time) ### Description Performs a container transaction lookup at a single location for a specified duration. ### Method Not applicable (Java method signature) ### Parameters #### Path Parameters - **location** (Location) - Required - The location to perform the lookup on. - **time** (int) - Required - Specify the amount of time to lookup. "5" would return results from the last 5 seconds. ### Response Returns `ContainerResult` entries with typed access to transaction details. #### ContainerResult Fields - **getX()**: Get the X coordinate of the container. - **getY()**: Get the Y coordinate of the container. - **getZ()**: Get the Z coordinate of the container. - **getType()**: Get the Material of the item. - **getData()**: Get the item data value. - **getAmount()**: Get the item amount. - **getMetadata()**: Get a copy of the raw item metadata. - **getPlayer()**: Get the username as a string. - **getTimestamp()**: Get the time of the transaction. - **getActionId()**: Get the action ID. (0=removed, 1=added) - **getActionString()**: Get the action as a string. (remove, add) - **isRolledBack()**: If the transaction is currently rolled back or not. - **worldName()**: The name of the world the container is located in. ``` -------------------------------- ### Shared Typed API Helpers (API v12) Source: https://docs.coreprotect.net/api/version/v12 API v12 introduces shared helper classes like LookupOptions, CoreProtectResult, and CoreProtectAction for typed lookups. ```java LookupOptions CoreProtectResult CoreProtectAction ``` -------------------------------- ### Container Lookup by Location and Time Source: https://docs.coreprotect.net/api/version/v12 Retrieves lookup results for containers at a specific location and time. Returns a list of ContainerResult objects. ```java List containerLookup(Location location, int time) ``` -------------------------------- ### itemLookup(LookupOptions options) Source: https://docs.coreprotect.net/api/version/v12 Looks up item changes using LookupOptions. ```APIDOC ## itemLookup(LookupOptions options) ### Description Looks up item changes using provided LookupOptions. ### Method POST (assumed, due to options parameter) ### Endpoint /api/v12/itemLookup ### Parameters #### Request Body - **options** (LookupOptions) - Required - The options to filter the lookup. ### Response #### Success Response (200) - **List**: A list of ItemResult objects. ``` -------------------------------- ### Lookup Sign Text by Location Source: https://docs.coreprotect.net/api/version/v12 Retrieves sign text at a specific location within a given time frame. Ensure CoreProtectAPI is accessible. ```java CoreProtectAPI CoreProtect = getCoreProtect(); if (CoreProtect != null){ // Ensure we have access to the API List lookup = CoreProtect.signLookup(location, 60); if (lookup != null){ for (SignResult result : lookup){ String message = result.getMessage(); String[] lines = result.getLines(); // ... } } } ``` -------------------------------- ### Client to Server Handshake Packet Source: https://docs.coreprotect.net/api/networking Sends handshake to register the client. Requires client to provide mod version, mod ID, and CoreProtect protocol version. ```APIDOC ## Client to Server Handshake Packet ### Description Sends handshake to register. ### Channel `coreprotect:handshake` ### Fields - **Mod Version** (UTF) - **Mod Id** (UTF) - **CoreProtect Protocol** (Int) ### Request Example (Fabric) ```java PacketByteBuf packetByteBuf = new PacketByteBuf(Unpooled.buffer()); ByteArrayOutputStream msgBytes = new ByteArrayOutputStream(); DataOutputStream msgOut = new DataOutputStream(msgBytes); msgOut.writeUTF(modVersion); msgOut.writeUTF(modId); msgOut.writeInt(coreprotectProtocol); packetByteBuf.writeBytes(msgBytes.toByteArray()); ``` ``` -------------------------------- ### isEnabled() Source: https://docs.coreprotect.net/api/version/v12 Checks if the CoreProtect API is enabled on the server. Returns true if enabled, false otherwise. ```APIDOC ## isEnabled() ### Description Checks if the CoreProtect API is enabled on the server. ### Method GET (assumed, as it's a query) ### Endpoint /api/v12/isEnabled ### Response #### Success Response (200) - **boolean**: true if the API is enabled, false otherwise. ``` -------------------------------- ### Lookup Session Data Source: https://docs.coreprotect.net/api/version/v12 Retrieves session data (login/logout) for a specific user over a period of one day. Ensure CoreProtectAPI is accessible. ```java CoreProtectAPI CoreProtect = getCoreProtect(); if (CoreProtect != null){ // Ensure we have access to the API LookupOptions options = LookupOptions.builder() .user("Notch") .time(24 * 60 * 60) .build(); List lookup = CoreProtect.sessionLookup(options); if (lookup != null){ for (SessionResult result : lookup){ int x = result.getX(); int y = result.getY(); int z = result.getZ(); int action = result.getActionId(); // 0 = logout, 1 = login // ... } } } ``` -------------------------------- ### Log Block Removal by User, Location, and Material Source: https://docs.coreprotect.net/api/version/v12 Logs the removal of a block by a user, specifying location, material type, and block data. Returns a boolean indicating success. ```java boolean logRemoval(String user, Location location, Material type, BlockData blockData) ``` -------------------------------- ### containerLookup (LookupOptions) Source: https://docs.coreprotect.net/api/version/v12 Retrieves container transaction data within a specified radius of a location, with optional time frame. ```APIDOC ## containerLookup (LookupOptions) ### Description Retrieves container transaction data within a specified radius of a location, with optional time frame. ### Method CoreProtectAPI.containerLookup ### Parameters - **options** (LookupOptions) - Required - An object containing lookup parameters like time and radius. ### Request Example ```java CoreProtectAPI CoreProtect = getCoreProtect(); if (CoreProtect != null) { // Ensure we have access to the API LookupOptions options = LookupOptions.builder() .time(60) .radius(location, 5) .build(); List lookup = CoreProtect.containerLookup(options); if (lookup != null) { for (ContainerResult result : lookup) { // ... access ContainerResult data ... } } } ``` ### Response #### Success Response - **lookup** (List) - A list of ContainerResult objects containing transaction data. #### Response Example ```java // Example of a single result element: // int x = result.getX(); // int y = result.getY(); // int z = result.getZ(); // Material type = result.getType(); // int amount = result.getAmount(); ``` ``` -------------------------------- ### Queue Lookup by Block Source: https://docs.coreprotect.net/api/version/v12 Retrieves queue lookup results for a specific block. Returns a list of String arrays. ```java List queueLookup(Block block) ``` -------------------------------- ### sessionLookup(String user, int time) Source: https://docs.coreprotect.net/api/version/v12 Looks up session data for a specific user at a given time. ```APIDOC ## sessionLookup(String user, int time) ### Description Looks up session data for a specific user at a given time. ### Method POST (assumed, due to user parameter) ### Endpoint /api/v12/sessionLookup ### Parameters #### Request Body - **user** (String) - Required - The username to look up. - **time** (int) - Required - The time in seconds to look back. ### Response #### Success Response (200) - **List**: A list of string arrays representing the session lookup results. ``` -------------------------------- ### Log Block Interaction Source: https://docs.coreprotect.net/api/version/v12 Logs a user's interaction with a block at a specific location. Returns a boolean indicating success. ```java boolean logInteraction(String user, Location location) ``` -------------------------------- ### Username Lookup by User and Time Source: https://docs.coreprotect.net/api/version/v12 Retrieves username data for a specific user within a given time frame. Returns a list of UsernameResult objects. ```java List usernameLookup(String user, int time) ``` -------------------------------- ### Lookup Inventory Transactions Source: https://docs.coreprotect.net/api/version/v12 Retrieves player inventory transactions within a specified radius and time frame. Ensure CoreProtectAPI is accessible. ```java CoreProtectAPI CoreProtect = getCoreProtect(); if (CoreProtect != null){ // Ensure we have access to the API LookupOptions options = LookupOptions.builder() .time(60) .radius(location, 5) .build(); List lookup = CoreProtect.inventoryLookup(options); if (lookup != null){ for (InventoryResult result : lookup){ Material type = result.getType(); int amount = result.getAmount(); String action = result.getActionString(); String source = result.getSource(); // ... } } } ``` -------------------------------- ### sessionLookup(LookupOptions options) Source: https://docs.coreprotect.net/api/version/v12 Performs a typed session lookup using a set of shared lookup options. ```APIDOC ## sessionLookup(LookupOptions options) ### Description Performs a typed session lookup using shared lookup options. ### Parameters #### Path Parameters - **options** (LookupOptions) - Required - Specify user, time, location, radius, and limit filters using `LookupOptions`. ### Response Returns `SessionResult` entries with typed access to session event details. ``` -------------------------------- ### inventoryLookup Source: https://docs.coreprotect.net/api/version/v12 Performs a lookup for player inventory transactions. ```APIDOC ## inventoryLookup ### Description Performs a lookup for player inventory transactions. ### Method `List inventoryLookup(LookupOptions options)` ### Parameters - **options** (LookupOptions) - Options to configure the lookup, including user, time, location, radius, and limit. ``` -------------------------------- ### logRemoval(String user, Location location, Material type, BlockData blockData) Source: https://docs.coreprotect.net/api/version/v12 Logs a block removal event with detailed information. ```APIDOC ## logRemoval(String user, Location location, Material type, BlockData blockData) ### Description Logs a block removal event with detailed information including user, location, material type, and block data. ### Method POST (assumed, due to multiple parameters) ### Endpoint /api/v12/logRemoval ### Parameters #### Request Body - **user** (String) - Required - The user who removed the block. - **location** (Location) - Required - The location where the block was removed. - **type** (Material) - Required - The material type of the block. - **blockData** (BlockData) - Required - The data associated with the block. ### Response #### Success Response (200) - **boolean**: true if the removal was logged successfully, false otherwise. ``` -------------------------------- ### Check Block Placement in a Thread Source: https://docs.coreprotect.net/api/version/v12 Use this snippet to perform a multi-threaded check for block placements by a specific user within a given timeframe. It ignores the most recent second of data to account for potential logging delays. ```java final Block block = null; //Should be an actual block class BasicThread implements Runnable { @Override public void run() { try { CoreProtectAPI CoreProtect = getCoreProtect(); if (CoreProtect != null){ // Ensure we have access to the API boolean hasPlaced = CoreProtect.hasPlaced("Notch", block, 60, 1); } } catch (Exception e){ e.printStackTrace(); } } } Runnable runnable = new BasicThread(); Thread thread = new Thread(runnable); thread.start(); ``` -------------------------------- ### logRemoval Source: https://docs.coreprotect.net/api/version/v12 Logs a block removal action. ```APIDOC ## `logRemoval(String user, BlockState blockState)` ### Description Logs a block as being removed/broken. (Thread safe) ### Parameters #### Request Body - **user** (String) - Required - The username to log as having removed the block. - **blockState** (BlockState) - Required - The BlockState of the block being logged. ### Method POST ``` ```APIDOC ## `logRemoval(String user, Location location, Material type, BlockData blockData)` ### Description Logs a block as being removed/broken, and logs the block's inventory (if applicable). ### Parameters #### Request Body - **user** (String) - Required - The username to log as having removed the block. - **location** (Location) - Required - The location of the block being logged. - **type** (Material) - Required - The Material of the block being logged. - **blockData** (BlockData) - Required - The BlockData of the block being logged. Can be set to "null". ### Method POST ``` -------------------------------- ### signLookup(LookupOptions options) Source: https://docs.coreprotect.net/api/version/v12 Performs a sign text lookup using a set of shared lookup options. ```APIDOC ## signLookup(LookupOptions options) ### Description Performs a sign text lookup using shared lookup options. ### Parameters #### Path Parameters - **options** (LookupOptions) - Required - Specify user, time, location, radius, and limit options. ### Response Returns `SignResult` entries with typed access to sign details. ``` -------------------------------- ### Lookup Sign Text by User and Location Source: https://docs.coreprotect.net/api/version/v12 Retrieves sign text written by a specific user within a radius and time frame. Ensure CoreProtectAPI is accessible. ```java CoreProtectAPI CoreProtect = getCoreProtect(); if (CoreProtect != null){ // Ensure we have access to the API LookupOptions options = LookupOptions.builder() .user("Notch") .time(60) .radius(location, 5) .build(); List lookup = CoreProtect.signLookup(options); if (lookup != null){ for (SignResult result : lookup){ int x = result.getX(); int y = result.getY(); int z = result.getZ(); // ... } } } ```