-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEssentialsProtect.php
More file actions
66 lines (59 loc) · 1.73 KB
/
EssentialsProtect.php
File metadata and controls
66 lines (59 loc) · 1.73 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/*
__PocketMine Plugin__
name=EssentialsProtect
description=EssentialsProtect
version=2.0
author=KsyMC
class=EssentialsProtect
apiversion=10
*/
class EssentialsProtect implements Plugin{
private $api, $path, $config;
public function __construct(ServerAPI $api, $server = false){
$this->api = $api;
EssentialsAPI::setEssentialsProtect($this);
}
public function init(){
$this->api->event("server.close", array($this, "handler"));
$this->api->addHandler("player.block.break", array($this, "permissionsCheck"), 7);
$this->api->addHandler("player.block.place", array($this, "permissionsCheck"), 7);
$this->api->addHandler("player.block.touch", array($this, "permissionsCheck"), 7);
$this->readConfig();
}
public function __destruct(){
}
public function readConfig(){
$this->path = DATA_PATH."/plugins/Essentials/";
$this->config = $this->api->plugin->readYAML($this->path."config.yml");
}
public function handler(&$data, $event){
switch($event){
case "server.close":
break;
}
}
public function permissionsCheck($data, $event){
if(!$this->api->ban->isOp($data["player"]->username)){
switch($event){
case "player.block.touch":
$items = BlockAPI::fromString($this->config["blacklist"]["usage"], true);
$type = "item";
break;
case "player.block.break":
$items = BlockAPI::fromString($this->config["blacklist"]["break"], true);
$type = "target";
break;
case "player.block.place":
$items = BlockAPI::fromString($this->config["blacklist"]["placement"], true);
$type = "item";
break;
}
foreach($items as $item){
if($data[$type]->getID() === $item->getID() and $data[$type]->getMetadata() === $item->getMetadata()){
return false;
}
}
}
}
}