예제 #1
1
 public function spawnTo(Player $player)
 {
     if ($player instanceof DesktopPlayer) {
         if ($this !== $player and $this->spawned === true and $player->getLevel() === $this->getLevel() and $player->canSee($this)) {
             $this->hasSpawned[$player->getID()] = $player;
             $pk = new SpawnPlayerPacket();
             if ($player->getRemoveFormat()) {
                 $pk->name = TextFormat::clean($this->nameTag);
             } else {
                 $pk->name = $this->nameTag;
             }
             $pk->eid = $this->getID();
             $pk->uuid = $this->bigBrother_formatedUUID;
             $pk->x = $this->x;
             $pk->z = $this->y;
             $pk->y = $this->z;
             $pk->yaw = $this->yaw;
             $pk->pitch = $this->pitch;
             $pk->item = $this->inventory->getItemInHand()->getID();
             $pk->metadata = $this->getData();
             $pk->data = $this->bigBrother_properties;
             $player->putRawPacket($pk);
             $pk = new EntityTeleportPacket();
             $pk->eid = $this->getID();
             $pk->x = $this->x;
             $pk->z = $this->y;
             $pk->y = $this->z;
             $pk->yaw = $this->yaw;
             $pk->pitch = $this->pitch;
             $player->putRawPacket($pk);
             $pk = new SetEntityMotionPacket();
             $pk->eid = $this->getID();
             $pk->speedX = $this->motionX;
             $pk->speedY = $this->motionY;
             $pk->speedZ = $this->motionZ;
             $player->dataPacket($pk);
             $this->inventory->sendHeldItem($player);
             $this->inventory->sendArmorContents($player);
         }
     } else {
         parent::spawnTo($player);
     }
 }
예제 #2
0
 /**
  * WARNING: Do not use this, it's only for internal use.
  * Changes to this function won't be recorded on the version.
  *
  * @param int    $X
  * @param int    $Z
  * @param Player $player
  */
 public function freeChunk($X, $Z, Player $player)
 {
     unset($this->usedChunks[$index = Level::chunkHash($X, $Z)][$player->getID()]);
     $this->unloadChunkRequest($X, $Z, true);
 }
예제 #3
0
 public function despawnFrom(Player $player)
 {
     if (isset($this->hasSpawned[$player->getID()])) {
         $pk = new RemovePlayerPacket();
         $pk->eid = $this->id;
         $pk->clientID = 0;
         $player->dataPacket($pk);
         unset($this->hasSpawned[$player->getID()]);
     }
 }
예제 #4
0
 public function onLoggedIn(Player $player)
 {
     if (isset($this->loggedIn[$player->getID()])) {
         return;
     }
     $f = $this->getFList()->getFaction($player);
     if (!$f instanceof Faction) {
         return;
     }
     $f->setActiveNow();
     $this->loggedIn[$player->getID()] = true;
 }
예제 #5
0
 public function onActivate(Item $item, Player $player = null)
 {
     if (($this->meta & 0x8) === 0x8) {
         //Top
         $down = $this->getSide(0);
         if ($down->getID() === $this->id) {
             $meta = $down->getDamage() ^ 0x4;
             $this->getLevel()->setBlock($down, Block::get($this->id, $meta), true);
             $players = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4);
             if ($player instanceof Player) {
                 unset($players[$player->getID()]);
             }
             $pk = new LevelEventPacket();
             $pk->x = $this->x;
             $pk->y = $this->y;
             $pk->z = $this->z;
             $pk->evid = 1003;
             $pk->data = 0;
             Server::broadcastPacket($players, $pk);
             return true;
         }
         return false;
     } else {
         $this->meta ^= 0x4;
         $this->getLevel()->setBlock($this, $this, true);
         $players = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4);
         if ($player instanceof Player) {
             unset($players[$player->getID()]);
         }
         $pk = new LevelEventPacket();
         $pk->x = $this->x;
         $pk->y = $this->y;
         $pk->z = $this->z;
         $pk->evid = 1003;
         $pk->data = 0;
         Server::broadcastPacket($players, $pk);
     }
     return true;
 }
 /**
  * @param Player $player
  * @return bool|Position
  */
 public function getAnchor(Player $player)
 {
     return isset($this->anchors[$player->getID()]) ? $this->anchors[$player->getID()] : false;
 }
예제 #7
0
 public static function offset(Player $player)
 {
     return $player->getID();
 }
예제 #8
0
 public function despawnFrom(Player $player)
 {
     if (isset($this->hasSpawned[$player->getID()])) {
         $this->entityevent_pk->eid = $this->id;
         $this->entityevent_pk->event = 3;
         if ($player != null) {
             $player->dataPacket($this->entityevent_pk);
             $this->removeentity_pk->eid = $this->id;
             $this->server->getScheduler()->scheduleDelayedTask(new CallbackTask([$player, "dataPacket"], [$this->removeentity_pk]), 23);
         }
         unset($this->hasSpawned[$player->getID()]);
     }
 }
 private function offset(Player $player)
 {
     return $player->getID();
 }
예제 #10
0
 public function finalizePlayer(Player $player, $isQuit)
 {
     if (isset($this->stack[$id = $player->getID()])) {
         unset($this->stack[$id]);
         // avoid bugs if the entity ID gets reused
         if ($isQuit) {
             $this->getLogger()->alert($player->getDisplayName() . " has quit, so his recording macro has been discarded.");
         } else {
             $this->getLogger()->alert("Discarding recording macro of " . $player->getDisplayName() . " due to plugin disable.");
             $player->sendMessage("Your recording macro has been discarded due to SimpleMacros being disabled.");
         }
     }
     if (isset($this->paused[$id])) {
         unset($this->stack[$id]);
     }
     if (isset($this->atts[$id])) {
         unset($this->atts[$id]);
     }
 }