@Override
    protected void enable() {
        // load config
        getLogger().info("Loading configuration...");
        YamlConfiguration config = loadConfig("config.yml");

        // search for packages which match the default import patterns
        getLogger().info("Scanning the classpath to resolve default package imports...");

        ClassGraph classGraph = new ClassGraph()
                .whitelistPackages(DEFAULT_IMPORT_INCLUDES)
                .blacklistPackages(DEFAULT_IMPORT_EXCLUDES)
                .addClassLoader(getServer().getClass().getClassLoader());

        // add the classloaders for helper implementation plugins
        LoaderUtils.getHelperImplementationPlugins().forEach(pl -> classGraph.addClassLoader(pl.getClass().getClassLoader()));

        Set<String> defaultPackages = classGraph.scan()
                .getAllClasses()
                .stream()
                .map(ClassInfo::getPackageName)
                .collect(Collectors.toSet());

        // setup the script controller
        getLogger().info("Initialising script controller...");
        this.controller = ScriptController.builder()
                .logger(SystemLogger.usingJavaLogger(getLogger()))
                .defaultEnvironmentSettings(EnvironmentSettings.builder()
                        .loadExecutor(new HelperLoadingExecutor())
                        .runExecutor(Schedulers.sync())
                        .pollRate(Ticks.to(config.getLong("poll-interval", 20L), TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS)
                        .initScript(config.getString("init-script", "init.js"))
                        .withBindings(new GeneralScriptBindings())
                        .withBindings(new HelperScriptBindings(this))
                        .withDefaultPackageImports(defaultPackages)
                        .build()
                )
                .build();

        // get script directory
        Path scriptDirectory = Paths.get(config.getString("script-directory"));
        if (!Files.isDirectory(scriptDirectory)) {
            try {
                Files.createDirectories(scriptDirectory);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        // init a new environment for our scripts
        getLogger().info("Creating new script environment at " + scriptDirectory.toString() + " (" + scriptDirectory.toAbsolutePath().toString() + ")");
        this.environment = this.controller.setupNewEnvironment(scriptDirectory);

        getLogger().info("Done!");
    }
Uses {@link ScriptController} and helper to provide a javascript plugin environment for Bukkit.
helper-js/src/main/java/me/lucko/helper/js/HelperJsPlugin.java