### Execute Gradle Build Commands Source: https://github.com/bentoboxworld/bentobox/blob/develop/CLAUDE.md Standard build and testing commands for the BentoBox project. ```bash ./gradlew build # Build the shaded JAR ./gradlew test # Run all tests ./gradlew clean build # Clean then build ./gradlew jacocoTestReport # Generate coverage report (build/reports/jacoco/) ``` -------------------------------- ### Load Configuration Object Source: https://github.com/bentoboxworld/bentobox/wiki/Config-API Load a configuration object using the Config class. This method requires the addon instance and the settings class. ```java Settings settings = new Config<>(this, Settings.class).loadConfigObject(); ``` -------------------------------- ### Provide Addon Description Source: https://github.com/bentoboxworld/bentobox/wiki/How-to-fill-in-the-addon.yml-file A descriptive text explaining the addon's functionality. This can span multiple lines and is displayed in the /bsadmin version command. ```yaml description: "It makes you die when you jump. So 2017." ``` -------------------------------- ### Basic Config Class Implementation Source: https://github.com/bentoboxworld/bentobox/wiki/Config-API Implement the ConfigObject interface to define a configuration class. This class will represent your plugin's configuration structure. ```java public class Settings implements ConfigObject { } ``` -------------------------------- ### Document map parameters and return values Source: https://github.com/bentoboxworld/bentobox/wiki/Request-Handler-API---How-plugins-can-get-data-from-addons Document the expected input map keys/types and the potential return values for clarity to plugin developers. ```java /* What we need in the map: 0. "world-name" -> String 1. "player" -> UUID What we will return: - 0L if invalid input/player has no island - the island level otherwise (which may be 0) */ ``` -------------------------------- ### Link to Addon Website Source: https://github.com/bentoboxworld/bentobox/wiki/How-to-fill-in-the-addon.yml-file Specifies a URL for the addon's website or GitHub repository. This is displayed in the /bsadmin version command. ```yaml website: "https://github.com/tastybento/bskyblock" ``` -------------------------------- ### Instantiate a BSBDatabase Object Source: https://github.com/bentoboxworld/bentobox/wiki/Database-API Create a BSBDatabase object to interact with your data class. Pass the plugin instance and the class itself as arguments. ```java BSBDatabase names = new BSBDatabase<>(plugin, Names.class); ``` -------------------------------- ### Specify Config File Location Source: https://github.com/bentoboxworld/bentobox/wiki/Config-API Use the @StoreAt annotation to specify the filename for your configuration. The location is relative to the addon's data folder. ```java @StoreAt(filename="config.yml") // Explicitly call out what name this should have. public class Settings implements ConfigObject { } ``` -------------------------------- ### Configure Maven Repository and Dependency Source: https://github.com/bentoboxworld/bentobox/blob/develop/README.md Add the CodeMC repositories and the BentoBox dependency to your Maven project. Ensure you replace PUT-VERSION-HERE with the correct version. ```xml codemc-snapshots https://repo.codemc.org/repository/maven-snapshots codemc-repo https://repo.codemc.org/repository/maven-public/ world.bentobox bentobox PUT-VERSION-HERE provided ``` -------------------------------- ### Utilize Key API Patterns Source: https://github.com/bentoboxworld/bentobox/blob/develop/CLAUDE.md Common patterns for island interactions, messaging, and manager access. ```java // Island permission check island.isAllowed(user, flag); // Localized player messaging (never use player.sendMessage() directly) user.sendMessage("protection.protected"); // Island lookup Optional island = plugin.getIslands().getIslandAt(location); // All managers accessed via singleton plugin.getIslands() // IslandsManager plugin.getIWM() // IslandWorldManager plugin.getFlagsManager() // FlagsManager ``` -------------------------------- ### Specify Main Class Source: https://github.com/bentoboxworld/bentobox/wiki/How-to-fill-in-the-addon.yml-file Provides the full namespace and class name that extends BSAddon. This is essential for BSkyBlock to locate and load your addon's primary class. ```yaml main: fr.poslovitch.myaddon.MySuperAddon ``` -------------------------------- ### Run Specific Tests Source: https://github.com/bentoboxworld/bentobox/blob/develop/CLAUDE.md Commands to execute tests at the class or method level. ```bash # Run all tests in a class ./gradlew test --tests "world.bentobox.bentobox.managers.IslandsManagerTest" # Run a specific test method ./gradlew test --tests "world.bentobox.bentobox.managers.IslandsManagerTest.testMethodName" ``` -------------------------------- ### Configure Gradle Repository and Dependency Source: https://github.com/bentoboxworld/bentobox/blob/develop/README.md Add the CodeMC public repository and the BentoBox dependency to your Gradle project. For snapshot versions, append -SNAPSHOT to the version number. ```groovy repositories { maven { url "https://repo.codemc.org/repository/maven-public/" } } dependencies { compileOnly 'world.bentobox:bentobox:PUT-VERSION-HERE-SNAPSHOT' } ``` -------------------------------- ### Save Configuration Object Source: https://github.com/bentoboxworld/bentobox/wiki/Config-API Save a configuration object using the Config class. This method requires the addon instance and the settings class. ```java Settings settings = new Settings(); new Config<>(this, Settings.class).saveConfigObject(settings); ``` -------------------------------- ### List Addon Authors Source: https://github.com/bentoboxworld/bentobox/wiki/How-to-fill-in-the-addon.yml-file An array of strings listing the developers of the addon. This provides credit and is displayed in the /bsadmin version command. ```yaml authors: - "Poslovitch" - "Tastybento" - "you, maybe? :P" # Don't hesitate to add our nicknames into the authors list of your addon, we would appreciate that! ``` -------------------------------- ### Set Addon Version Source: https://github.com/bentoboxworld/bentobox/wiki/How-to-fill-in-the-addon.yml-file Defines the version of your addon. While arbitrary, the common format is Major.Minor.Fix (e.g., 1.0.0). This is displayed in commands like /bsadmin version. ```yaml version: 1.0.0 ``` -------------------------------- ### Load All Objects from Database Source: https://github.com/bentoboxworld/bentobox/wiki/Database-API Use loadObjects() to load all database entries into memory as a List. This operation can be time-consuming and should be performed asynchronously. ```java List uuids = names.loadObjects(); ``` -------------------------------- ### Configure server.properties for Default World Name Source: https://github.com/bentoboxworld/bentobox/wiki/Set-a-BentoBox-world-as-the-server-default-world Modify the 'level-name' property in 'server.properties' to match your BentoBox world's name. This ensures the server loads the correct world on startup. ```properties level-name=bskyblock_world ``` -------------------------------- ### Save Data to the Database Source: https://github.com/bentoboxworld/bentobox/wiki/Database-API Instantiate your data object, populate it with data, and then use the saveObject() method to persist it to the database. Existing objects with the same uniqueId will be overwritten. ```java names.saveObject(new Names(user.getName(), user.getUniqueId())); ``` -------------------------------- ### Add Getters and Setters for Config Entries Source: https://github.com/bentoboxworld/bentobox/wiki/Config-API Implement getters and setters that follow JavaBeans Naming Conventions to access and modify the configuration fields. This is crucial for the Config API to function correctly. ```java @StoreAt(filename="config.yml") // Explicitly call out what name this should have. public class Settings implements ConfigObject { @ConfigEntry(path = "world.name") private String worldName = "My_world_name"; @ConfigEntry(path = "world.size") private int worldSize = 100; public String getWorldName() { return worldName; } public void setWorldName(String worldName) { this.worldName = worldName; } public int getWorldSize() { return worldSize; } public void setWorldSize(int worldSize) { this.worldSize = worldSize; } } ``` -------------------------------- ### Configure Paste Speed in BentoBox Source: https://github.com/bentoboxworld/bentobox/wiki/Home Adjust the 'paste-speed' setting in the BentoBox config.yml to manage server lag during blueprint pasting. Lower values reduce lag but increase pasting time. ```yaml # Number of blocks to paste per tick when pasting blueprints. # Smaller values will help reduce noticeable lag but will make pasting take slightly longer. # On the contrary, greater values will make pasting take less time, but this benefit is quickly severely impacted by the # resulting amount of chunks that must be loaded to fulfill the process, which often causes the server to hang out. paste-speed: 64 ``` -------------------------------- ### Request player's island level from Level addon Source: https://github.com/bentoboxworld/bentobox/wiki/Request-Handler-API---How-plugins-can-get-data-from-addons Use this to obtain a player's island level from the Level addon. Requires the player's UUID and the world name. ```java UUID uuid = player.getUniqueId(); Long result = (Long)AddonRequestBuilder .addon("Level") .label("island-level") .addMetaData("world-name", uuid) .request(); ``` -------------------------------- ### Add Comments to Config Entries with @ConfigComment Source: https://github.com/bentoboxworld/bentobox/wiki/Config-API Utilize the @ConfigComment annotation to add comments to your configuration file. These comments will be preserved when the configuration is saved. ```java @StoreAt(filename="config.yml") // Explicitly call out what name this should have. @ConfigComment("This is my config.yml file") // Note that the comment will automatically @ConfigComment("It is for my addon") // be proceeded with a # and space public class Settings implements ConfigObject { @ConfigEntry(path = "world.name") @ConfigComment("This is the name of the world.") private String worldName = "My_world_name"; @ConfigEntry(path = "world.size") @ConfigComment("Size - minimum is 10, max is 100") private int worldSize = 100; public String getWorldName() { return worldName; } public void setWorldName(String worldName) { this.worldName = worldName; } public int getWorldSize() { return worldSize; } public void setWorldSize(int worldSize) { this.worldSize = worldSize; } } ``` -------------------------------- ### Define Addon Name Source: https://github.com/bentoboxworld/bentobox/wiki/How-to-fill-in-the-addon.yml-file Specifies the unique name of the addon. This name must consist of alphanumeric characters and underscores. Spaces are converted to underscores. It's used for identification within the BSkyBlock API and in commands like /bsadmin version. ```yaml name: "MySuperAddon" ``` -------------------------------- ### Implement a Protection Listener Source: https://github.com/bentoboxworld/bentobox/blob/develop/CLAUDE.md Extend FlagListener to handle protection logic. The checkIsland method automatically manages rank checks and event cancellation. ```java public class MyListener extends FlagListener { @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onSomeEvent(SomeEvent e) { checkIsland(e, e.getPlayer(), e.getBlock().getLocation(), Flags.BLOCK_BREAK); } } ``` -------------------------------- ### Handle incoming data requests Source: https://github.com/bentoboxworld/bentobox/wiki/Request-Handler-API---How-plugins-can-get-data-from-addons Override the handle method to process incoming data requests. Define the expected map contents and return type. ```java @Override public Object handle(Map map) { ``` -------------------------------- ### Configure bukkit.yml for Custom World Generators Source: https://github.com/bentoboxworld/bentobox/wiki/Set-a-BentoBox-world-as-the-server-default-world Specify the 'BentoBox' generator for your BentoBox worlds in 'bukkit.yml'. This is crucial to prevent Bukkit from attempting to generate these worlds with its default mechanics. ```yaml worlds: bskyblock_world: generator: BentoBox bskyblock_world_nether: generator: BentoBox bskyblock_world_the_end: generator: BentoBox ``` -------------------------------- ### Define a Data Object for BentoBox Database Source: https://github.com/bentoboxworld/bentobox/wiki/Database-API Create a class extending DataObject to store data. Ensure it has a uniqueId field, an @Expose annotation for fields to be stored, and a zero-argument constructor. ```java public class Names implements DataObject { @Expose private String uniqueId = ""; // name @Expose private UUID uuid; public Names() {} public Names(String name, UUID uuid) { this.uniqueId = name; this.uuid = uuid; } @Override public String getUniqueId() { return uniqueId; } @Override public void setUniqueId(String uniqueId) { this.uniqueId = uniqueId; } /** * @return the uuid */ public UUID getUuid() { return uuid; } /** * @param uuid the uuid to set */ public void setUuid(UUID uuid) { this.uuid = uuid; } } ``` -------------------------------- ### Process map and return island level Source: https://github.com/bentoboxworld/bentobox/wiki/Request-Handler-API---How-plugins-can-get-data-from-addons Validate the input map for required parameters and types before retrieving and returning the island level. Ensure parameter checking for robustness. ```java if (map == null || map.isEmpty() || map.get("world-name") == null || !(map.get("world-name") instanceof String) || map.get("player") == null || !(map.get("player") instanceof UUID) || Bukkit.getWorld((String) map.get("world-name")) == null) { return 0L; } return addon.getIslandLevel(Bukkit.getWorld((String) map.get("world-name")), (UUID) map.get("player")); ``` -------------------------------- ### Load a Single Object from the Database Source: https://github.com/bentoboxworld/bentobox/wiki/Database-API Retrieve a specific record from the database by providing its uniqueId to the loadObject() method. You can then access its fields directly. ```java Names loadedName = names.loadObject("tastybento"); ``` ```java UUID uuid = names.loadObject(string).getUuid(); ``` -------------------------------- ### Register request handlers in an addon Source: https://github.com/bentoboxworld/bentobox/wiki/Request-Handler-API---How-plugins-can-get-data-from-addons Register instances of your custom request handler classes within your addon's main class. ```java // Register request handlers registerRequestHandler(new LevelRequestHandler(this)); registerRequestHandler(new TopTenRequestHandler(this)); ``` -------------------------------- ### Define Config Entries with @ConfigEntry Source: https://github.com/bentoboxworld/bentobox/wiki/Config-API Use the @ConfigEntry annotation to map class fields to specific paths within the YAML configuration file. Default values can be assigned to these fields. ```java @StoreAt(filename="config.yml") // Explicitly call out what name this should have. public class Settings implements ConfigObject { @ConfigEntry(path = "world.name") private String worldName = "My_world_name"; @ConfigEntry(path = "world.size") private int worldSize = 100; } ``` -------------------------------- ### Check if Object Exists in Database Source: https://github.com/bentoboxworld/bentobox/wiki/Database-API Verify if an object exists in the database using its unique ID. This check can also be time-consuming and is best performed off the main thread. ```java return names.objectExists("tastybento") ? "he exists in the db" : "who?'; ``` -------------------------------- ### Close Database Connection Source: https://github.com/bentoboxworld/bentobox/wiki/Database-API Explicitly close the database connection to release resources immediately. Connections are typically auto-closed when the plugin is disabled. ```java names.close() ``` -------------------------------- ### Define LevelRequestHandler label Source: https://github.com/bentoboxworld/bentobox/wiki/Request-Handler-API---How-plugins-can-get-data-from-addons Set the unique label for your request handler in its constructor. This label is used by plugins to request data. ```java public LevelRequestHandler(Level addon) { super("island-level"); // the label is "island-level" this.addon = addon; } ``` -------------------------------- ### Delete Object from Database Source: https://github.com/bentoboxworld/bentobox/wiki/Database-API Remove an object from the database by providing its unique ID. The method logs errors if deletion fails but is otherwise silent. ```java names.deleteObject("tastybento"); ``` -------------------------------- ### Suppress SonarCloud rules for public API Source: https://github.com/bentoboxworld/bentobox/blob/develop/CLAUDE.md Use this annotation to prevent binary-incompatible changes when refactoring public API methods that rely on Guava types. ```java @SuppressWarnings("java:S4738") // ImmutableSet is intentional public API; changing return type is binary-incompatible public ImmutableSet getMemberSet() { ... } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.