Created
November 8, 2015 15:58
-
-
Save PEMapModder/ed9edd96510ef7a216b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
So far I made something like this: (I just started half an hour ago, so this is my efficiency) | |
<?php | |
/* | |
__PocketMine Plugin__ | |
author=PEMapModder | |
name=SpleefPlugin | |
version=alpha.0.0 | |
apiversion=11 | |
class=SpleefPluginLoadable | |
*/ | |
class SpleefPluginLoadable implements Plugin{ | |
protected $config,$cfgMem; | |
private $c,$p,$t,$waitTapBlock_createArena; | |
public function __construct(ServerAPI $a,$s=false){ | |
$this->c=$a->console; | |
$this->p=$a->player; | |
$this->t=$a->tile; | |
$this->s=$s; | |
} | |
public function init(){ | |
@mkdir(FILE_PATH."/spleef"); | |
$this->config=new Config(FILE_PATH."/spleef/cfg.yml",CONFIG_YAML,array("arenas"=>array())); | |
$this->cfgMem=$this->config->getAll(); | |
$this->s->addHandler("player.block.touch", array($this, "event")); | |
#$this->s->addHandler("player.join", array($this, "playerJoinRedirect")); // BTW I just found out that the reason why I always crash when using this event is because $player->entity is not set. What is the event for the player ACTUALLY joining the game? player.join and player.connect basically are the same | |
$this->c->register("addarena"," Adds a spleef arena",array($this,"cmds")); | |
$this->s->addHandler("player.quit",array($this, "event")); | |
} | |
public function __destruct(){$this->save();} | |
public function save(){//maybe add scheduled saves in case of crashes? | |
$this->config->setAll($cfgMem); | |
} | |
public function event($data,$event){ | |
if($event=="player.block.touch"){ | |
$target=$data["target"]; | |
$player=$data["player"]; | |
////////////////////////////////////Warp to arena//////////////////////////////////// | |
if($target instanceof SignPostBlock){//WallSign.php:line 26: class WallSign extends SignPostBlock | |
$data=$this->t->get($target)->data; | |
if($data["Text1"]==="Enter arena"){ | |
$name=$data["Text2"]; | |
if(!(isset($this->cfgmem["arenas"][$name]))){ | |
$x=$target->x; | |
$y=$target->y; | |
$z=$target->z; | |
$level=$target->level; | |
$msg="The arena $name mentioned on the sign at ($x,$y,$z) at world $level is undefined"; | |
$player->sendChat($msg."."); | |
console($msg." and is tapped by $player."); | |
} | |
$arena=$this->cfgmem["arenas"][$name]; | |
$x=$arena[$arena["status"]]["x"]; | |
$y=$arena[$arena["status"]]["y"]; | |
$z=$arena[$arena["status"]]["z"]; | |
$this->c->run("tp $player w:arenas"); | |
$this->c->run("tp $player $x $y $z"); | |
} | |
} | |
////////////////////////////////////Add arena//////////////////////////////////// | |
if(isset($this->waitTapBlock_createArena["$player"])){//"$player" is an alternative for $player->username or $player->__toString() | |
; | |
} | |
} | |
if($event=="player.quit"){ | |
if(isset($this->waitTapBlock_createArena["$data"])){ | |
unset($this->waitTapBlock_createArena["$data"]); | |
} | |
} | |
} | |
////////////////////////////////////Register add arena wait//////////////////////////////////// | |
public function cmds($cmd,$arg,$player){ | |
if($cmd=="addarena"){ | |
if(isset($this->waitTapBlock_createArena["$player"]))return "You already registered for adding arena.\nUse /cancel to unset."; | |
$name=$arg[0]; | |
$maxPpl=$arg[1]; | |
$this->waitTapBlock_createArena["$player"]=array($arg[0],$arg[1]); | |
} | |
} | |
////////////////////////////////////World Edit//////////////////////////////////// | |
public function generateFullCircle(Vector3 $centre,Level $level,$r,$blockid,$blockDmg=0,$arcA=0,$arcB=360){//angles in degrees, vectors in blocks | |
$x=$centre->x; | |
$y=$centre->y; | |
$z=$centre->z;//abbr for the centre coords | |
$block=BlockAPI::get($blockid);//get the Block object for $blockid | |
$arcAccu=1; | |
$rAccu=1; | |
#$result=array(); | |
for($d=$arcA;$d<$arcB;$d=$d+$arcAccu){//changes the direction in the arc bit by bit; what is the optimal ArcAccuracy $arcAccu? | |
$t=$d/180*M_PI; | |
for($rL=0;$rL<=$r;$r+$rAccu){//changes the length of the angle bit by bit to generate a solid circle; what is the optimal RadiusLengthAccuracy $rAccu? | |
$tX=sin($t)*$rL+$x; | |
$tZ=cos($t)*$rL+$z; | |
#result[]= | |
$level->setBlockRaw(new Vector3($tX,$y,$tZ),$block); | |
} | |
} | |
#return $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment