Created
November 25, 2013 14:27
-
-
Save 99leonchang/7641967 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
__PocketMine Plugin__ | |
name=MuteThing | |
description=MuteThing | |
version=1.0 | |
author=99leonchang | |
class=MuteThing | |
apiversion=9,10,11 | |
*/ | |
class MuteThing implements Plugin{ | |
private $api,$server; | |
public function __construct(ServerAPI $api, $server = false) | |
{ | |
$this->api = $api; | |
$this->server = ServerAPI::request(); | |
} | |
public function init(){ | |
$this->api->addHandler("player.chat", array($this, "chat"), 5); | |
$this->api->addHandler("player.join", array($this, "playerjoin"), 5); | |
$this->api->console->register('mute', "Mutes", array($this, 'commandHandler')); | |
$this->api->console->register('unmute', "Unmutes", array($this, 'commandHandler')); | |
$this->muted = array(); | |
//Wiezz's array data storage method | |
} | |
public function chat($data, $event){ | |
$players = $this->api->player->getAll(); | |
$message = $data['message']; | |
foreach($players as $player){ | |
$username = $player->username; | |
if($this->muted[$username]['mute'] === 0){ | |
$this->api->chat->sendTo(false, $message, $username); | |
} | |
} | |
return false; | |
} | |
public function playerjoin($data){ | |
$username = (string)$data->username; | |
$this->players[$username] = array( | |
'mute' => 0 | |
); | |
} | |
public function commandHandler ($cmd, $args, $issuer) { | |
switch($cmd){ | |
case "mute": | |
$this->players[$username]['mute'] = 1; | |
$this->api->chat->sendTo(false, "[MuteThing] You muted the chat", $username); | |
break; | |
case "unmute": | |
$this->players[$username]['mute'] = 0; | |
$this->api->chat->sendTo(false, "[MuteThing] You unmuted the chat", $username); | |
break; | |
} | |
} | |
public function __destruct() {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment