>>();
-
- /**
- * Creates a new Buscript object, which is used to execute Javascript script files.
- * This object is not thread-safe so a new one should be created for each thread.
- * This constructor will automatically assign the variable name "plugin" to your plugin for script purposes.
- *
- * @param plugin The plugin implementing this library.
- */
- public Buscript(Plugin plugin) {
- this(plugin, "plugin");
- }
-
- /**
- * Creates a new Buscript object, which is used to execute Javascript script files.
- *
- * This object is not thread-safe so a new one should be created for each thread.
- *
- * @param plugin The plugin implementing this library.
- * @param pluginScriptName The name of the variable the plugin will be referenced as in scripts.
- */
- public Buscript(Plugin plugin, String pluginScriptName) {
- super(new File(plugin.getDataFolder(), "scripts"), plugin.getLogger());
- this.plugin = plugin;
-
- // Adds the current server instance as a script variable "server".
- setScriptVariable("server", plugin.getServer());
- setScriptVariable(pluginScriptName, plugin);
-
- // Adds all the default Buscript global methods.
- addScriptMethods(new DefaultFunctions(this));
- // Sets up permissions with vault.
- setupVault();
- plugin.getServer().getPluginManager().registerEvents(new VaultListener(this), plugin);
- // Initializes the delayed script data.
- initData();
- // Starts up a task to check for scripts that need to run at a specific time.
- ScriptTask scriptTask = new ScriptTask(this);
- scriptTask.start();
- // Registers events with bukkit.
- plugin.getServer().getPluginManager().registerEvents(new BuscriptListener(this), plugin);
- }
-
- private void initData() {
- scriptFile = new File(getScriptFolder(), "scripts.bin");
- scriptConfig = YamlConfiguration.loadConfiguration(scriptFile);
- ConfigurationSection scripts = scriptConfig.getConfigurationSection("scripts");
- if (scripts != null) {
- for (String player : scripts.getKeys(false)) {
- List