Added ChunkLoadEvent, ChunkUnloadEvent, ChunkPopulateEvent

This commit is contained in:
Shoghi Cervantes
2014-08-02 17:19:33 +02:00
parent 7ddfd4394d
commit eee7e659e9
6 changed files with 176 additions and 10 deletions

View File

@ -0,0 +1,47 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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 PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
/**
* Level related events
*/
namespace pocketmine\event\level;
use pocketmine\level\format\FullChunk;
abstract class ChunkEvent extends LevelEvent{
/** @var FullChunk */
private $chunk;
/**
* @param FullChunk $chunk
*/
public function __construct(FullChunk $chunk){
parent::__construct($chunk->getLevel()->getLevel());
$this->chunk = $chunk;
}
/**
* @return FullChunk
*/
public function getChunk(){
return $this->chunk;
}
}

View File

@ -0,0 +1,44 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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 PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\event\level;
use pocketmine\level\format\FullChunk;
/**
* Called when a Chunk is loaded
*/
class ChunkLoadEvent extends ChunkEvent{
public static $handlerList = null;
private $newChunk;
public function __construct(FullChunk $chunk, $newChunk){
parent::__construct($chunk);
$this->newChunk = (bool) $newChunk;
}
/**
* @return bool
*/
public function isNewChunk(){
return $this->newChunk;
}
}

View File

@ -0,0 +1,29 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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 PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\event\level;
/**
* Called when a Chunk is populated (after receiving it on the main thread)
*/
class ChunkPopulateEvent extends ChunkEvent{
public static $handlerList = null;
}

View File

@ -0,0 +1,30 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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 PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\event\level;
use pocketmine\event\Cancellable;
/**
* Called when a Chunk is unloaded
*/
class ChunkUnloadEvent extends ChunkEvent implements Cancellable{
public static $handlerList = null;
}

View File

@ -23,7 +23,7 @@ namespace pocketmine\event\level;
use pocketmine\event\Cancellable;
/**
* Called when a Level is saved
* Called when a Level is unloaded
*/
class LevelUnloadEvent extends LevelEvent implements Cancellable{
public static $handlerList = null;