-
Notifications
You must be signed in to change notification settings - Fork 1
/
KickForMe.php
43 lines (41 loc) · 1.35 KB
/
KickForMe.php
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
<?php
/*
__PocketMine Plugin__
name=KickForAdmin
version=0.0.1
author=humerusj
apiversion=9
class=KickForAdmin
*/
class KickForAdmin implements Plugin {
private $api;
private $server;
public function __construct(ServerAPI $api, $server = false) {
$this->api = $api;
$this->server = ServerAPI::request();
}
public function init() {
$this->api->addHandler("player.connect", array($this, "KickIt"), 15);
}
public function __destruct() {
}
public function KickIt($player, $event) {
switch($event) {
case 'player.connect':
if (($player->username === "Steve") || ($player->username === "OtherPerson") && (count($this->api->player->getAll()) === $this->api->getProperty('maxPlayers'))) {
$l = array();
foreach($this->server->clients as $p){
if($p !== $player->username){
$l[] = $p;
}
}
if(count($l) === 0){
return;
}
$p = $l[mt_rand(0, count($l) - 2)];
$p->close("Please Reconnect");
}
break;
}
}
}