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
Modifier and TypeClassDescriptionstatic class
A 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
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Deprecated.static @Nullable String
Deprecated.static @Nullable Class<? extends org.bukkit.event.Event>[]
Deprecated.Deprecated.static @Nullable Config
Deprecated.static List<TriggerSection>
Deprecated.static Collection<File>
static Kleenean
Deprecated.static Collection<File>
static boolean
isAsync()
Checks if scripts are loaded in separate thread.static boolean
isCurrentEvent(@Nullable Class<? extends org.bukkit.event.Event> event)
Deprecated.static boolean
isCurrentEvent(Class<? extends org.bukkit.event.Event>... events)
Deprecated.static boolean
Checks if scripts are loaded in multiple threads instead of one thread.static int
static int
static int
static int
static ArrayList<TriggerItem>
loadItems(SectionNode node)
Loads a section by converting it toTriggerItem
s.static ScriptLoader.ScriptInfo
loadScripts(Config... configs)
Deprecated.static ScriptLoader.ScriptInfo
loadScripts(List<Config> configs)
Deprecated.loadScripts(List<Config> configs, OpenCloseable openCloseable)
Loads the specified scripts.static ScriptLoader.ScriptInfo
loadScripts(List<Config> configs, List<LogEntry> logOut)
Deprecated.static @Nullable Config
loadStructure(Config config)
Loads structure of given script, currently only for functions.static @Nullable Config
loadStructure(File f)
Loads structure of given script, currently only for functions.static @Nullable Config
loadStructure(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.ScriptInfo
reloadScript(File script)
Deprecated.reloadScript(File script, OpenCloseable openCloseable)
Reloads a single script.static ScriptLoader.ScriptInfo
reloadScripts(File folder)
Deprecated.reloadScripts(File folder, OpenCloseable openCloseable)
Reloads all scripts in the given folder and its subfolders.static String
replaceOptions(String s)
Replaces options in a string.static void
setAsyncLoaderSize(int size)
Sets the amount of async loaders, by updatingasyncLoaderSize
andloaderThreads
.static void
setCurrentEvent(String name, @Nullable Class<? extends org.bukkit.event.Event>... events)
Deprecated.static void
setCurrentLoops(List<SecLoop> currentLoops)
Deprecated.static void
setCurrentScript(@Nullable Config currentScript)
Deprecated.static void
setCurrentSections(List<TriggerSection> currentSections)
Deprecated.static void
setHasDelayBefore(Kleenean hasDelayBefore)
Deprecated.static ScriptLoader.ScriptInfo
unloadScript(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 updatingasyncLoaderSize
andloaderThreads
.
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
- AnOpenCloseable
that 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 toTriggerItem
s. -
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()
-