Skip to content

Instantly share code, notes, and snippets.

@shoghicp
Created May 9, 2015 20:16
Show Gist options
  • 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!");
}
}
}
@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