public ScriptModule
void setLogVerbosity(boolean verbose)
Set whether or not to print out debugging message inside script log.
@NotNull GameScript getScript(@NotNull java.lang.String fileName, @Nullable ScriptCompiler mode)
Get class GameScript
to execute (external) passive script.
fileName
- Script filename including extension.mode
- Compiler to interpret the script. (No effect on legacy script engine)IllegalArgumentException
- is thrown if file does not exist.IllegalArgumentException
- is raised if file is not a passive script.ScriptEngineNotFound
- is thrown if either file extension or script engine is invalid.RuntimeException
- is thrown if plugin fails to load scriptclass GameScript
@NotNull org.bukkit.scheduler.BukkitTask repeat(int counter, @NotNull Timer interval, @NotNull java.lang.Runnable task)
Repeat to execute task.
counter
- The number of times to repeat.interval
- The class Timer
of repeating task.task
- The task to be executed.IllegalArgumentException
- is thrown if interval
is less than 1 tick.@NotNull org.bukkit.scheduler.BukkitTask wait(@NotNull Timer delay, @NotNull java.lang.Runnable task)
Wait before executing the task.
delay
- The amount of class Timer
to wait.task
- The task to be executed.IllegalArgumentException
- is thrown if delay
is less than 1 tick.boolean dispatchCommand(@NotNull org.bukkit.entity.LivingEntity target, @NotNull java.lang.String commandLine)
Dispatch the commandLine
to target and execute it.
target
- LivingEntity who executes the command. e.g. PlayercommandLine
- Command + Arguments, without prefix-slash(/)commandLine
,
target@NotNull java.io.File getFile(@NotNull java.lang.String path)
Returns the File which is silently created if it didn't exist there.
The file is resolved by given path
- a relative path that is joined
to the root folder of the game layout where this module is derived from.
To illustrate this, let's assume that our game 'skywars'
is rooted from 'plugins/CraftGames/skywars/'.
If your path
were 'data/test.txt', then actual outcome would be
'plugins/CraftGames/skywars/data/test.txt'
void readObjectStream(@NotNull java.io.File file, @NotNull java.util.function.Consumer<org.bukkit.util.io.BukkitObjectInputStream> reader)
Read data from your custom getFile
through BukkitObjectInputStream.
You can deserialize file contents into various types of primitive data as well as ConfigurationSerializable objects. i.e. Boolean, String, ItemStack, PotionEffect, etc.
file
- The file to read data from. Use getFile
to get one.reader
- This lends you the InputStream to read stuff.You don't need to flush/close the stream afterwards as plugin does it for you.FileNotFoundException
- is thrown if file
does not exist.getFile
,
BukkitObjectInputStream,
ConfigurationSerializablevoid writeObjectStream(@NotNull java.io.File file, @NotNull java.util.function.Consumer<org.bukkit.util.io.BukkitObjectOutputStream> writer)
Write data to your custom getFile
through BukkitObjectOutputStream.
You can serialize primitive data and ConfigurationSerializable objects to save those into the file.
file
- The file to write data to. Use getFile
to get one.writer
- This lends you the OutputStream to write stuff.You don't need to flush/close the stream afterwards as plugin does it for you.FileNotFoundException
- is thrown if file
does not exist.getFile
,
BukkitObjectOutputStream,
ConfigurationSerializablevoid getYamlConfiguration(@NotNull java.io.File file, @NotNull java.util.function.Consumer<org.bukkit.configuration.file.YamlConfiguration> consumer)
Read or write data of your custom YAML configuration.
file
- The file you want to treat as YAML. Use getFile
to get one.consumer
- This lends you to the YamlConfiguration for you to take control of the file.You don't have to worry about saving the file because the plugin does it for you.