Skip to content

Instantly share code, notes, and snippets.

@shoghicp

shoghicp/Explode.php

Last active Dec 22, 2015
Embed
What would you like to do?
Explode Plugin. Usage: /explode [power]
<?php
/*
__PocketMine Plugin__
name=Explode
description=Create an explosion
version=0.2
author=shoghicp
class=ExplodePlugin
apiversion=10
*/
class ExplodePlugin implements Plugin{
private $api;
public function __construct(ServerAPI $api, $server = false){
$this->api = $api;
}
public function init(){
$this->api->console->register("explode", "<power> [player]", array($this, "commandHandler"));
}
public function commandHandler($cmd, $params, $issuer, $alias){
$output = "";
switch($cmd){
case "explode":
if(!isset($params[1]) and !($issuer instanceof Player)){
$output .= "Please run this command in-game.\n";
return $output;
}
$power = 4;
if(isset($params[0])){
$power = (float) $params[0];
}
if(isset($params[1])){
$issuer = $this->api->player->get($params[1]);
if(!($issuer instanceof Player)){
$output .= "The player doesn't exists.\n";
return $output;
}
}
$e = new Explosion(new Position($issuer->entity->x, $issuer->entity->y + 0.5, $issuer->entity->z, $issuer->level), $power);
$e->explode();
$output .= "Created an explosion with power $power\n";
break;
}
return $output;
}
public function __destruct(){
}
}
@ZacHack

This comment has been minimized.

Copy link

@ZacHack ZacHack commented Sep 8, 2013

Nice man!!!

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Nov 28, 2013

@ZacHack I made it loonnng time ago but it was using packets and no block destorying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment