Skip to content

Instantly share code, notes, and snippets.

@shoghicp
Created May 9, 2015 20:16
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shoghicp/516105d470cf7d140757 to your computer and use it in GitHub Desktop.
Save shoghicp/516105d470cf7d140757 to your computer and use it in GitHub Desktop.
Example of new plugin format aimed for easy scripting.
<?php
/**
* This file is an example of a compressed plaintext plugin format for PocketMine
* It's aimed towards easy scripting, but not for normal plugin development.
*
* This kind of plugin won't be able to embed/load resources,
* nor have access to some features like fast permission/command integration.
*
* This first comment is used to define the properties like on plugin.yml,
* having the same name but not being able to define complex types (arrays, multi-line strings)
*
* @name MyPlugin
* @main authorName\MyPlugin\MainClass
* @version 1.0.0
* @api 1.12.0
* @description My super plugin
* @author authorName
*/
//If you want to use multiple namespaces per file you've to use this.
namespace authorName\MyPlugin{
use authorName\MyPlugin\MyTasks\NotifyAlive;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\plugin\PluginBase;
class MainClass extends PluginBase{
public function onEnable(){
$this->getLogger()->info("I've been enabled!");
$this->getServer()->getScheduler()->scheduleRepeatingTask(new NotifyAlive($this), 40);
$this->getServer()->getPluginManager()->registerEvents(new PlayerListener(), $this);
}
}
class PlayerListener implements Listener{
public function onPlayerJoined(PlayerJoinEvent $event){
$event->getPlayer()->sendMessage("I'm enabled!");
}
}
}
namespace authorName\MyPlugin\MyTasks{
use pocketmine\scheduler\PluginTask;
class NotifyAlive extends PluginTask{
public function onRun($currentTick){
$this->getOwner()->getLogger()->info("I'm still enabled!");
}
}
}
Copy link

ghost commented May 9, 2015

Noice

@AFlachat
Copy link

AFlachat commented May 9, 2015

It will be great but can we (after the update) use the 2 methods for plugins ?

@shoghicp
Copy link
Author

shoghicp commented May 9, 2015

@Asparanc check this blog post for more details.

Copy link

ghost commented May 10, 2015

@shoghicp Will you still be able to do plugins in phars like we can now?

@Sharkcraft
Copy link

It will be awesome but still after the update can we have the both methods for the plugins

@XCodexDev
Copy link

Is there any good tutorials on how to develop pocketmine plugins from basics to expert? 💫

@AndreyNazarchuk
Copy link

Yay! 😄 ☺️
Now its more like JavaScript and less like Java

@kevin200
Copy link

Support PMF or something like that?

@PEMapModder
Copy link

Read. Just read this. https://forums.pocketmine.net/threads/new-plugin-scripting-format-draft.8335/

Also it is a forum post not a blog post I guess.

@PEMapModder
Copy link

@shoghicp I am more interested in the loader. Where is it?

@shoghicp
Copy link
Author

shoghicp commented Jun 7, 2015

@PEMapModder It's on 1.5 already

@Palente
Copy link

Palente commented Apr 14, 2016

I have a error
[Server] [03:19:27] [Server thread/INFO]: Enabling DevTools v1.10.0
[Server] [03:19:27] [Server thread/ERROR]: Could not load '/storage/emulated/0/PocketMine/plugins/Advert' in folder '/storage/emulated/0/PocketMine/plugins/': yaml_parse(): scanning error encountered during parsing: could not find expected ':' (line 10, column 1), context while scanning a simple key (line 9, column 1)
[Server] [03:19:27] [Server thread/WARNING]: RuntimeException: "yaml_parse(): scanning error encountered during parsing: could not find expected ':' (line 10, column 1), context while scanning a simple key (line 9, column 1)" (E_WARNING) in "/src/pocketmine/plugin/PluginDescription" at line 2

@StarProgamGamer
Copy link

@Palente that is to do with the plugin you are using. You should be discussing this on the plugin's page whatever advert is not here as it is not the developers of pocketmine's fault. Just go on the github page for that 'Advert' plugin. We cannot help you with someone else's plugin. Sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment