-
Notifications
You must be signed in to change notification settings - Fork 0
/
circle.php
99 lines (94 loc) · 3.15 KB
/
circle.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
namespace Managon;
use pocketmine\Player;
use pocketmine\Server;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerInteractEvent;
use pocketmine\math\Vector3;
use pocketmine\level\Level;
use pocketmine\level\particle\RedStoneParticle;
use pocketmine\plugin\PluginBase;
use pocketmine\scheduler\PluginTask;
class circle extends PluginBase implements Listener{
public $tapper;
public function onEnable(){
Server::getInstance()->getPluginManager()->registerEvents($this,$this);
}
public function onCommand(CommandSender $sender, Command $c,$label,array $args){
if(!$sender instanceof Player){
$sender->sendMessage("Use the command in a game..");
return;
}else{
if(count($args) < 1 || count($args) > 5){//feuture
$sender->sendMessage("§bIf you make circle, Send /cir redius\n§aIf you make tornado, Send /trn redius height");
return;
}else{
switch($c->getName()){
case "cir":
$hypo = (Int) $args[0];
if($hypo < 10){
$sender->sendMessage("The radius must be bigger than 10");
return;
}
$this->tapper[$sender->getName()]["cir"] = $hypo;
$sender->sendMessage("Tap the ground! I will make circle.");
break;
case "trn":
$hypo = (Int) $args[0];
if($hypo < 10){
$sender->sendMessage("The radius must be bigger than 10");
return;
}
$height = (Int) $args[1];
if($height > 30){
$sender->sendMessage("The height must be lower than 30");
return;
}
$this->tapper[$sender->getName()]["trn"][$hypo] = $height;
$sender->sendMessage("Tap the ground! I will make tornado.");
break;
}
}
}
}
public function onTap(PlayerInteractEvent $event){
if(isset($this->tapper[$event->getPlayer()->getName()])){
$type = $this->tapper[$event->getPlayer()->getName()];
$block = $event->getBlock();
$x = $block->x;
$y = $block->y;
$z = $block->z;
$level = $event->getPlayer()->getLevel();
foreach($type as $t => $hypo){
switch($t){
case "cir":
$hypo = $type["cir"];
for($r = 0; $r <= 1080; $r++){
$a = cos(deg2rad($r/3))* $hypo;
$b = sin(deg2rad($r/3))* $hypo;
$pos = new Vector3($x + $a, $y, $z + $b);
$particle = new RedStoneParticle($pos, 20);
$level->addParticle($particle, $level->getPlayers());
}
unset($this->tapper[$event->getPlayer()->getName()]);
break;
case "trn":
foreach($hypo as $h => $height){
$hh = $height*4;
for($s = 1; $s <= 3600; $s++){
$a = cos(deg2rad($s/2))* $h;//the Base
$b = sin(deg2rad($s/2))* $h;//the highest
$pos = new Vector3($x + $a, $y+($s/$hh), $z + $b);
$particle = new RedStoneParticle($pos, 20);
$level->addParticle($particle, $level->getPlayers());
}
unset($this->tapper[$event->getPlayer()->getName()]);
break;
}
}
}
}
}
}