/
ExploitEngine.php
75 lines (64 loc) · 2.29 KB
/
ExploitEngine.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
<?php
/*
* 88""Yb 88""Yb 88 8b d8 88 88 .dP"Y8
* 88__dP 88__dP 88 88b d88 88 88 `Ybo."
* 88""" 88"Yb 88 88YbdP88 Y8 8P o.`Y8b
* 88 88 Yb 88 88 YY 88 `YbodP' 8bodP'
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author Latvian PHP programmer Kristaps Drivnieks (Primus)
* @link https://Github.com/PrimusLV/FactionsPE
*/
namespace factions\engine;
use factions\utils\Settings;
use pocketmine\block\Block;
use pocketmine\block\Liquid;
use pocketmine\entity\PrimedTNT;
use pocketmine\event\entity\EntityExplodeEvent;
use evalcore\engine\Engine;
class ExploitEngine extends Engine
{
/**
* Allows obsidian to explode
*
* @param EntityExplodeEvent $event
* @priority MONITOR
* @ignoreCancelled false
*/
public function explodeInWater(EntityExplodeEvent $event)
{
$entity = $event->getEntity();
if (!$entity instanceof PrimedTNT) return;
$center = $entity->getLevel()->getBlock($entity);
if (!$center instanceof Liquid) return;
if (!Settings::get('handleExploitTNTWaterlog', true)) return;
$targets = [];
for($i = 0; $i <= 6; $i++) {
$targets[] = $center->getSide($i);
}
foreach ($targets as $target) {
$id = $target->getId();
if ($id != 0 && ($id < 7 || $id > 11) && $id != 49 && $id != 90 && $id != 116 && $id != 119 && $id != 120 && $id != 130) {
// Break
$target->getLevel()->setBlock($target, Block::get(0));
}
}
}
public function explosion(EntityExplodeEvent $event)
{
$entity = $event->getEntity();
if (!$entity instanceof PrimedTNT) return;
$center = $entity->getLevel()->getBlock($entity);
$targets = [];
for($i = 0; $i <= 6; $i++) {
$targets[] = $center->getSide($i);
}
foreach ($targets as $target) {
if ($target->getId() === 49) $target->getLevel()->setBlock($target, Block::get(0));
}
}
}