Quickstart
Build a small shop plugin with a menu, items and messages that runs on 1.8 and on Paper 26.
This walk-through builds the plugin from the homepage: a shop menu that feeds the player, opened when they join.
It assumes you completed Installation with bloom-gui and both adapters.
1. Enable Bloom
Bloom.enable(this) detects the server, picks the adapter and starts Bloom's services. bloom.shutdown() stops
everything Bloom started for your plugin, in order. Always pair them.
public final class MyPlugin extends JavaPlugin {
private Bloom bloom;
@Override
public void onEnable() {
bloom = Bloom.enable(this);
bloom.messages().send(getServer().getConsoleSender(), "&dHello from Bloom on " + bloom.platform().describe());
}
@Override
public void onDisable() {
if (bloom != null) {
bloom.shutdown();
}
}
}2. Build an item and a menu
Items use modern material names on every server. On 1.8, COOKED_BEEF stays the same and names that changed in
1.13, such as LIME_WOOL, are mapped to their legacy material and data value automatically.
public final class ShopPlugin extends JavaPlugin {
private Bloom bloom;
@Override
public void onEnable() {
bloom = Bloom.enable(this); // detects 1.7.10 ... 26.x and loads the matching adapter
Items items = Items.of(bloom);
Menu shop = Menu.builder()
.title("&dBlossom Shop")
.rows(3)
.button(
13,
Button.of(items.builder("COOKED_BEEF").name("&6Feed me").build(), click -> {
click.player().setFoodLevel(20);
bloom.messages().actionBar(click.player(), "&aYum!");
click.close();
}))
.build();
bloom.events()
.subscribe(
PlayerJoinEvent.class,
event -> bloom.scheduler()
.syncLater(() -> Menus.of(bloom).open(event.getPlayer(), shop), 20));
}
@Override
public void onDisable() {
bloom.shutdown(); // closes menus, cancels tasks, unregisters listeners
}
}A few things happen for you here:
- The menu cancels every click and drag, so the item can never be taken out.
click.close()waits until the next tick, which is the safe moment to close an inventory.actionBarshows an action bar on servers that have one and is skipped, with one console warning, on 1.7.10.- The join listener and the delayed task are removed when the plugin disables.
3. Build and run
./gradlew shadowJarPut the jar from build/libs into a test server's plugins folder and join. The startup log tells you which
adapter Bloom chose and which capabilities the server has.
Next steps
- Menus: layouts, pagination and navigation.
- Items: custom items that survive renames and server restarts.
- Configuration: let server owners change prices and titles.
- Storage: keep player data in SQLite or MySQL.