Update PluginTemplate

This commit is contained in:
Collin 2024-09-24 14:57:40 +02:00
parent 836a573995
commit e51fb0b8c5
2 changed files with 16 additions and 5 deletions

View File

@ -1,5 +1,6 @@
{
"name": "Plugin",
"name": "Plugin name for PHAR building and loading",
"version": "1.0.0",
"main": {
"path": "src/Plugin.php",

View File

@ -1,13 +1,23 @@
<?php
//Namespace from plugin.json
namespace Plugin;
//Import PluginBase
use LonaDB\Plugins\PluginBase;
//Class name from plugin.json
class MainClass extends PluginBase
{
//The onEnable funciton is always run once the plugin has been loaded
//You should use this as your constructor
public function onEnable() : void
{
$this->GetLogger()->Load($this->GetName() . " has been enabled");
$this->GetLogger()->Load($this->GetName() . " on version " . $this->GetVersion() . " has been enabled");
}
//You can create your own event handling:
public function onTableCreate(string $executor, string $name) : void {
$this->GetLogger()->Plugin($this->GetName(), "A table has been created: " . $name)
}
public function onTableDelete(string $executor, string $name) : void {
$this->GetLogger()->Plugin($this->GetName(), "A table has been deleted: " . $name)
}
}