This repository was archived by the owner on May 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathMainClass.php
More file actions
49 lines (41 loc) · 1.33 KB
/
MainClass.php
File metadata and controls
49 lines (41 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace ExamplePlugin;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerRespawnEvent;
use pocketmine\Player;
use pocketmine\plugin\PluginBase;
use pocketmine\Server;
use pocketmine\utils\TextFormat;
class MainClass extends PluginBase implements Listener{
public function onLoad(){
$this->getLogger()->info(TextFormat::WHITE . "I've been loaded!");
}
public function onEnable(){
$this->getServer()->getPluginManager()->registerEvents($this, $this);
$this->getServer()->getScheduler()->scheduleRepeatingTask(new BroadcastPluginTask($this), 120);
$this->getLogger()->info(TextFormat::DARK_GREEN . "I've been enabled!");
}
public function onDisable(){
$this->getLogger()->info(TextFormat::DARK_RED . "I've been disabled!");
}
public function onCommand(CommandSender $sender, Command $command, $label, array $args){
switch($command->getName()){
case "example":
$sender->sendMessage("Hello ".$sender->getName()."!");
return true;
default:
return false;
}
}
/**
* @param PlayerRespawnEvent $event
*
* @priority NORMAL
* @ignoreCancelled false
*/
public function onSpawn(PlayerRespawnEvent $event){
Server::getInstance()->broadcastMessage($event->getPlayer()->getDisplayName() . " has just spawned!");
}
}