示例#1
0
 public static function broadcast(Player $player, $achievementId)
 {
     if (isset(Achievement::$list[$achievementId])) {
         $translation = new TranslationContainer("chat.type.achievement", [$player->getDisplayName(), TextFormat::RED . Achievement::$list[$achievementId]["name"]]);
         if (Server::getInstance()->getConfigString("announce-player-achievements", true) === true) {
             Server::getInstance()->broadcastMessage($translation);
         } else {
             $player->sendMessage($translation);
         }
         return true;
     }
     return false;
 }
示例#2
0
 public function onActivate(Item $item, Player $player = null)
 {
     $time = $this->getLevel()->getTime() % Level::TIME_FULL;
     $isNight = ($time >= Level::TIME_NIGHT and $time < Level::TIME_SUNRISE);
     if ($player instanceof Player and !$isNight) {
         $player->sendMessage(TextFormat::GRAY . "You can only sleep at night");
         return true;
     }
     $blockNorth = $this->getSide(2);
     //Gets the blocks around them
     $blockSouth = $this->getSide(3);
     $blockEast = $this->getSide(5);
     $blockWest = $this->getSide(4);
     if (($this->meta & 0x8) === 0x8) {
         //This is the Top part of bed
         $b = $this;
     } else {
         //Bottom Part of Bed
         if ($blockNorth->getId() === $this->id and ($blockNorth->meta & 0x8) === 0x8) {
             $b = $blockNorth;
         } elseif ($blockSouth->getId() === $this->id and ($blockSouth->meta & 0x8) === 0x8) {
             $b = $blockSouth;
         } elseif ($blockEast->getId() === $this->id and ($blockEast->meta & 0x8) === 0x8) {
             $b = $blockEast;
         } elseif ($blockWest->getId() === $this->id and ($blockWest->meta & 0x8) === 0x8) {
             $b = $blockWest;
         } else {
             if ($player instanceof Player) {
                 $player->sendMessage(TextFormat::GRAY . "This bed is incomplete");
             }
             return true;
         }
     }
     if ($player instanceof Player and $player->sleepOn($b) === false) {
         $player->sendMessage(TextFormat::GRAY . "This bed is occupied");
     }
     return true;
 }