Search in sources :

Example 1 with SkriptTypes

use of fr.romitou.mongosk.skript.SkriptTypes in project MongoSK by Romitou.

the class MongoSK method onEnable.

@Override
public void onEnable() {
    instance = this;
    long start = System.currentTimeMillis();
    // Load the configuration.
    this.loadConfiguration();
    // Make some safe checks to be sure Skript is installed, enabled, and ready to register this addon.
    LoggerHelper.info("Checking the availability of Skript...");
    final PluginManager pluginManager = this.getServer().getPluginManager();
    final Plugin skriptPlugin = pluginManager.getPlugin("Skript");
    if (skriptPlugin == null || !skriptPlugin.isEnabled() || !Skript.isAcceptRegistrations()) {
        LoggerHelper.severe("Skript is not installed or does not accept registrations. Disabling.", "Is Skript plugin present: " + (skriptPlugin != null), "Is Skript enabled: " + (skriptPlugin != null && skriptPlugin.isEnabled()), "Does Skript accept registrations: " + (skriptPlugin != null && skriptPlugin.isEnabled() && Skript.isAcceptRegistrations()));
        pluginManager.disablePlugin(this);
        return;
    }
    // Register the SkriptAddon and try to load classes.
    LoggerHelper.info("Registration of the MongoSK syntaxes...");
    try {
        SkriptAddon skriptAddon = Skript.registerAddon(this);
        skriptAddon.loadClasses("fr.romitou.mongosk.skript", "conditions", "effects", "events", "expressions", (isUsingNewSections() ? "sections" : "legacySections"));
        new SkriptTypes();
    } catch (IOException e) {
        LoggerHelper.severe("MongoSK could not load and register some syntax elements.", "Try to update your version of Skript and MongoSK, and try again only with these two plugins.", "If the problem persists, please open an issue on GitHub.", "More information about this exception: " + e.getMessage());
        return;
    }
    // Register MongoSK codecs.
    if (MongoSKAdapter.ADAPTERS_ENABLED) {
        LoggerHelper.info("Loading MongoSK adapters and codecs...");
        MongoSKAdapter.loadCodecs();
    }
    LoggerHelper.info("MongoSK has been activated and the syntaxes has been loaded successfully in " + (System.currentTimeMillis() - start) + "ms!", "MongoSK version: " + this.getDescription().getVersion(), "Skript version: " + skriptPlugin.getDescription().getVersion(), "Server version: " + this.getServer().getVersion());
    LoggerHelper.info("If you need help, go to GitHub or to our Discord: https://discord.com/invite/6jeQkRcMkk");
    // Register Metrics.
    // Learn more: https://bstats.org/getting-started
    this.registerMetrics();
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) SkriptAddon(ch.njol.skript.SkriptAddon) SkriptTypes(fr.romitou.mongosk.skript.SkriptTypes) IOException(java.io.IOException) Plugin(org.bukkit.plugin.Plugin) JavaPlugin(org.bukkit.plugin.java.JavaPlugin)

Aggregations

SkriptAddon (ch.njol.skript.SkriptAddon)1 SkriptTypes (fr.romitou.mongosk.skript.SkriptTypes)1 IOException (java.io.IOException)1 Plugin (org.bukkit.plugin.Plugin)1 PluginManager (org.bukkit.plugin.PluginManager)1 JavaPlugin (org.bukkit.plugin.java.JavaPlugin)1