diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java b/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java index 7819d74a..e77d85db 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java @@ -25,7 +25,6 @@ import com.discordsrv.bukkit.config.main.BukkitConfig; import com.discordsrv.bukkit.config.manager.BukkitConfigManager; import com.discordsrv.bukkit.config.manager.BukkitConnectionConfigManager; import com.discordsrv.bukkit.console.BukkitConsole; -import com.discordsrv.bukkit.integration.VaultIntegration; import com.discordsrv.bukkit.listener.BukkitChatListener; import com.discordsrv.bukkit.listener.BukkitConnectionListener; import com.discordsrv.bukkit.listener.BukkitDeathListener; @@ -188,9 +187,11 @@ public class BukkitDiscordSRV extends ServerDiscordSRV void registerModule(CheckedFunction> function) { + protected final void registerModule(CheckedFunction> function) { moduleManager.registerModule((T) this, function); } + /** + * @param className a class which has a constructor with {@link DiscordSRV} (or implementation specific) as the only parameter. + */ + protected final void registerIntegration( + @Language(value = "JAVA", prefix = "class X{static{Class.forName(\"", suffix = "\");}}") String className + ) { + Object module; + try { + Class clazz = Class.forName(className); + Constructor constructor = clazz.getConstructor(getClass()); + module = constructor.newInstance(this); + } catch (Throwable ignored) { + return; + } + moduleManager.registerModule(this, d -> (AbstractModule) module); + } + @Override public void unregisterModule(AbstractModule module) { moduleManager.unregister(module); @@ -440,6 +460,9 @@ public abstract class AbstractDiscordSRV