Package ch.njol.skript
Class ScriptLoader
java.lang.Object
ch.njol.skript.ScriptLoader
The main class for loading, unloading and reloading scripts.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA class for keeping track of a the general content of a script: The amount of files The amount of triggers The amount of commands The amount of functions The names of the declared commands -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidDeprecated.static @Nullable StringDeprecated.static @Nullable Class<? extends org.bukkit.event.Event>[]Deprecated.Deprecated.static @Nullable ConfigDeprecated.static List<TriggerSection>Deprecated.static Collection<File>static KleeneanDeprecated.static Collection<File>static booleanisAsync()Checks if scripts are loaded in separate thread.static booleanisCurrentEvent(@Nullable Class<? extends org.bukkit.event.Event> event)Deprecated.static booleanisCurrentEvent(Class<? extends org.bukkit.event.Event>... events)Deprecated.static booleanChecks if scripts are loaded in multiple threads instead of one thread.static intstatic intstatic intstatic intstatic ArrayList<TriggerItem>loadItems(SectionNode node)Loads a section by converting it toTriggerItems.static ScriptLoader.ScriptInfoloadScripts(Config... configs)Deprecated.static ScriptLoader.ScriptInfoloadScripts(List<Config> configs)Deprecated.loadScripts(List<Config> configs, OpenCloseable openCloseable)Loads the specified scripts.static ScriptLoader.ScriptInfoloadScripts(List<Config> configs, List<LogEntry> logOut)Deprecated.static @Nullable ConfigloadStructure(Config config)Loads structure of given script, currently only for functions.static @Nullable ConfigloadStructure(File f)Loads structure of given script, currently only for functions.static @Nullable ConfigloadStructure(InputStream source, String name)Loads structure of given script, currently only for functions.loadStructures(File directory)Loads structures of all scripts in the given directory, or of the passed script if it's a normal file.loadStructures(File[] files)Loads structures of specified scripts.static ScriptLoader.ScriptInforeloadScript(File script)Deprecated.reloadScript(File script, OpenCloseable openCloseable)Reloads a single script.static ScriptLoader.ScriptInforeloadScripts(File folder)Deprecated.reloadScripts(File folder, OpenCloseable openCloseable)Reloads all scripts in the given folder and its subfolders.static StringreplaceOptions(String s)Replaces options in a string.static voidsetAsyncLoaderSize(int size)Sets the amount of async loaders, by updatingasyncLoaderSizeandloaderThreads.static voidsetCurrentEvent(String name, @Nullable Class<? extends org.bukkit.event.Event>... events)Deprecated.static voidsetCurrentLoops(List<SecLoop> currentLoops)Deprecated.static voidsetCurrentScript(@Nullable Config currentScript)Deprecated.static voidsetCurrentSections(List<TriggerSection> currentSections)Deprecated.static voidsetHasDelayBefore(Kleenean hasDelayBefore)Deprecated.static ScriptLoader.ScriptInfounloadScript(File script)Unloads the specified script.
-
Constructor Details
-
ScriptLoader
public ScriptLoader()
-
-
Method Details
-
isAsync
public static boolean isAsync()Checks if scripts are loaded in separate thread. If true, following behavior should be expected:- Scripts are still unloaded and enabled in server thread
- When reloading a script, old version is unloaded after it has been parsed, immediately before it has been loaded
- When reloading all scripts, scripts that were removed are disabled after everything has been reloaded
- Script infos returned by most methods are inaccurate
- Returns:
- If main thread is not blocked when loading.
-
isParallel
public static boolean isParallel()Checks if scripts are loaded in multiple threads instead of one thread. If true,isAsync()will also be true.- Returns:
- if parallel loading is enabled.
-
setAsyncLoaderSize
Sets the amount of async loaders, by updatingasyncLoaderSizeandloaderThreads.
Ifsize <= 0, async and parallel loading are disabled.
Ifsize == 1, async loading is enabled but parallel loading is disabled.
Ifsize >= 2, async and parallel loading are enabled.- Parameters:
size- the amount of async loaders to use.- Throws:
IllegalStateException
-
loadScripts
public static CompletableFuture<ScriptLoader.ScriptInfo> loadScripts(List<Config> configs, OpenCloseable openCloseable)Loads the specified scripts.- Parameters:
configs- Configs for scripts, loaded byloadStructures(File[])openCloseable- AnOpenCloseablethat will be called before and after each individual script load (seemakeFuture(Supplier, OpenCloseable)).- Returns:
- Info on the loaded scripts.
-
loadStructures
Loads structures of specified scripts.- Parameters:
files- the scripts to load
-
loadStructures
Loads structures of all scripts in the given directory, or of the passed script if it's a normal file.- Parameters:
directory- a directory or a single file
-
loadStructure
Loads structure of given script, currently only for functions. Must be called before actually loading that script.- Parameters:
f- Script file.
-
loadStructure
Loads structure of given script, currently only for functions. Must be called before actually loading that script.- Parameters:
source- Source input stream.name- Name of source "file".
-
loadStructure
Loads structure of given script, currently only for functions. Must be called before actually loading that script.- Parameters:
config- Config object for the script.
-
unloadScript
Unloads the specified script.- Parameters:
script-- Returns:
- Info on the unloaded script
-
reloadScript
public static CompletableFuture<ScriptLoader.ScriptInfo> reloadScript(File script, OpenCloseable openCloseable)Reloads a single script.- Parameters:
script- Script file.- Returns:
- Future of statistics of the newly loaded script.
-
reloadScripts
public static CompletableFuture<ScriptLoader.ScriptInfo> reloadScripts(File folder, OpenCloseable openCloseable)Reloads all scripts in the given folder and its subfolders.- Parameters:
folder- A folder.- Returns:
- Future of statistics of newly loaded scripts.
-
replaceOptions
Replaces options in a string. -
loadItems
Loads a section by converting it toTriggerItems. -
getLoadedFiles
-
getDisabledFiles
-
loadedScripts
public static int loadedScripts() -
loadedCommands
public static int loadedCommands() -
loadedFunctions
public static int loadedFunctions() -
loadedTriggers
public static int loadedTriggers() -
loadScripts
Deprecated.- See Also:
loadScripts(List, OpenCloseable)
-
loadScripts
@Deprecated public static ScriptLoader.ScriptInfo loadScripts(List<Config> configs, List<LogEntry> logOut)Deprecated. -
loadScripts
Deprecated.- See Also:
loadScripts(List, OpenCloseable)
-
reloadScript
Deprecated.- See Also:
reloadScript(File, OpenCloseable)
-
reloadScripts
Deprecated.- See Also:
reloadScripts(File, OpenCloseable)
-
getHasDelayBefore
Deprecated.- See Also:
ParserInstance.getHasDelayBefore()
-
setHasDelayBefore
Deprecated. -
getCurrentScript
Deprecated.- See Also:
ParserInstance.getCurrentScript()
-
setCurrentScript
Deprecated.- See Also:
ParserInstance.setCurrentScript(Config)
-
getCurrentSections
Deprecated.- See Also:
ParserInstance.getCurrentSections()
-
setCurrentSections
Deprecated.- See Also:
ParserInstance.setCurrentSections(List)
-
getCurrentLoops
Deprecated.- See Also:
ParserInstance.getCurrentSections(Class)
-
setCurrentLoops
Deprecated.Never use this method, it has no effect. -
getCurrentEventName
Deprecated.- See Also:
ParserInstance.getCurrentEventName()
-
setCurrentEvent
@SafeVarargs @Deprecated public static void setCurrentEvent(String name, @Nullable Class<? extends org.bukkit.event.Event>... events)Deprecated. -
deleteCurrentEvent
Deprecated.- See Also:
ParserInstance.deleteCurrentEvent()
-
isCurrentEvent
@Deprecated public static boolean isCurrentEvent(@Nullable Class<? extends org.bukkit.event.Event> event)Deprecated.- See Also:
ParserInstance.isCurrentEvent(Class)
-
isCurrentEvent
@SafeVarargs @Deprecated public static boolean isCurrentEvent(Class<? extends org.bukkit.event.Event>... events)Deprecated.- See Also:
ParserInstance.isCurrentEvent(Class[])
-
getCurrentEvents
Deprecated.- See Also:
ParserInstance.getCurrentEvents()
-