Class BukkitScriptManager
java.lang.Object
dev.magicmq.pyspigot.manager.script.ScriptManager
dev.magicmq.pyspigot.bukkit.manager.script.BukkitScriptManager
The Bukkit-specific implementation of the script manager.
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
callScriptExceptionEvent
(Script script, PyException exception) Calls a ScriptExceptionEvent via a platform-specific implementation.protected void
callScriptLoadEvent
(Script script) Calls a ScriptLoadEvent via a platform-specific implementation.protected void
callScriptUnloadEvent
(Script script, boolean error) Calls a ScriptUnloadEvent via a platform-specific implementation.protected void
Cancels the start script task via a platform-specific implementation.static BukkitScriptManager
get()
Get the singleton instance of this BukkitScriptManager.protected void
initScriptPermissions
(Script script) Initialize script permissions via a platform-specific implementation.protected boolean
isPluginDependencyMissing
(String dependency) Checks if a script plugin dependency is missing via a platform-specific implementation.protected ScriptOptions
newProjectOptions
(Path projectConfigPath) Initialize a new ScriptOptions for a multi-file project via a platform-specific implementation, using the appropriate values in the project's project.yml file.protected Script
newScript
(Path path, String name, ScriptOptions options, boolean project) Initialize a new Script via a platform-specific implementation.protected ScriptOptions
Initialize a new ScriptOptions with the default values via a platform-specific implementation.protected ScriptOptions
newScriptOptions
(Path scriptPath) Initialize a new ScriptOptions for a single-file script via a platform-specific implementation, using the appropriate values in the script_options.yml file.protected void
removeScriptPermissions
(Script script) Remove script permissions from the server via a platform-specific implementation.protected void
Schedules and starts the start script task for the script load delay via a platform-specific implementation.protected void
unloadScriptOnMainThread
(Script script, boolean error) Unloads the script on the main thread by scheduling the unload operation with a platform-specific scheduler.protected void
unregisterFromPlatformManagers
(Script script) Unregisters the script from any platform-specific managers.Methods inherited from class dev.magicmq.pyspigot.manager.script.ScriptManager
getAllProjectPaths, getAllScriptNames, getAllScriptPaths, getLoadedScriptNames, getLoadedScripts, getProjectOptions, getProjectPath, getScriptByName, getScriptByPath, getScriptInfo, getScriptOptions, getScriptPath, handleScriptException, initJython, isScriptRunning, loadProject, loadProject, loadProject, loadScript, loadScript, loadScript, loadScripts, shutdown, testThrow, unloadScript, unloadScript, unloadScripts
-
Method Details
-
scheduleStartScriptTask
protected void scheduleStartScriptTask()Description copied from class:ScriptManager
Schedules and starts the start script task for the script load delay via a platform-specific implementation.- Specified by:
scheduleStartScriptTask
in classScriptManager
-
cancelStartScriptTask
protected void cancelStartScriptTask()Description copied from class:ScriptManager
Cancels the start script task via a platform-specific implementation.- Specified by:
cancelStartScriptTask
in classScriptManager
-
isPluginDependencyMissing
Description copied from class:ScriptManager
Checks if a script plugin dependency is missing via a platform-specific implementation.- Specified by:
isPluginDependencyMissing
in classScriptManager
- Parameters:
dependency
- The name of the dependency to check- Returns:
- True if the dependency is missing, false if it is present
-
callScriptExceptionEvent
Description copied from class:ScriptManager
Calls a ScriptExceptionEvent via a platform-specific implementation.- Specified by:
callScriptExceptionEvent
in classScriptManager
- Parameters:
script
- The script that threw the exceptionexception
- The exception that was thrown- Returns:
- True if the exception should be reported, false if otherwise
-
callScriptLoadEvent
Description copied from class:ScriptManager
Calls a ScriptLoadEvent via a platform-specific implementation.- Specified by:
callScriptLoadEvent
in classScriptManager
- Parameters:
script
- The script that was loaded
-
callScriptUnloadEvent
Description copied from class:ScriptManager
Calls a ScriptUnloadEvent via a platform-specific implementation.- Specified by:
callScriptUnloadEvent
in classScriptManager
- Parameters:
script
- The script that was unloadederror
- True if the unload was due to an error, false if it was not
-
newScriptOptions
Description copied from class:ScriptManager
Initialize a new ScriptOptions with the default values via a platform-specific implementation.- Specified by:
newScriptOptions
in classScriptManager
- Returns:
- The new ScriptOptions
-
newScriptOptions
Description copied from class:ScriptManager
Initialize a new ScriptOptions for a single-file script via a platform-specific implementation, using the appropriate values in the script_options.yml file.- Specified by:
newScriptOptions
in classScriptManager
- Parameters:
scriptPath
- The path of the script file whose script options should be initialized- Returns:
- The new ScriptOptions
-
newProjectOptions
Description copied from class:ScriptManager
Initialize a new ScriptOptions for a multi-file project via a platform-specific implementation, using the appropriate values in the project's project.yml file.- Specified by:
newProjectOptions
in classScriptManager
- Parameters:
projectConfigPath
- The path of the project.yml file to parse that belongs to the project- Returns:
- The new ScriptOptions
-
newScript
Description copied from class:ScriptManager
Initialize a new Script via a platform-specific implementation.- Specified by:
newScript
in classScriptManager
- Parameters:
path
- The path that corresponds to the file where the script livesname
- The name of this script. Should contain its extension (.py)options
- TheScriptOptions
for this scriptproject
- True if the script is a multi-file project, false if it is a single-file script- Returns:
- The new script
-
initScriptPermissions
Description copied from class:ScriptManager
Initialize script permissions via a platform-specific implementation.- Specified by:
initScriptPermissions
in classScriptManager
- Parameters:
script
- The script whose permissions should be initialized
-
removeScriptPermissions
Description copied from class:ScriptManager
Remove script permissions from the server via a platform-specific implementation.- Specified by:
removeScriptPermissions
in classScriptManager
- Parameters:
script
- The script whose permissions should be removed
-
unregisterFromPlatformManagers
Description copied from class:ScriptManager
Unregisters the script from any platform-specific managers.- Specified by:
unregisterFromPlatformManagers
in classScriptManager
- Parameters:
script
- The script to unregister
-
unloadScriptOnMainThread
Description copied from class:ScriptManager
Unloads the script on the main thread by scheduling the unload operation with a platform-specific scheduler.Used in conjunction with
ScriptManager.handleScriptException(Script, PyException, String)
to ensure if sys.exit is called from an asynchronous context, the script is unloaded synchronously.- Specified by:
unloadScriptOnMainThread
in classScriptManager
- Parameters:
script
- The script to unloaderror
- If the script unload was due to an error, pass true. Otherwise, pass false
-
get
Get the singleton instance of this BukkitScriptManager.- Returns:
- The instance
-