-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetherQuick.php
More file actions
71 lines (66 loc) · 2.59 KB
/
NetherQuick.php
File metadata and controls
71 lines (66 loc) · 2.59 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
67
68
69
70
<?php
/*
__PocketMine Plugin__
name=NetherQuick
description=Tap on Nether Reactor to go to the second world loaded or to the default world if already in second world
version=2.2
author=Glitchmaster_PE and wies
class=NetherQuick
apiversion=9,10
*/
class NetherQuick implements Plugin{
private $api;
public function __construct(ServerAPI $api, $server = false){
$this->api = $api;
}
public function init(){
if(!file_exists('./worlds/Nether/')){
$file = @file_get_contents("http://forums.pocketmine.net/index.php?attachments/nether-zip.359/");
if($file === false){
console('[ERROR][NetherQuick] Failed downloading the world, check your internet connection or download the map manualy');
return false;
}else{
file_put_contents('./worlds/netherzip.zip', $file);
$zip = new ZipArchive;
$result = $zip->open('./worlds/netherzip.zip');
$zip->extractTo('./worlds/');
$zip->close();
unlink('./worlds/netherzip.zip');
}
}
$this->api->level->loadLevel("Nether");
$this->api->addHandler("player.block.touch", array($this, "touchHandler"));
$this->config = new Config($this->api->plugin->configPath($this) . "config.yml", CONFIG_YAML, array("ItemID" => "247", "RequireCorrectPattern" => true));
$this->netherReactorIds = array(4,4,4,4,4,41,41,41,41,0,0,0,0,4,4,4,4,4,4,4,4,4,0,0,0,0);
$this->netherReactorPattern = array(array(0,-1,0),array(1,-1,0),array(-1,-1,0),array(0,-1,1),array(0,-1,-1),array(1,-1,1),array(1,-1,-1),array(-1,-1,1),array(-1,-1,-1),
array(1,0,0),array(-1,0,0),array(0,0,1),array(0,0,-1),array(1,0,1),array(1,0,-1),array(-1,0,1),array(-1,0,-1),
array(0,1,0),array(1,1,0),array(-1,1,0),array(0,1,1),array(0,1,-1),array(1,1,1),array(1,1,-1),array(-1,1,1),array(-1,1,-1));
}
public function touchHandler($data){
if($data["target"]->getID() === $this->config->get("ItemID")){
if($this->config->get("RequireCorrectPattern") == true){
$x = $data["target"]->x;
$y = $data["target"]->y;
$z = $data["target"]->z;
$player = $data["player"];
$level = $player->level;
$blocks = array();
foreach($this->netherReactorPattern as $val){
$blocks[] = $level->getBlock(new Vector3($x + $val[0], $y + $val[1], $z + $val[2]))->getID();
}
if($this->netherReactorIds !== $blocks){
$player->sendChat("Incorrect pattern!");
return false;
}
}
if($level === $this->api->level->get("Nether")){
$player->teleport($this->api->level->getDefault()->getSpawn());
}else{
$player->teleport($this->api->level->get("Nether")->getSpawn());
}
return false;
}
}
public function __destruct(){}
}
?>