Skip to main content

XDiscordUltimate Developer Documentation

Technical documentation for developers integrating with XDiscordUltimate, querying verified accounts, listening to the event bus, or writing custom modules.

What You Can Do

Architecture

How the core, module system, data layer, and event bus fit together.

Building from Source

Clone, compile with Gradle, and locate the shaded JAR.

Writing Modules

Extend the Module abstraction to add your own Discord features.

API Overview

The public API surface: database, events, managers, and placeholders.

Entry Point

XDiscordUltimate is a standard Bukkit plugin. The main class is a singleton accessed statically:
import com.xreatlabs.xdiscordultimate.XDiscordUltimate;

XDiscordUltimate plugin = XDiscordUltimate.getInstance();
From the singleton you reach every subsystem through getters: getConfigManager(), getMessageManager(), getAdminUtils(), getEmbedUtils(), getDatabaseManager(), getModuleManager(), getDiscordManager(), getHelpGUI(), plus the optional hooks getLuckPerms(), isLuckPermsEnabled(), isPlaceholderAPIEnabled(), parsePlaceholders(String, Player), and getStartTime().

Hello, Developer

The smallest useful integration looks up the Discord ID linked to a Minecraft player. The DatabaseManager returns a CompletableFuture for every read/write, so never block the main thread waiting for it.
import com.xreatlabs.xdiscordultimate.XDiscordUltimate;
import org.bukkit.entity.Player;

public void greetLinkedPlayer(Player player) {
    XDiscordUltimate plugin = XDiscordUltimate.getInstance();

    plugin.getDatabaseManager()
          .getDiscordId(player.getUniqueId())
          .thenAccept(discordId -> {
              if (discordId != null) {
                  plugin.getLogger().info(
                      player.getName() + " is linked to Discord ID " + discordId);
              }
          });
}
For reactive behavior, register a listener on the event bus:
import com.xreatlabs.xdiscordultimate.events.XDiscordEventBus;
import com.xreatlabs.xdiscordultimate.events.PlayerVerifiedEvent;

public class MyIntegration extends JavaPlugin {

    private final Object listener = new Object() {
        public void onVerify(PlayerVerifiedEvent event) {
            getLogger().info(event.getPlayerName()
                + " just verified as " + event.getDiscordUsername());
        }
    };

    @Override
    public void onEnable() {
        XDiscordEventBus.register(listener);
    }

    @Override
    public void onDisable() {
        XDiscordEventBus.unregister(listener);
    }
}
The event bus is reflection-based: any method on a registered object whose single parameter matches the published event type is invoked. See Architecture for the dispatch contract.

Depending on the Plugin

XDiscordUltimate is not yet published to Maven Central. Depend on it through JitPack against the GitHub repository.
The coordinates below point at the GitHub main branch. Pin to a released tag (v1.2.0) or a specific commit for reproducible builds.
repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    compileOnly 'com.github.xreatlabs:XDiscordUltimate:1.2.0'
}
Maven equivalent:
<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>

<dependency>
  <groupId>com.github.xreatlabs</groupId>
  <artifactId>XDiscordUltimate</artifactId>
  <version>1.2.0</version>
  <scope>provided</scope>
</dependency>
If you need the absolute latest API, build locally and install to your local Maven repository with ./gradlew publishToMavenLocal, then depend on com.xreatlabs.xdiscordultimate:XDiscordUltimate:1.2.0.

Next Steps

Architecture

Understand the core, module system, data layer, and event bus.

Writing Modules

Build a feature on the Module abstraction.

API Overview

Explore the database, event, and manager APIs.