Added server-side join message (removed from client-side MCPE)

This commit is contained in:
Shoghi Cervantes 2014-06-15 00:14:28 +02:00
parent cb1c4da4ea
commit c4673addf7
3 changed files with 31 additions and 3 deletions

View File

@ -51,7 +51,6 @@ use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\SimpleTransactionGroup; use pocketmine\inventory\SimpleTransactionGroup;
use pocketmine\inventory\StonecutterShapelessRecipe; use pocketmine\inventory\StonecutterShapelessRecipe;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\level\format\pmf\LevelFormat;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\level\Position; use pocketmine\level\Position;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
@ -1191,7 +1190,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->server->getLogger()->info(TextFormat::AQUA . $this->username . TextFormat::WHITE . "[/" . $this->ip . ":" . $this->port . "] logged in with entity id " . $this->id . " at (" . $this->getLevel()->getName() . ", " . round($this->x, 4) . ", " . round($this->y, 4) . ", " . round($this->z, 4) . ")"); $this->server->getLogger()->info(TextFormat::AQUA . $this->username . TextFormat::WHITE . "[/" . $this->ip . ":" . $this->port . "] logged in with entity id " . $this->id . " at (" . $this->getLevel()->getName() . ", " . round($this->x, 4) . ", " . round($this->y, 4) . ", " . round($this->z, 4) . ")");
$this->server->getPluginManager()->callEvent(new PlayerJoinEvent($this, $this->username . " joined the game")); $this->server->getPluginManager()->callEvent($ev = new PlayerJoinEvent($this, $this->username . " joined the game"));
$this->server->broadcastMessage($ev->getJoinMessage());
$this->orderChunks(); $this->orderChunks();

View File

@ -594,7 +594,7 @@ abstract class Entity extends Position implements Metadatable{
foreach($this->getLevel()->getChunkEntities($X, $Z) as $entity){ foreach($this->getLevel()->getChunkEntities($X, $Z) as $entity){
$entity->despawnFrom($this); $entity->despawnFrom($this);
} }
$pk = new UnloadChunkPacket(); $pk = new UnloadChunkPacket();
$pk->chunkX = $X; $pk->chunkX = $X;
$pk->chunkZ = $Z; $pk->chunkZ = $Z;

View File

@ -1294,6 +1294,11 @@ class Level implements ChunkManager, Metadatable{
unset($this->entities[$entity->getID()]); unset($this->entities[$entity->getID()]);
} }
/**
* @param Entity $entity
*
* @throws \RuntimeException
*/
public function addEntity(Entity $entity){ public function addEntity(Entity $entity){
if($entity->getLevel() !== $this){ if($entity->getLevel() !== $this){
throw new \RuntimeException("Invalid Entity level"); throw new \RuntimeException("Invalid Entity level");
@ -1304,6 +1309,11 @@ class Level implements ChunkManager, Metadatable{
$this->entities[$entity->getID()] = $entity; $this->entities[$entity->getID()] = $entity;
} }
/**
* @param Tile $tile
*
* @throws \RuntimeException
*/
public function addTile(Tile $tile){ public function addTile(Tile $tile){
if($tile->getLevel() !== $this){ if($tile->getLevel() !== $this){
throw new \RuntimeException("Invalid Tile level"); throw new \RuntimeException("Invalid Tile level");
@ -1311,6 +1321,11 @@ class Level implements ChunkManager, Metadatable{
$this->tiles[$tile->getID()] = $tile; $this->tiles[$tile->getID()] = $tile;
} }
/**
* @param Tile $tile
*
* @throws \RuntimeException
*/
public function removeTile(Tile $tile){ public function removeTile(Tile $tile){
if($tile->getLevel() !== $this){ if($tile->getLevel() !== $this){
throw new \RuntimeException("Invalid Tile level"); throw new \RuntimeException("Invalid Tile level");
@ -1321,10 +1336,23 @@ class Level implements ChunkManager, Metadatable{
unset($this->tiles[$tile->getID()]); unset($this->tiles[$tile->getID()]);
} }
/**
* @param int $x
* @param int $z
*
* @return bool
*/
public function isChunkInUse($x, $z){ public function isChunkInUse($x, $z){
return isset($this->usedChunks[static::chunkHash($x, $z)]); return isset($this->usedChunks[static::chunkHash($x, $z)]);
} }
/**
* @param int $x
* @param int $z
* @param bool $generate
*
* @return bool
*/
public function loadChunk($x, $z, $generate = true){ public function loadChunk($x, $z, $generate = true){
if($generate === true){ if($generate === true){
return $this->getChunkAt($x, $z, true) instanceof Chunk; return $this->getChunkAt($x, $z, true) instanceof Chunk;