-
Notifications
You must be signed in to change notification settings - Fork 15
Vol2
Before we go on, I would like to ask a question.
What can a plugin do? What is it for?
This is a tricky question. Everyone knows that plugins add things to PocketMine, but few can classify their main uses. Plugins can basically do anything, but three main components are commands, event handling and scheduled tasks. We are going to discuss about them one by one in this volume.
It is very easy to register a command. You don't even need to write PHP code. Remember our old plugin.yml? Time to open it again. The last time we saved it, it should be like this:
name: MyPlugin
version: 1.0.0
author: YourName
api: 1.12.0
main: yourname\myplugin\MyPluginThe next part is going to be about commands, so add a new line commands:
name: MyPlugin
version: 1.0.0
author: YourName
api: 1.12.0
main: yourname\myplugin\MyPlugin
commands:To add a command, write down its name message, description (as shown in /help) Send back a message and usage message /message <usage here>:
name: MyPlugin
version: 1.0.0
author: YourName
api: 1.12.0
main: yourname\myplugin\MyPlugin
commands:
message:
description: Send back a message
usage: /message <usage here>It is pretty straightforward. You would understand what this thing means even if I didn't teach you.
You can add multiple commands:
name: MyPlugin
version: 1.0.0
author: YourName
api: 1.12.0
main: yourname\myplugin\MyPlugin
commands:
message:
description: Send back a message
usage: /message <usage here>
another-command:
description: This is another command
usage: /another-command <argument> <another argument>Hmm, typing /message every time seems to be too troublesome. What about adding aliases? In this way, typing /msg or /mess would be converted into /message automatically.
name: MyPlugin
version: 1.0.0
author: YourName
api: 1.12.0
main: yourname\myplugin\MyPlugin
commands:
message:
description: Send back a message
usage: /message <usage here>
aliases: [msg, mess]
another-command:
description: This is another command
usage: /another-command <argument> <another argument>Note that it must be called aliases not alias. Use a pair of square braces ([]) to contain the aliases, and separate the aliases by commas (,).
Note: commands must not contain colons (
:) or spaces. This is because colons are used to specify the owner of a command (you don't need to care about this as it rarely happens), and spaces are used to separate the command name and the arguments behind it.
Anyway, we have registered the command, but we haven't yet added the function to handle the command. Now, we are heading to our first PHP function. We are going to write real code, where we are seeing infinite possibilities.
unfinished page
PocketMine Plugin Tutorials wiki
Copyright © 2020 PEMapModder
Everyone is welcome to read, save, update, redistribute and/or modify the contents of this Repositorywsdazxsasd