-
Notifications
You must be signed in to change notification settings - Fork 8
/
superAdmins.php
81 lines (72 loc) · 2.03 KB
/
superAdmins.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/*
__PocketMine Plugin__
name=superAdmins
description=superAdmins
version=0.5
author=WreWolf
class=superAdmins
apiversion=11
*/
class superAdmins implements Plugin
{
private $api, $path, $server, $config;
public function __construct(ServerAPI $api, $server = false)
{
$this->api = $api;
$this->server = ServerAPI::request();
}
public function init()
{
$this->path = $this->api->plugin->createConfig($this, array());
$this->config = $this->api->plugin->readYAML($this->path . "config.yml");
$this->api->addHandler("admin.isSa", array($this, "eventHandler"));
$this->api->console->register("addsa", "", array($this, "addsaHandler"));
$this->api->console->register("rmsa", "", array($this, "rmsaHandler"));
$this->api->console->register("lssa", "superAdmins command", array($this, "lssaHandler"));
}
public function addsaHandler($cmd, $args, $issuer, $alias)
{
if ($issuer != "console")
{
return "Only from Console";
}
$output = "Alredy in";
$user = $args[0];
if (!in_array($user, $this->config)) {
$this->config[] = $user;
$this->api->plugin->writeYAML($this->path . "config.yml", $this->config);
$output = "Added";
}
return $output;
}
public function rmsaHandler($cmd, $args, $issuer, $alias)
{
if ($issuer != "console")
{
return "Only from Console";
}
$output = "Not in sa";
$user = $args[0];
if (($key = array_search($user, $this->config)) !== false) {
unset($this->config[$key]);
$output = "Removed";
}
return $output;
}
public function lssaHandler($cmd, $args, $issuer, $alias)
{
if ($issuer != "console")
{
return="Only from Console";
}
return "Sa is: " . implode(',', $this->config);
}
public function eventHandler($data, $event)
{
return in_array($data['user'], $this->config);
}
public function __destruct()
{
}
}