Fully loadable plugins

This commit is contained in:
Shoghi Cervantes 2014-03-27 04:59:18 +01:00
parent 120efad01f
commit 530d705d39
402 changed files with 927 additions and 577 deletions

View File

@ -41,6 +41,9 @@ use PocketMine\Network\Query\QueryHandler;
use PocketMine\Network\Query\QueryPacket;
use PocketMine\Network\ThreadedHandler;
use PocketMine\Network\UPnP\UPnP;
use PocketMine\Permission\DefaultPermissions;
use PocketMine\Plugin\Plugin;
use PocketMine\Plugin\PluginLoadOrder;
use PocketMine\Plugin\PluginManager;
use PocketMine\Recipes\Crafting;
use PocketMine\Scheduler\ServerScheduler;
@ -390,7 +393,7 @@ class Server{
$this->pluginPath = $pluginPath;
@mkdir($this->dataPath . "worlds/", 0777);
@mkdir($this->dataPath . "players/", 0777);
@mkdir($this->pluginPath . "plugins/", 0777);
@mkdir($this->pluginPath, 0777);
$this->tickScheduler = new TickScheduler(20);
$this->scheduler = new ServerScheduler();
@ -451,10 +454,6 @@ class Server{
if(ADVANCED_CACHE == true){
console("[INFO] Advanced cache enabled");
}
if($this->getConfigBoolean("upnp-forwarding", false) == true){
console("[INFO] [UPnP] Trying to port forward...");
UPnP::PortForward($this->getPort());
}
if(defined("PocketMine\\DEBUG") and \PocketMine\DEBUG >= 0 and function_exists("cli_set_process_title")){
@cli_set_process_title("PocketMine-MP " . $this->getPocketMineVersion());
@ -468,20 +467,20 @@ class Server{
console("[INFO] This server is running PocketMine-MP version " . ($version->isDev() ? TextFormat::YELLOW : "") . $this->getPocketMineVersion() . TextFormat::RESET . " \"" . $this->getCodename() . "\" (API " . $this->getApiVersion() . ")", true, true, 0);
console("[INFO] PocketMine-MP is distributed under the LGPL License", true, true, 0);
$this->consoleSender = new ConsoleCommandSender();
$this->commandMap = new SimpleCommandMap($this);
$this->pluginManager = new PluginManager($this, $this->commandMap);
$this->pluginManager->registerInterface("PocketMine\\Plugin\\FolderPluginLoader");
$this->pluginManager->loadPlugins($this->pluginPath);
//TODO: update checking (async)
$this->commandMap = new SimpleCommandMap($this);
$this->enablePlugins(PluginLoadOrder::STARTUP);
Block::init();
Item::init();
Crafting::init();
Level::init();
$this->pluginManager = new PluginManager();
console("[INFO] Loaded " . count($this->pluginManager->loadPlugins($this->pluginPath . "plugins/")) . " plugin(s).");
$this->consoleSender = new ConsoleCommandSender();
$this->properties->save();
//TODO
/*if($this->getProperty("send-usage", true) !== false){
@ -495,12 +494,44 @@ class Server{
$this->rcon = new RCON($this->getProperty("rcon.password", ""), $this->getProperty("rcon.port", $this->getProperty("server-port")), ($ip = $this->getProperty("server-ip")) != "" ? $ip : "0.0.0.0", $this->getProperty("rcon.threads", 1), $this->getProperty("rcon.clients-per-thread", 50));
}*/
if($this->getConfigBoolean("enable-query", true) === true){
$this->queryHandler = new QueryHandler();
}
//$this->schedule(2, array($this, "checkTickUpdates"), array(), true);
$this->enablePlugins(PluginLoadOrder::POSTWORLD);
}
/**
* @param int $type
*/
public function enablePlugins($type){
foreach($this->pluginManager->getPlugins() as $plugin){
if(!$plugin->isEnabled() and $plugin->getDescription()->getOrder() === $type){
$this->loadPlugin($plugin);
}
}
if($type === PluginLoadOrder::POSTWORLD){
$this->commandMap->registerServerAliases();
$this->loadCustomPermissions();
}
}
private function loadCustomPermissions(){
DefaultPermissions::registerCorePermissions();
}
/**
* @param Plugin $plugin
*/
public function loadPlugin(Plugin $plugin){
$this->pluginManager->enablePlugin($plugin);
foreach($plugin->getDescription()->getPermisions() as $perm){
$this->pluginManager->addPermission($perm);
}
}
public function disablePlugins(){
$this->pluginManager->disablePlugins();
}
public function checkConsole(){
@ -535,6 +566,15 @@ class Server{
* Starts the PocketMine-MP server and starts processing ticks and packets
*/
public function start(){
if($this->getConfigBoolean("enable-query", true) === true){
$this->queryHandler = new QueryHandler();
}
if($this->getConfigBoolean("upnp-forwarding", false) == true){
console("[INFO] [UPnP] Trying to port forward...");
UPnP::PortForward($this->getPort());
}
$this->tickCounter = 0;
register_tick_function(array($this, "tick"));
/*
@ -682,7 +722,6 @@ class Server{
}
public function titleTick(){
$time = microtime(true);
if(defined("PocketMine\\DEBUG") and \PocketMine\DEBUG >= 0 and \PocketMine\ANSI === true){
echo "\x1b]0;PocketMine-MP " . $this->getPocketMineVersion() . " | Online " . count(Player::$list) . "/" . $this->getMaxPlayers() . " | RAM " . round((memory_get_usage() / 1024) / 1024, 2) . "/" . round((memory_get_usage(true) / 1024) / 1024, 2) . " MB | U " . round($this->interface->getUploadSpeed() / 1024, 2) . " D " . round($this->interface->getDownloadSpeed() / 1024, 2) . " kB/s | TPS " . $this->getTPS() . "\x07";
}

View File

@ -26,7 +26,6 @@
namespace PocketMine;
use PocketMine\Entity\Entity;
use PocketMine\Network\Handler;
use PocketMine\Network\Packet;
use PocketMine\Network\Protocol\Info;
use PocketMine\Network\RakNet\Info as RakNetInfo;
@ -547,7 +546,9 @@ class ServerOld{
$data =& $packet;
$CID = Server::clientID($packet->ip, $packet->port);
if(isset(Player::$list[$CID])){
Player::$list[$CID]->handlePacket($packet);
if($packet instanceof RakNetPacket){
Player::$list[$CID]->handlePacket($packet);
}
}else{
switch($packet->pid()){
case RakNetInfo::UNCONNECTED_PING:

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
/**
* Air block

View File

@ -23,8 +23,8 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Network\Protocol\ChatPacket;
use PocketMine\Player;
use PocketMine\Server;
use PocketMine;
class Bed extends Transparent{
public function __construct($type = 0){
@ -34,8 +34,8 @@ class Bed extends Transparent{
$this->hardness = 1;
}
public function onActivate(Item $item, PocketMine\Player $player = null){
if($player instanceof PocketMine\Player and Server::getInstance()->api->time->getPhase($this->level) !== "night"){
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player and Server::getInstance()->api->time->getPhase($this->level) !== "night"){
$pk = new ChatPacket;
$pk->message = "You can only sleep at night";
$player->dataPacket($pk);
@ -58,7 +58,7 @@ class Bed extends Transparent{
$b = $blockEast;
}elseif($blockWest->getID() === $this->id and ($blockWest->meta & 0x08) === 0x08){
$b = $blockWest;
}elseif($player instanceof PocketMine\Player){
}elseif($player instanceof Player){
$pk = new ChatPacket;
$pk->message = "This bed is incomplete";
$player->dataPacket($pk);
@ -67,7 +67,7 @@ class Bed extends Transparent{
}
}
if($player instanceof PocketMine\Player and $player->sleepOn($b) === false){
if($player instanceof Player and $player->sleepOn($b) === false){
$pk = new ChatPacket;
$pk->message = "This bed is occupied";
$player->dataPacket($pk);
@ -76,7 +76,7 @@ class Bed extends Transparent{
return true;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->isTransparent === false){
$faces = array(
@ -85,7 +85,7 @@ class Bed extends Transparent{
2 => 2,
3 => 5,
);
$d = $player instanceof PocketMine\Player ? $player->getDirection() : 0;
$d = $player instanceof Player ? $player->getDirection() : 0;
$next = $this->getSide($faces[(($d + 3) % 4)]);
$downNext = $this->getSide(0);
if($next->isReplaceable === true and $downNext->isTransparent === false){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Bedrock extends Solid{

View File

@ -23,7 +23,7 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player;
class Beetroot extends Flowable{
public function __construct($meta = 0){
@ -32,7 +32,7 @@ class Beetroot extends Flowable{
$this->hardness = 0;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() === self::FARMLAND){
$this->level->setBlock($block, $this, true, false, true);
@ -43,7 +43,7 @@ class Beetroot extends Flowable{
return false;
}
public function onActivate(Item $item, PocketMine\Player $player = null){
public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal
$this->meta = 0x07;
$this->level->setBlock($this, $this, true, false, true);

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class BirchWoodStairs extends Stair{

View File

@ -24,10 +24,10 @@
*/
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine\Level\Position;
use PocketMine\Player;
abstract class Block extends Position{
const AIR = 0;
@ -516,21 +516,21 @@ abstract class Block extends Position{
* @param float $fx
* @param float $fy
* @param float $fz
* @param \PocketMine\Player $player = null
* @param Player $player = null
*
* @return bool
*/
abstract function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null);
abstract function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null);
/**
* Do actions when activated by Item. Returns if it has done anything
*
* @param Item $item
* @param \PocketMine\Player $player
* @param Player $player
*
* @return bool
*/
abstract function onActivate(Item $item, PocketMine\Player $player = null);
abstract function onActivate(Item $item, Player $player = null);
/**
* Fires a block update on the Block

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class Bookshelf extends Solid{
public function __construct(){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class BrickStairs extends Stair{
public function __construct($meta = 0){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Bricks extends Solid{

View File

@ -23,7 +23,7 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player;
class BrownMushroom extends Flowable{
public function __construct(){
@ -45,7 +45,7 @@ class BrownMushroom extends Flowable{
return false;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->isTransparent === false){
$this->level->setBlock($block, $this, true, false, true);

View File

@ -27,8 +27,8 @@ use PocketMine\NBT\Tag\Compound;
use PocketMine\NBT\Tag\Enum;
use PocketMine\NBT\Tag\Int;
use PocketMine\NBT\Tag\String;
use PocketMine\Player;
use PocketMine\Tile\Furnace;
use PocketMine;
use PocketMine\Tile\Tile;
class BurningFurnace extends Solid{
@ -38,14 +38,14 @@ class BurningFurnace extends Solid{
$this->hardness = 17.5;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$faces = array(
0 => 4,
1 => 2,
2 => 5,
3 => 3,
);
$this->meta = $faces[$player instanceof PocketMine\Player ? $player->getDirection() : 0];
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
$this->level->setBlock($block, $this, true, false, true);
$nbt = new Compound(false, array(
new Enum("Items", array()),
@ -66,8 +66,8 @@ class BurningFurnace extends Solid{
return true;
}
public function onActivate(Item $item, PocketMine\Player $player = null){
if($player instanceof PocketMine\Player){
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player){
$t = $this->level->getTile($this);
$furnace = false;
if($t instanceof Furnace){

View File

@ -24,8 +24,8 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine\Math\Vector3 as Vector3;
use PocketMine\Player;
use PocketMine\Server;
use PocketMine;
class Cactus extends Transparent{
public function __construct($meta = 0){
@ -67,7 +67,7 @@ class Cactus extends Transparent{
return false;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() === self::SAND or $down->getID() === self::CACTUS){
$block0 = $this->getSide(2);

View File

@ -23,7 +23,7 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player;
class Cake extends Transparent{
public function __construct($meta = 0){
@ -34,7 +34,7 @@ class Cake extends Transparent{
$this->hardness = 2.5;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() !== self::AIR){
$this->level->setBlock($block, $this, true, false, true);
@ -61,8 +61,8 @@ class Cake extends Transparent{
return array();
}
public function onActivate(Item $item, PocketMine\Player $player = null){
if($player instanceof PocketMine\Player and $player->getHealth() < 20){
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player and $player->getHealth() < 20){
++$this->meta;
$player->heal(3, "cake");
if($this->meta >= 0x06){

View File

@ -23,7 +23,7 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player;
class Carpet extends Flowable{
public function __construct($meta = 0){
@ -52,7 +52,7 @@ class Carpet extends Flowable{
$this->isSolid = true;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() !== self::AIR){
$this->level->setBlock($block, $this, true, false, true);

View File

@ -23,7 +23,7 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player;
class Carrot extends Flowable{
public function __construct($meta = 0){
@ -32,7 +32,7 @@ class Carrot extends Flowable{
$this->hardness = 0;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() === self::FARMLAND){
$this->level->setBlock($block, $this, true, false, true);
@ -43,7 +43,7 @@ class Carrot extends Flowable{
return false;
}
public function onActivate(Item $item, PocketMine\Player $player = null){
public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal
$this->meta = 0x07;
$this->level->setBlock($this, $this, true, false, true);

View File

@ -27,8 +27,8 @@ use PocketMine\NBT\Tag\Compound;
use PocketMine\NBT\Tag\Enum;
use PocketMine\NBT\Tag\Int;
use PocketMine\NBT\Tag\String;
use PocketMine\Player;
use PocketMine\Tile\Chest as TileChest;
use PocketMine;
use PocketMine\Tile\Tile;
class Chest extends Transparent{
@ -41,7 +41,7 @@ class Chest extends Transparent{
$this->hardness = 15;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$faces = array(
0 => 4,
1 => 2,
@ -50,7 +50,7 @@ class Chest extends Transparent{
);
$chest = false;
$this->meta = $faces[$player instanceof PocketMine\Player ? $player->getDirection() : 0];
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
for($side = 2; $side <= 5; ++$side){
if(($this->meta === 4 or $this->meta === 5) and ($side === 4 or $side === 5)){
@ -96,8 +96,8 @@ class Chest extends Transparent{
return true;
}
public function onActivate(Item $item, PocketMine\Player $player = null){
if($player instanceof PocketMine\Player){
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player){
$top = $this->getSide(1);
if($top->isTransparent !== true){
return true;

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Clay extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Coal extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class CoalOre extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Cobblestone extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class CobblestoneStairs extends Stair{
public function __construct($meta = 0){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Cobweb extends Flowable{

View File

@ -23,7 +23,7 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player;
class CyanFlower extends Flowable{
public function __construct(){
@ -31,7 +31,7 @@ class CyanFlower extends Flowable{
$this->hardness = 0;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){
$this->level->setBlock($block, $this, true, false, true);

View File

@ -23,7 +23,7 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player;
class Dandelion extends Flowable{
public function __construct(){
@ -31,7 +31,7 @@ class Dandelion extends Flowable{
$this->hardness = 0;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){
$this->level->setBlock($block, $this, true, false, true);

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Level\Level;
class DeadBush extends Flowable{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Diamond extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class DiamondOre extends Solid{

View File

@ -21,8 +21,8 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
use PocketMine\Player;
class Dirt extends Solid{
public function __construct(){
@ -31,7 +31,7 @@ class Dirt extends Solid{
$this->hardness = 2.5;
}
public function onActivate(Item $item, PocketMine\Player $player = null){
public function onActivate(Item $item, Player $player = null){
if($item->isHoe()){
$item->useOn($this);
$this->level->setBlock($this, Block::get(Item::FARMLAND, 0), true, false, true);

View File

@ -25,7 +25,6 @@ use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine\Network\Protocol\LevelEventPacket;
use PocketMine\Player;
use PocketMine;
abstract class Door extends Transparent{
@ -49,7 +48,7 @@ abstract class Door extends Transparent{
return false;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
if($face === 1){
$blockUp = $this->getSide(1);
$blockDown = $this->getSide(0);
@ -96,7 +95,7 @@ abstract class Door extends Transparent{
return true;
}
public function onActivate(Item $item, PocketMine\Player $player = null){
public function onActivate(Item $item, Player $player = null){
if(($this->meta & 0x08) === 0x08){ //Top
$down = $this->getSide(0);
if($down->getID() === $this->id){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class DoubleSlab extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class DoubleWoodSlab extends Solid{

View File

@ -23,8 +23,8 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine\Player;
use PocketMine\Server;
use PocketMine;
class Fallable extends Solid{
@ -33,7 +33,7 @@ class Fallable extends Solid{
$this->hasPhysics = true;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$ret = $this->level->setBlock($this, $this, true, false, true);
Server::getInstance()->api->block->blockUpdate(clone $this, Level::BLOCK_UPDATE_NORMAL);

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Farmland extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class Fence extends Transparent{
public function __construct(){

View File

@ -21,8 +21,8 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
use PocketMine\Player;
class FenceGate extends Transparent{
public function __construct($meta = 0){
@ -36,14 +36,14 @@ class FenceGate extends Transparent{
$this->hardness = 15;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$faces = array(
0 => 3,
1 => 0,
2 => 1,
3 => 2,
);
$this->meta = $faces[$player instanceof PocketMine\Player ? $player->getDirection() : 0] & 0x03;
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] & 0x03;
$this->level->setBlock($block, $this, true, false, true);
return true;
@ -55,14 +55,14 @@ class FenceGate extends Transparent{
);
}
public function onActivate(Item $item, PocketMine\Player $player = null){
public function onActivate(Item $item, Player $player = null){
$faces = array(
0 => 3,
1 => 0,
2 => 1,
3 => 2,
);
$this->meta = ($faces[$player instanceof PocketMine\Player ? $player->getDirection() : 0] & 0x03) | ((~$this->meta) & 0x04);
$this->meta = ($faces[$player instanceof Player ? $player->getDirection() : 0] & 0x03) | ((~$this->meta) & 0x04);
if(($this->meta & 0x04) === 0x04){
$this->isFullBlock = true;
}else{

View File

@ -23,7 +23,6 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
class Fire extends Flowable{
public function __construct($meta = 0){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class Flowable extends Transparent{
public function __construct($id, $meta = 0, $name = "Unknown"){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class Furnace extends BurningFurnace{

View File

@ -23,8 +23,8 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine\Player;
use PocketMine\Server;
use PocketMine;
class Generic extends Block{
@ -37,7 +37,7 @@ class Generic extends Block{
parent::__construct($id, $meta, $name);
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
return $this->level->setBlock($this, $this, true, false, true);
}
@ -73,7 +73,7 @@ class Generic extends Block{
return false;
}
public function onActivate(Item $item, PocketMine\Player $player = null){
public function onActivate(Item $item, Player $player = null){
return $this->isActivable;
}
}

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Glass extends Transparent{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class GlassPane extends Transparent{
public function __construct(){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class GlowingObsidian extends Solid{
public function __construct($meta = 0){

View File

@ -23,7 +23,6 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
class GlowingRedstoneOre extends Solid{
public function __construct(){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Glowstone extends Transparent{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Gold extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class GoldOre extends Solid{

View File

@ -23,8 +23,8 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Generator\Object\TallGrass;
use PocketMine\Player;
use PocketMine\Utils\Random;
use PocketMine;
class Grass extends Solid{
public function __construct(){
@ -39,7 +39,7 @@ class Grass extends Solid{
);
}
public function onActivate(Item $item, PocketMine\Player $player = null){
public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){
$item->count--;
TallGrass::growGrass($this->level, $this, new Random(), 8, 2);

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Gravel extends Fallable{

View File

@ -21,8 +21,8 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
use PocketMine\Player;
class HayBale extends Solid{
public function __construct($meta = 0){
@ -30,7 +30,7 @@ class HayBale extends Solid{
$this->hardness = 10;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$faces = array(
0 => 0,
1 => 0,

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Ice extends Transparent{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Iron extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class IronBars extends Transparent{
public function __construct(){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class IronDoor extends Door{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class IronOre extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class JungleWoodStairs extends Stair{

View File

@ -23,7 +23,7 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player;
class Ladder extends Transparent{
public function __construct($meta = 0){
@ -33,7 +33,7 @@ class Ladder extends Transparent{
$this->hardness = 2;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
if($target->isTransparent === false){
$faces = array(
2 => 2,

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Lapis extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class LapisOre extends Solid{

View File

@ -24,8 +24,8 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine\Level\Position;
use PocketMine\Player;
use PocketMine\Server;
use PocketMine;
class Lava extends Liquid{
public function __construct($meta = 0){
@ -33,7 +33,7 @@ class Lava extends Liquid{
$this->hardness = 0;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$ret = $this->level->setBlock($this, $this, true, false, true);
Server::getInstance()->api->block->scheduleBlockUpdate(clone $this, 40, Level::BLOCK_UPDATE_NORMAL);

View File

@ -23,7 +23,7 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player;
class Leaves extends Transparent{
const OAK = 0;
@ -140,7 +140,7 @@ class Leaves extends Transparent{
return false;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$this->meta |= 0x04;
$this->level->setBlock($this, $this, true, false, true);
}

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class Liquid extends Transparent{
public function __construct($id, $meta = 0, $name = "Unknown"){

View File

@ -21,8 +21,8 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
use PocketMine\Player;
class LitPumpkin extends Solid{
public function __construct(){
@ -30,7 +30,7 @@ class LitPumpkin extends Solid{
$this->hardness = 5;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$faces = array(
0 => 4,
1 => 2,

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Melon extends Transparent{

View File

@ -23,7 +23,7 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player;
class MelonStem extends Flowable{
public function __construct($meta = 0){
@ -32,7 +32,7 @@ class MelonStem extends Flowable{
$this->hardness = 0;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() === self::FARMLAND){
$this->level->setBlock($block, $this, true, false, true);
@ -80,7 +80,7 @@ class MelonStem extends Flowable{
return false;
}
public function onActivate(Item $item, PocketMine\Player $player = null){
public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal
$this->meta = 0x07;
$this->level->setBlock($this, $this, true, false, true);

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class MossStone extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class NetherBrick extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class NetherBrickStairs extends Stair{
public function __construct($meta = 0){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class NetherReactor extends Solid{
public function __construct($meta = 0){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Netherrack extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Obsidian extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class Planks extends Solid{
public function __construct($meta = 0){

View File

@ -23,7 +23,7 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player;
class Potato extends Flowable{
public function __construct($meta = 0){
@ -32,7 +32,7 @@ class Potato extends Flowable{
$this->hardness = 0;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() === self::FARMLAND){
$this->level->setBlock($block, $this, true, false, true);
@ -43,7 +43,7 @@ class Potato extends Flowable{
return false;
}
public function onActivate(Item $item, PocketMine\Player $player = null){
public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal
$this->meta = 0x07;
$this->level->setBlock($this, $this, true, false, true);

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class Pumpkin extends Solid{
public function __construct(){

View File

@ -23,7 +23,7 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player;
class PumpkinStem extends Flowable{
public function __construct($meta = 0){
@ -32,7 +32,7 @@ class PumpkinStem extends Flowable{
$this->hardness = 0;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() === self::FARMLAND){
$this->level->setBlock($block, $this, true, false, true);
@ -80,7 +80,7 @@ class PumpkinStem extends Flowable{
return false;
}
public function onActivate(Item $item, PocketMine\Player $player = null){
public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal
$this->meta = 0x07;
$this->level->setBlock($this, $this, true, false, true);

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Quartz extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class QuartzStairs extends Stair{
public function __construct($meta = 0){

View File

@ -23,7 +23,7 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player;
class RedMushroom extends Flowable{
public function __construct(){
@ -45,7 +45,7 @@ class RedMushroom extends Flowable{
return false;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->isTransparent === false){
$this->level->setBlock($block, $this, true, false, true);

View File

@ -23,7 +23,6 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
class RedstoneOre extends Solid{
public function __construct(){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class Sand extends Fallable{
public function __construct(){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Sandstone extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class SandstoneStairs extends Stair{
public function __construct($meta = 0){

View File

@ -24,8 +24,8 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Generator\Object\Tree;
use PocketMine\Level\Level;
use PocketMine\Player;
use PocketMine\Utils\Random;
use PocketMine;
class Sapling extends Flowable{
const OAK = 0;
@ -47,7 +47,7 @@ class Sapling extends Flowable{
$this->hardness = 0;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down->getID() === self::GRASS or $down->getID() === self::DIRT or $down->getID() === self::FARMLAND){
$this->level->setBlock($block, $this, true, false, true);
@ -58,7 +58,7 @@ class Sapling extends Flowable{
return false;
}
public function onActivate(Item $item, PocketMine\Player $player = null){
public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal
Tree::growTree($this->level, $this, new Random(), $this->meta & 0x03);
if(($player->gamemode & 0x01) === 0){

View File

@ -23,7 +23,7 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player;
class SignPost extends Transparent{
public function __construct($meta = 0){
@ -33,7 +33,7 @@ class SignPost extends Transparent{
$this->hardness = 5;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
if($face !== 0){
$faces = array(
2 => 2,

View File

@ -21,8 +21,8 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
use PocketMine\Player;
class Slab extends Transparent{
public function __construct($meta = 0){
@ -46,7 +46,7 @@ class Slab extends Transparent{
$this->hardness = 30;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$this->meta &= 0x07;
if($face === 0){
if($target->getID() === self::SLAB and ($target->getMetadata() & 0x08) === 0x08 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){
@ -70,7 +70,7 @@ class Slab extends Transparent{
return true;
}
}elseif(!($player instanceof PocketMine\Player) or !$player->inBlock($block)){
}elseif(!($player instanceof Player) or !$player->inBlock($block)){
if($block->getID() === self::SLAB){
if(($block->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($block, Block::get(Item::DOUBLE_SLAB, $this->meta), true, false, true);

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class Snow extends Solid{
public function __construct(){

View File

@ -23,7 +23,7 @@ namespace PocketMine\Block;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
use PocketMine\Player;
class SnowLayer extends Flowable{
public function __construct($meta = 0){
@ -34,7 +34,7 @@ class SnowLayer extends Flowable{
$this->hardness = 0.5;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$down = $this->getSide(0);
if($down instanceof Solid){
$this->level->setBlock($block, $this, true, false, true);

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class Solid extends Generic{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class SoulSand extends Solid{
public function __construct(){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class Sponge extends Solid{
public function __construct(){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class SpruceWoodStairs extends Stair{

View File

@ -21,8 +21,8 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
use PocketMine\Player;
class Stair extends Transparent{
@ -36,7 +36,7 @@ class Stair extends Transparent{
$this->hardness = 30;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$faces = array(
0 => 0,
1 => 2,

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class StillLava extends Liquid{
public function __construct($meta = 0){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class StillWater extends Water{
public function __construct($meta = 0){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class Stone extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class StoneBrickStairs extends Stair{
public function __construct($meta = 0){

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
class StoneBricks extends Solid{

View File

@ -21,7 +21,6 @@
namespace PocketMine\Block;
use PocketMine;
class StoneWall extends Transparent{
public function __construct($meta = 0){

View File

@ -21,8 +21,8 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
use PocketMine\Player;
class Stonecutter extends Solid{
public function __construct($meta = 0){
@ -30,7 +30,7 @@ class Stonecutter extends Solid{
$this->isActivable = true;
}
public function onActivate(Item $item, PocketMine\Player $player = null){
public function onActivate(Item $item, Player $player = null){
$player->toCraft[-1] = 2;
return true;

Some files were not shown because too many files have changed in this diff Show More