Skip to main content

⌨️ API

Repository

Add CraftEngine API to your project:

repositories {
maven("https://repo.momirealms.net/releases/")
}
dependencies {
compileOnly("net.momirealms:craft-engine-core:{version}") // replace "{version}" with the plugin version
compileOnly("net.momirealms:craft-engine-bukkit:{version}") // for instance 0.0.60
}

Make sure to add CraftEngine as a dependency for your plugin:

softdepend:
- CraftEngine
caution

Be Aware with Changes

Only the contents under the api package are considered stable. Other methods of interacting with the plugin are unstable and subject to change, especially during the current beta phase.

The content available at the following link is considered stable and covers 90% of API usage requirements: https://github.com/Xiao-MoMi/craft-engine/tree/main/bukkit/src/main/java/net/momirealms/craftengine/bukkit/api

info

If you're eager to start registering your own block behaviors, you can reference some of our built-in implementations as examples. https://github.com/Xiao-MoMi/craft-engine/tree/main/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior

Some Development Conventions

Naming

  1. IDs for new types: Use lowercase letters with underscores (e.g., my_plugin:test_function).
  2. Config parameters: If users need to pass values in config files, use hyphens (-) for keys (better readability).

Example:

type: my_plugin:test_function
send-to-all: true
message: "Test TeST tEST"

Block Events

Please avoid directly using events like CustomBlockBreakEvent. Instead, you should:

  1. Listen to the corresponding Bukkit event (e.g., BlockBreakEvent).
  2. Retrieve the BlockData from the event.
  3. Convert it to a custom block using the CraftEngineBlocks class for further processing.

Using Bukkit events allows you to achieve everything you need in a more comprehensive way, without requiring additional learning.

Regarding Registration

When registering new block behaviors, item behaviors, or host types and etc, please first check if there are corresponding constant classes available (e.g., BlockBehaviors, ItemBehaviors). It is strongly recommended to use the register methods provided within these classes for your registrations.

info

The API documentation will undergo restructuring after the official release to include more advanced examples.