-
Notifications
You must be signed in to change notification settings - Fork 0
Making a script
You need to have the plugin installed as well as the language addons you are going to use installed. Look here to learn how to do that.
You also should know how to use the language you desire to use. There are plenty of tutorials online, although this plugin uses them (especially JavaScript) slightly differently mainly due to the quirks of Java.
The load method doesn't exist for scripts. The script itself is run during load. Most things won't be accessible during this period, for example registering of commands or listeners.
When the server is enabled, it usually tells all the plugins that, include this one. When this one gets enabled, it tells all the scripts to enable as well. It calls the onEnable
method and on_enable
for Python (both work for Python). Here you can register commands, listeners, and all that fancy jazz.
This generally happens when the server is being shut down, thus disabling all the plugins. This plugin calls the onDisable
method and on_disable
for Python. If you're connected to an SQL database, here is where you should probably disconnect.
This happens when either the server is being reloaded (velocity), or the plugin is being reloaded (via command; PlugMan doesn't count). This is where you should reload the information used by your script.
To register a command with my plugin on Spigot, you must create an object that implements either org.bukkit.command.CommandExecutor
or org.bukkit.command.TabExecutor
for completions and implement their methods (public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
and/or public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args)
.
This is where I should probably recode my stuff, but eh idc enough to. It works and it's easy. You must now create a new uwu.smsgamer.serverscripter.spigot.utils.ScriptCommand
with the arguments String name, String description, String usageMessage, List<String> aliases, CommandExecutor executor, TabCompleter tabCompleter
(last 2 are optional but I recommend still adding the executor now).
You can then do whatever you want with that object (you can set its command executor, tab completer, or do stuff with the org.bukkit.command.Command
object as this one extends that).
Once you're done doing all the things you need to do with that, you can now call ScriptCommand.registerCommand(Command command)
with the object you created as the argument.
To see how to do this for your language, please take a look at the examples
Similar process.
Note: WIP
No API with the Velocity base as I didn't think it was necessary. You can use velocity's built-in API to do this. Take a look at this python script
Note: WIP
Similar process to registering commands.
Note: WIP
Similar process to registering commands.
Note: WIP
Similar process to registering commands.
Note: WIP