Skip to content

Instantly share code, notes, and snippets.

@jasonw4331
Forked from shoghicp/MyPlugin.php
Last active April 18, 2017 23:50
Show Gist options
  • Save jasonw4331/d7d754a490fe22c793c2b11e9fde23f3 to your computer and use it in GitHub Desktop.
Save jasonw4331/d7d754a490fe22c793c2b11e9fde23f3 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!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment