From 12e38efb38090ec68f39684043245ea9a6266ebb Mon Sep 17 00:00:00 2001 From: Josh North Date: Tue, 27 Jun 2017 17:10:04 -0400 Subject: [PATCH 1/5] test why player falls or dies on email send? --- AdminMail/src/AdminMail/AdminMail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AdminMail/src/AdminMail/AdminMail.php b/AdminMail/src/AdminMail/AdminMail.php index d4a11de..5adca81 100644 --- a/AdminMail/src/AdminMail/AdminMail.php +++ b/AdminMail/src/AdminMail/AdminMail.php @@ -37,6 +37,6 @@ class AdminMail extends PluginBase implements Listener { $player = $event->getPlayer(); $name = $player->getName(); $adminmail = $this->getConfig()->get("adminmail"); - mail($adminmail, "PMMP - $name joined", "Hello, player $name has joined the server."); + #mail($adminmail, "PMMP - $name joined", "Hello, player $name has joined the server."); } } \ No newline at end of file From 060c645275d3a08c626eabcdd1df1f349602c9b7 Mon Sep 17 00:00:00 2001 From: Josh North Date: Wed, 28 Jun 2017 13:32:58 -0400 Subject: [PATCH 2/5] Upload files to 'AdminMail' --- AdminMail/README.md | 16 +++++++++------- AdminMail/plugin.yml | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/AdminMail/README.md b/AdminMail/README.md index 5c12064..972d106 100644 --- a/AdminMail/README.md +++ b/AdminMail/README.md @@ -1,7 +1,9 @@ -# AdminMail - -PMMP plugin to email admins on some server events - -Tested on 3.0.0-ALPHA5. - -Edit config.yml with the address to send to. Your server will need to be set up to send email properly via php. \ No newline at end of file +# AdminMail + +PMMP plugin to email admins on some server events + +Tested on 3.0.0-ALPHA5. + +Edit config.yml with the address to send to. Your server will need to be set up to send email properly via php. + +PNAME will be replaced with player name \ No newline at end of file diff --git a/AdminMail/plugin.yml b/AdminMail/plugin.yml index ca949ac..8aa5ed3 100644 --- a/AdminMail/plugin.yml +++ b/AdminMail/plugin.yml @@ -1,5 +1,5 @@ name: AdminMail -main: AdminMail\AdminMail +main: AdminMail\Main api: 3.0.0-ALPHA5 version: 0.0.1 description: "Administrative email on events" From 66371f9311ebed44ef12a09514463ed3ffe601be Mon Sep 17 00:00:00 2001 From: Josh North Date: Wed, 28 Jun 2017 13:35:28 -0400 Subject: [PATCH 3/5] Update 'AdminMail/src/AdminMail/Main.php' --- AdminMail/src/AdminMail/{AdminMail.php => Main.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename AdminMail/src/AdminMail/{AdminMail.php => Main.php} (100%) diff --git a/AdminMail/src/AdminMail/AdminMail.php b/AdminMail/src/AdminMail/Main.php similarity index 100% rename from AdminMail/src/AdminMail/AdminMail.php rename to AdminMail/src/AdminMail/Main.php From 83d0cb0663176c01a816df9c35606e98c815821e Mon Sep 17 00:00:00 2001 From: Josh North Date: Wed, 28 Jun 2017 13:36:05 -0400 Subject: [PATCH 4/5] Upload files to 'AdminMail/src/AdminMail' --- AdminMail/src/AdminMail/EmailTask.php | 45 +++++++++++++++++++++++++++ AdminMail/src/AdminMail/Main.php | 17 ++++++++-- 2 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 AdminMail/src/AdminMail/EmailTask.php diff --git a/AdminMail/src/AdminMail/EmailTask.php b/AdminMail/src/AdminMail/EmailTask.php new file mode 100644 index 0000000..489698c --- /dev/null +++ b/AdminMail/src/AdminMail/EmailTask.php @@ -0,0 +1,45 @@ +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(); + + $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); +} +} \ No newline at end of file diff --git a/AdminMail/src/AdminMail/Main.php b/AdminMail/src/AdminMail/Main.php index 5adca81..d0b8a4b 100644 --- a/AdminMail/src/AdminMail/Main.php +++ b/AdminMail/src/AdminMail/Main.php @@ -11,7 +11,8 @@ use pocketmine\command\CommandSender; use pocketmine\utils\Config; -class AdminMail extends PluginBase implements Listener { +class Main extends PluginBase implements Listener { + public function onLoad() { # Called when the plugin is being loaded by the server $this->getLogger()->info("Loading plugin..."); # Logs to the console @@ -32,11 +33,21 @@ class AdminMail extends PluginBase implements Listener { $sender->sendMessage("This is an example command"); # Sends to the sender } } - + + + + public function onJoin(PlayerJoinEvent $event) { # Called when a player joins $player = $event->getPlayer(); $name = $player->getName(); $adminmail = $this->getConfig()->get("adminmail"); - #mail($adminmail, "PMMP - $name joined", "Hello, player $name has joined the server."); + $adminsubject = $this->getConfig()->get("adminsubject"); + $adminmessage = $this->getConfig()->get("adminmessage"); + + + //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) } } \ No newline at end of file From 8a908debaaed020df41fd42b16b240e5503a3b15 Mon Sep 17 00:00:00 2001 From: Josh North Date: Wed, 28 Jun 2017 13:36:45 -0400 Subject: [PATCH 5/5] Upload files to 'AdminMail/resources' --- AdminMail/resources/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AdminMail/resources/config.yml b/AdminMail/resources/config.yml index 05acf54..0858fa2 100644 --- a/AdminMail/resources/config.yml +++ b/AdminMail/resources/config.yml @@ -1,2 +1,4 @@ enabled: true adminmail: youradmin@email.com +adminsubject: PMMP - Player PNAME has joined +adminmessage: Hello. This is to let you know player PNAME has joined the server. \ No newline at end of file