Cleanup unnecessary functions
This commit is contained in:
parent
2f00c814a3
commit
afca9c03cd
@ -14,32 +14,23 @@ use AdminMail\Main;
|
|||||||
|
|
||||||
class EmailTask extends PluginTask {
|
class EmailTask extends PluginTask {
|
||||||
|
|
||||||
|
public function __construct(Main $main, string $adminmail, string $playername, string $adminsubject, string $adminmessage) {
|
||||||
|
parent::__construct($main);
|
||||||
|
$this->playername = $playername;
|
||||||
|
$this->adminmail = $adminmail;
|
||||||
|
$this->adminsubject = $adminsubject;
|
||||||
|
$this->adminmessage = $adminmessage;
|
||||||
|
}
|
||||||
|
|
||||||
public function __construct(Main $main, string $adminmail, string $playername, string $adminsubject, string $adminmessage) {
|
public function onRun($tick) {
|
||||||
parent::__construct($main);
|
$player = $this->getOwner()->getServer()->getPlayer($this->playername);
|
||||||
$this->playername = $playername;
|
|
||||||
$this->adminmail = $adminmail;
|
|
||||||
$this->adminsubject = $adminsubject;
|
|
||||||
$this->adminmessage = $adminmessage;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onRun($tick) { //
|
|
||||||
|
|
||||||
$player = $this->getOwner()->getServer()->getPlayer($this->playername);
|
|
||||||
$name = $player->getName();
|
$name = $player->getName();
|
||||||
|
$admin = $this->adminmail;
|
||||||
|
$admin1 = $this->adminsubject;
|
||||||
|
$admin1 = str_replace("PNAME", $name, $admin1);
|
||||||
|
$admin2 = $this->adminmessage;
|
||||||
|
$admin2 = str_replace("PNAME", $name, $admin2);
|
||||||
|
mail($admin, $admin1, $admin2);
|
||||||
|
}
|
||||||
|
|
||||||
$admin = $this->adminmail;
|
|
||||||
$admin1 = $this->adminsubject;
|
|
||||||
$admin1 = str_replace("PNAME", $name, $admin1);
|
|
||||||
|
|
||||||
$admin2 = $this->adminmessage;
|
|
||||||
$admin2 = str_replace("PNAME", $name, $admin2);
|
|
||||||
|
|
||||||
|
|
||||||
// $adminmail = $this->getConfig()->get("adminmail");
|
|
||||||
|
|
||||||
|
|
||||||
mail($admin, $admin1, $admin2);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -10,44 +10,22 @@ use pocketmine\command\Command;
|
|||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
use pocketmine\utils\Config;
|
use pocketmine\utils\Config;
|
||||||
|
|
||||||
|
|
||||||
class Main extends PluginBase implements Listener {
|
class Main extends PluginBase implements Listener {
|
||||||
|
|
||||||
|
public function onEnable() {
|
||||||
public function onLoad() { # Called when the plugin is being loaded by the server
|
$this->getServer()->getPluginManager()->registerEvents($this, $this);
|
||||||
$this->getLogger()->info("Loading plugin..."); # Logs to the console
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onEnable() { # Called when the plugin is enabled successfully without any errors
|
|
||||||
$this->getServer()->getPluginManager()->registerEvents($this, $this); # Registers the events
|
|
||||||
@mkdir($this->getDataFolder());
|
@mkdir($this->getDataFolder());
|
||||||
$this->saveDefaultConfig();
|
$this->saveDefaultConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onDisable() { # Called when the plugin is being disabled
|
public function onJoin(PlayerJoinEvent $event) {
|
||||||
$this->getLogger()->info("Plugin disabled!"); # Logs to the console
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { # This is called when a player rans the command from this plugin
|
|
||||||
if($cmd->getName() == "example") { # Remove this if your plugin has only one command
|
|
||||||
$sender->sendMessage("This is an example command"); # Sends to the sender
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function onJoin(PlayerJoinEvent $event) { # Called when a player joins
|
|
||||||
$player = $event->getPlayer();
|
$player = $event->getPlayer();
|
||||||
$name = $player->getName();
|
$name = $player->getName();
|
||||||
$adminmail = $this->getConfig()->get("adminmail");
|
$adminmail = $this->getConfig()->get("adminmail");
|
||||||
$adminsubject = $this->getConfig()->get("adminsubject");
|
$adminsubject = $this->getConfig()->get("adminsubject");
|
||||||
$adminmessage = $this->getConfig()->get("adminmessage");
|
$adminmessage = $this->getConfig()->get("adminmessage");
|
||||||
|
$task = new EmailTask($this, $adminmail, $name, $adminsubject, $adminmessage);
|
||||||
|
$this->getServer()->getScheduler()->scheduleDelayedTask($task, 5*20);
|
||||||
//mail($adminmail, "PMMP - $name joined", "Hello, player $name has joined the server.");
|
|
||||||
//sleep(10);
|
|
||||||
$task = new EmailTask($this, $adminmail, $name, $adminsubject, $adminmessage); // Create the new class Task by calling
|
|
||||||
$this->getServer()->getScheduler()->scheduleDelayedTask($task, 5*20); // Counted in ticks (1 second = 20 ticks)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user