getServer() public method

public getServer ( ) : Server
return Server
示例#1
1
 public function teleport(Player $player)
 {
     if ($this->message !== null) {
         $player->sendMessage($this->message);
     }
     if ($this->position instanceof Position) {
         if ($this->position->isValid()) {
             if ($this->position instanceof WeakPosition) {
                 $this->position->updateProperties();
             }
             //Server::getInstance()->getLogger()->info($this->position->x . " : " . $this->position->y . " : " . $this->position->z);
             $player->teleport($this->position);
         } else {
             $player->sendMessage($this->getApi()->executeTranslationItem("level-not-loaded-warp"));
         }
     } else {
         $plugin = $player->getServer()->getPluginManager()->getPlugin("FastTransfer");
         if ($plugin instanceof PluginBase && $plugin->isEnabled() && $plugin instanceof FastTransfer) {
             $plugin->transferPlayer($player, $this->address, $this->port);
         } else {
             $player->getServer()->getPluginManager()->getPlugin("SimpleWarp")->getLogger()->warning("In order to use warps tp other servers, you must install " . TextFormat::AQUA . "FastTransfer" . TextFormat::RESET . ".");
             $player->sendPopup(TextFormat::RED . "Warp failed!" . TextFormat::RESET);
         }
     }
 }
示例#2
1
 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         $t = $this->getLevel()->getTile($this);
         $dispenser = null;
         if ($t instanceof TileDispenser) {
             $dispenser = $t;
         } else {
             $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::DISPENSER), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]);
             $nbt->Items->setTagType(NBT::TAG_Compound);
             $dispenser = Tile::createTile(Tile::DISPENSER, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         }
         if ($player->isCreative() and $player->getServer()->limitedCreative) {
             return true;
         }
         $player->addWindow($dispenser->getInventory());
     }
     return true;
 }
示例#3
1
 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         $t = $this->getLevel()->getTile($this);
         if ($t instanceof FurnaceTile) {
             $furnace = $t;
         } else {
             $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::FURNACE), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]);
             $nbt->Items->setTagType(NBT::TAG_Compound);
             $furnace = Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         }
         if (isset($furnace->namedtag->Lock) and $furnace->namedtag->Lock instanceof StringTag) {
             if ($furnace->namedtag->Lock->getValue() !== $item->getCustomName()) {
                 return true;
             }
         }
         if ($player->isCreative() and $player->getServer()->limitedCreative) {
             return true;
         }
         $player->addWindow($furnace->getInventory());
     }
     return true;
 }
示例#4
1
文件: Chest.php 项目: xpyctum/Genisys
 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         $top = $this->getSide(1);
         if ($top->isTransparent() !== true) {
             return true;
         }
         $t = $this->getLevel()->getTile($this);
         $chest = null;
         if ($t instanceof TileChest) {
             $chest = $t;
         } else {
             $nbt = new CompoundTag("", [new EnumTag("Items", []), new StringTag("id", Tile::CHEST), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]);
             $nbt->Items->setTagType(NBT::TAG_Compound);
             $chest = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         }
         if (isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof StringTag) {
             if ($chest->namedtag->Lock->getValue() !== $item->getCustomName()) {
                 return true;
             }
         }
         if ($player->isCreative() and $player->getServer()->limitedCreative) {
             return true;
         }
         $player->addWindow($chest->getInventory());
     }
     return true;
 }
示例#5
0
 public function getMaskLocation(Player $player)
 {
     // always return player current location if there is an error
     if (!$this->maskLoc) {
         return $player->getLocation();
     }
     if (!preg_match('#^((\\?spawn\\?)|((\\-)?[0-9]+,(\\-)?[0-9]+,(\\-)?[0-9]+))@([^/\\\\]+)$#', $this->maskLocPos, $match)) {
         return $player->getLocation();
     }
     $pos = $match[1];
     $world = $match[7];
     $level = $player->getLevel();
     if ($world === "?default?") {
         $level = $player->getServer()->getDefaultLevel();
     } elseif ($world !== "?current?") {
         $level = $player->getServer()->getLevelByName($world);
         if (!$level instanceof Level) {
             $level = $player->getLevel();
         }
     }
     if ($pos === "?spawn?") {
         $position = $level->getSpawnLocation();
     } else {
         list($x, $y, $z) = explode(",", $pos);
         $position = new Position((int) $x, (int) $y, (int) $z, $level);
     }
     return $position;
 }
示例#6
0
 /**
  * This will transfer a player and also add the workaround for players
  * lingering connections...
  * @param Player $player
  * @param str $address
  * @param int $port
  * @param str $message
  * @return bool
  */
 public static function transferPlayer(Player $player, $address, $port, $message = null)
 {
     $ft = $player->getServer()->getPluginManager()->getPlugin("FastTransfer");
     if ($ft === null) {
         return false;
     }
     if ($message === null) {
         $message = mc::_("You are being transferred");
     }
     $res = $ft->transferPlayer($player, $address, $port, $message);
     // find out the RakLib interface, which is the network interface that MCPE players connect with
     foreach ($player->getServer()->getNetwork()->getInterfaces() as $interface) {
         if ($interface instanceof RakLibInterface) {
             $raklib = $interface;
             break;
         }
     }
     if (!isset($rakLib)) {
         return $res;
     }
     // calculate the identifier for the player used by RakLib
     $identifier = $player->getAddress() . ":" . $player->getPort();
     // this method call is the most important one -
     // it sends some signal to RakLib that makes it think that the client
     // has clicked the "Quit to Title" button (or timed out). Some RakLib
     // internal stuff will then tell PocketMine that the player has quitted.
     $rakLib->closeSession($identifier, "transfer");
 }
示例#7
0
 public function onActivate(Item $item, Player $player = null)
 {
     if (!$this->getLevel()->getServer()->anviletEnabled) {
         return true;
     }
     if ($player instanceof Player) {
         //TODO lock
         if ($player->isCreative() and $player->getServer()->limitedCreative) {
             return true;
         }
         $tile = $this->getLevel()->getTile($this);
         $enchantTable = null;
         if ($tile instanceof EnchantTable) {
             $enchantTable = $tile;
         }
     } else {
         $this->getLevel()->setBlock($this, $this, true, true);
         $nbt = new CompoundTag("", [new StringTag("id", Tile::ENCHANT_TABLE), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]);
         if ($item->hasCustomName()) {
             $nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
         }
         if ($item->hasCustomBlockData()) {
             foreach ($item->getCustomBlockData() as $key => $v) {
                 $nbt->{$key} = $v;
             }
         }
         $enchantTable = Tile::createTile(Tile::ENCHANT_TABLE, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
     }
     $player->addWindow($enchantTable->getInventory());
     return true;
 }
示例#8
0
 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if ($player === null or $player->isSurvival() !== true) {
         return false;
     }
     if ($target->getId() === Block::STILL_WATER or $target->getId() === Block::WATER) {
         $player->getServer()->getPluginManager()->callEvent($ev = new PlayerGlassBottleEvent($player, $target, $this));
         if ($ev->isCancelled()) {
             return false;
         } else {
             if ($this->count <= 1) {
                 $player->getInventory()->setItemInHand(Item::get(Item::POTION, 0, 1));
                 return true;
             } else {
                 $this->count--;
                 $player->getInventory()->setItemInHand($this);
             }
             if ($player->getInventory()->canAddItem(Item::get(Item::POTION, 0, 1)) === true) {
                 $player->getInventory()->AddItem(Item::get(Item::POTION, 0, 1));
             } else {
                 $motion = $player->getDirectionVector()->multiply(0.4);
                 $position = clone $player->getPosition();
                 $player->getLevel()->dropItem($position->add(0, 0.5, 0), Item::get(Item::POTION, 0, 1), $motion, 40);
             }
             return true;
         }
     }
     return false;
 }
示例#9
0
 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         if ($player->getServer()->limitedCreative and $player->isCreative()) {
             return true;
         }
         $player->craftingType = Player::CRAFTING_BIG;
     }
     return true;
 }
 public function execute(Player $source) : bool
 {
     $droppedItem = $this->getTargetItem();
     if (!$source->getServer()->getAllowInvCheats() and !$source->isCreative()) {
         if (!$source->getFloatingInventory()->contains($droppedItem)) {
             return false;
         }
         $source->getFloatingInventory()->removeItem($droppedItem);
     }
     $source->dropItem($droppedItem);
     return true;
 }
示例#11
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($player instanceof Player) {
         $this->meta = ((int) $player->getDirection() + 5) % 4;
     }
     $this->getLevel()->setBlock($block, $this, true, true);
     if ($player != null) {
         // interesting for snow golem AND iron golem (this can be the body)
         $firstBlock = $this->getLevel()->getBlock($block->add(0, -1, 0));
         $secondBlock = $this->getLevel()->getBlock($block->add(0, -2, 0));
         // interesting for iron golem (checking arms and air beyond the feet)
         $armBlock1 = $this->getLevel()->getBlock($block->add(0, -1, -1));
         // arm 1
         $armBlock2 = $this->getLevel()->getBlock($block->add(0, -1, 1));
         // arm2
         $airBlock1 = $this->getLevel()->getBlock($block->add(0, -2, -1));
         // beneath arms
         $airBlock2 = $this->getLevel()->getBlock($block->add(0, -2, 1));
         // beneath arms
         // we've to test in all 3d!
         $armBlock3 = $this->getLevel()->getBlock($block->add(-1, -1, 0));
         // arm 1
         $armBlock4 = $this->getLevel()->getBlock($block->add(1, -1, 0));
         // arm2
         $airBlock3 = $this->getLevel()->getBlock($block->add(-1, -2, 0));
         // beneath arms
         $airBlock4 = $this->getLevel()->getBlock($block->add(1, -2, 0));
         // beneath arms
         if ($firstBlock->getId() === Item::SNOW_BLOCK && $secondBlock->getId() === Item::SNOW_BLOCK and $player->getServer()->getProperty("golem.snow-golem-enabled") === true) {
             //Block match snowgolem
             $this->getLevel()->setBlock($block, new Air());
             $this->getLevel()->setBlock($firstBlock, new Air());
             $this->getLevel()->setBlock($secondBlock, new Air());
             $snowGolem = new SnowGolem($player->getLevel()->getChunk($this->getX() >> 4, $this->getZ() >> 4), new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)])]));
             $snowGolem->spawnToAll();
         } elseif ($firstBlock->getId() === Item::IRON_BLOCK && $secondBlock->getId() === Item::IRON_BLOCK and $player->getServer()->getProperty("golem.iron-golem-enabled") === true) {
             // possible iron golem
             if ($armBlock1->getId() === Item::IRON_BLOCK && $armBlock2->getId() === Item::IRON_BLOCK && $airBlock1->getId() === Item::AIR && $airBlock2->getId() === Item::AIR || $armBlock3->getId() === Item::IRON_BLOCK && $armBlock4->getId() === Item::IRON_BLOCK && $airBlock3->getId() === Item::AIR && $airBlock4->getId() === Item::AIR) {
                 $this->getLevel()->setBlock($block, new Air());
                 $this->getLevel()->setBlock($firstBlock, new Air());
                 $this->getLevel()->setBlock($secondBlock, new Air());
                 $this->getLevel()->setBlock($armBlock1, new Air());
                 $this->getLevel()->setBlock($armBlock2, new Air());
                 $this->getLevel()->setBlock($armBlock3, new Air());
                 $this->getLevel()->setBlock($armBlock4, new Air());
                 $ironGolem = new IronGolem($player->getLevel()->getChunk($this->getX() >> 4, $this->getZ() >> 4), new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)])]));
                 $ironGolem->spawnToAll();
             }
         }
     }
     return true;
 }
 public function onActivate(Item $item, Player $player = null)
 {
     if (!$this->getLevel()->getServer()->anvilEnabled) {
         return true;
     }
     if ($player instanceof Player) {
         if ($player->isCreative() and $player->getServer()->limitedCreative) {
             return true;
         }
         $player->addWindow(new AnvilInventory($this));
     }
     return true;
 }
示例#13
0
 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     $bucketContents = Block::get($this->meta);
     if ($bucketContents instanceof Air) {
         // Bucket Empty so pick up block
         if ($target instanceof Liquid and $target->getDamage() === 0) {
             $result = clone $this;
             if ($target instanceof StillWater) {
                 $toStore = Block::WATER;
             } elseif ($target instanceof StillLava) {
                 $toStore = Block::LAVA;
             } else {
                 return false;
             }
             $result->setDamage($toStore);
             $player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketFillEvent($player, $block, $face, $this, $result));
             if (!$ev->isCancelled()) {
                 $player->getLevel()->setBlock($target, new Air(), true, true);
                 if ($player->isSurvival()) {
                     $player->getInventory()->setItemInHand($ev->getItem(), $player);
                 }
                 return true;
             } else {
                 $player->getInventory()->sendContents($player);
             }
         }
     } elseif ($bucketContents instanceof Liquid) {
         // Bucket Full, so empty
         $result = clone $this;
         $result->setDamage(0);
         if ($bucketContents instanceof Water) {
             $toCreate = Block::STILL_WATER;
         } elseif ($bucketContents instanceof Lava) {
             $toCreate = Block::STILL_LAVA;
         } else {
             return false;
         }
         $bucketContents = Block::get($toCreate);
         $player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketFillEvent($player, $block, $face, $this, $result));
         if (!$ev->isCancelled()) {
             $player->getLevel()->setBlock($block, $bucketContents, true, true);
             if ($player->isSurvival()) {
                 $player->getInventory()->setItemInHand($ev->getItem(), $player);
             }
             return true;
         } else {
             $player->getInventory()->sendContents($player);
         }
     }
     return false;
 }
示例#14
0
 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         $t = $this->getLevel()->getTile($this);
         if ($t instanceof TileHopper) {
             if ($t->hasLock() and !$t->checkLock($item->getCustomName())) {
                 $player->getServer()->getLogger()->debug($player->getName() . " attempted to open a locked hopper");
                 return true;
             }
             $player->addWindow($t->getInventory());
         }
     }
     return true;
 }
示例#15
0
 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     $targetBlock = Block::get($this->meta);
     if ($targetBlock instanceof Air) {
         if ($target instanceof Liquid and $target->getDamage() === 0) {
             $result = clone $this;
             $id = $target->getId();
             if ($id == self::STILL_WATER) {
                 $id = self::WATER;
             }
             if ($id == self::STILL_LAVA) {
                 $id = self::LAVA;
             }
             $result->setDamage($id);
             $player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketFillEvent($player, $block, $face, $this, $result));
             if (!$ev->isCancelled()) {
                 $player->getLevel()->setBlock($target, new Air(), true, true);
                 if ($player->isSurvival()) {
                     $player->getInventory()->setItemInHand($ev->getItem());
                 }
                 return true;
             } else {
                 $player->getInventory()->sendContents($player);
             }
         }
     } elseif ($targetBlock instanceof Liquid) {
         $result = clone $this;
         $result->setDamage(0);
         $player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketEmptyEvent($player, $block, $face, $this, $result));
         if (!$ev->isCancelled()) {
             //Only disallow water placement in the Nether, allow other liquids to be placed
             //In vanilla, water buckets are emptied when used in the Nether, but no water placed.
             if (!($player->getLevel()->getDimension() === Level::DIMENSION_NETHER and $targetBlock->getID() === self::WATER)) {
                 $player->getLevel()->setBlock($block, $targetBlock, true, true);
             }
             if ($player->isSurvival()) {
                 $player->getInventory()->setItemInHand($ev->getItem());
             }
             return true;
         } else {
             $player->getInventory()->sendContents($player);
         }
     }
     return false;
 }
示例#16
0
 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         //TODO lock
         if ($player->isCreative() and $player->getServer()->limitedCreative) {
             return true;
         }
         $t = $this->getLevel()->getTile($this);
         $brewingStand = false;
         if ($t instanceof TileBrewingStand) {
             $brewingStand = $t;
         } else {
             $nbt = new CompoundTag("", [new EnumTag("Items", []), new StringTag("id", Tile::BREWING_STAND), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]);
             $nbt->Items->setTagType(NBT::TAG_Compound);
             $brewingStand = Tile::createTile(Tile::BREWING_STAND, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         }
         $player->addWindow($brewingStand->getInventory());
     }
     return true;
 }
示例#17
0
 public function onRename(Player $player, Item $resultItem) : bool
 {
     if (!$resultItem->deepEquals($this->getItem(self::TARGET), true, false, true)) {
         //Item does not match target item. Everything must match except the tags.
         return false;
     }
     if ($player->getExpLevel() < $resultItem->getRepairCost()) {
         //Not enough exp
         return false;
     }
     $player->setExpLevel($player->getExpLevel() - $resultItem->getRepairCost());
     $this->clearAll();
     if (!$player->getServer()->allowInventoryCheats and !$player->isCreative()) {
         if (!$player->getFloatingInventory()->canAddItem($resultItem)) {
             return false;
         }
         $player->getFloatingInventory()->addItem($resultItem);
     }
     return true;
 }
示例#18
0
 /**
  * Send a PopUp, but takes care of checking if there are some
  * plugins that might cause issues.
  *
  * Currently only supports SimpleAuth and BasicHUD.
  *
  * @param Player $player
  * @param str $msg
  */
 public static function sendPopup($player, $msg)
 {
     $pm = $player->getServer()->getPluginManager();
     if (($sa = $pm->getPlugin("SimpleAuth")) !== null) {
         // SimpleAuth also has a HUD when not logged in...
         if ($sa->isEnabled() && !$sa->isPlayerAuthenticated($player)) {
             return;
         }
     }
     if (($hud = $pm->getPlugin("BasicHUD")) !== null) {
         // Send pop-ups through BasicHUD
         $hud->sendPopup($player, $msg);
         return;
     }
     $player->sendPopup($msg);
 }
示例#19
0
 public function open(Player $who)
 {
     $who->getServer()->getPluginManager()->callEvent($ev = new InventoryOpenEvent($this, $who));
     if ($ev->isCancelled()) {
         return \false;
     }
     $this->onOpen($who);
     return \true;
 }
示例#20
0
 /**
  *
  * @param GameLevelModel $lv        	
  * @param Player $player        	
  * @return boolean
  */
 public function portalEnter(HungerGamesPlugIn $plugin, GameLevelModel $lv, Player $player)
 {
     if ($player->getLevel()->getName() != $lv->levelName) {
         return true;
     }
     if ($lv->insideLevelEntracePortal($player->getPosition())) {
         if (!isset($this->joinedPlayers[$player->getName()])) {
             if ($plugin->storyenforceaccess && $lv->type != 1) {
                 $w = $plugin->storyManager->hasPlayerWonLevel($player->getName(), $lv->type - 1);
                 if (!$w) {
                     $player->sendMessage(TextFormat::RED . "[HG Story Mode Enabled]");
                     $player->sendMessage(TextFormat::YELLOW . "Required " . TextFormat::GOLD . "WIN " . TextFormat::YELLOW . "previous level before play this level!");
                     $player->getLevel()->addSound(new LaunchSound($player->getPosition()), array($player));
                     if ($player->isOp()) {
                         $player->sendMessage(TextFormat::AQUA . "[Admin BY-PASS Story Mode Checking]");
                     } else {
                         $player->teleport($lv->enterpos);
                         return;
                     }
                 }
             }
             $this->joinedPlayers[$player->getName()] = $player;
             $message = TextFormat::GRAY . "[HG] [" . TextFormat::AQUA . $player->getName() . TextFormat::GRAY . "] joined " . $lv->displayName . " [" . TextFormat::GREEN . count($lv->joinedPlayers) . TextFormat::GRAY . " |" . TextFormat::WHITE . "minimal " . TextFormat::YELLOW . $lv->minPlayers . TextFormat::GRAY . "]";
             $player->getServer()->broadcastMessage($message, $this->joinedPlayers);
             $lv->level->addSound(new DoorSound($player->getPosition()), $lv->joinedPlayers);
             $effect = MagicUtil::addEffect($player, Effect::STRENGTH);
             if ($effect != null) {
                 $this->playersWithEffects[$player->getName()] = $effect;
             }
             if (!$player->isOp()) {
                 if (!$player->isSurvival()) {
                     $player->setGamemode(Player::SURVIVAL);
                 }
             }
             $player->sendMessage(TextFormat::YELLOW . "[HG] Please wait here");
             $player->sendMessage(TextFormat::GRAY . "[HG] The game auto start with minimal players");
         }
     } else {
         if (isset($this->joinedPlayers[$player->getName()])) {
             $message = TextFormat::GRAY . "[ " . $player->getName() . " ] left " . $lv->displayName;
             $player->getServer()->broadcastMessage($message, $this->joinedPlayers);
             $lv->level->addSound(new DoorSound($player), $lv->joinedPlayers);
             unset($this->joinedPlayers[$player->getName()]);
             if (count($this->joinedPlayers) < $lv->minPlayers) {
                 $lv->joinDownCounter = $lv->joinDownCounterReset;
             }
             foreach ($plugin->arenaManager->arenas as &$arena) {
                 if ($arena instanceof MapArenaModel) {
                     if (isset($arena->votedPlayers[$player->getName()])) {
                         unset($arena->votedPlayers[$player->getName()]);
                         if ($arena->vote >= 1) {
                             $arena->vote--;
                         }
                         break;
                     }
                 }
             }
             if (isset($this->playersWithEffects[$player->getName()])) {
                 $effect = $this->playersWithEffects[$player->getName()];
                 if ($effect != null) {
                     $player->removeEffect($effect->getId());
                     unset($this->playersWithEffects[$player->getName()]);
                 }
             }
         }
     }
 }
示例#21
0
 public static function isLevelLoaded(Player $player, $levelhome)
 {
     $level = null;
     if (!$player->getServer()->isLevelGenerated($levelhome)) {
         $player->sendMessage("unable to find world name [" . $levelhome . "]");
         return null;
     }
     if (!$player->getServer()->isLevelLoaded($levelhome)) {
         $player->getServer()->loadLevel($levelhome);
     }
     if ($player->getServer()->isLevelLoaded($levelhome)) {
         $player->sendMessage("level loaded -" . $levelhome);
         $level = $player->getServer()->getLevelByName($levelhome);
         if ($level == null) {
             $player->sendMessage("level not found: " . $levelhome);
             return null;
         }
     }
     return $level;
 }
示例#22
0
 /**
  *
  * @param Player $player        	
  */
 public function handlePlayerInGameChat(Player $player, $msg)
 {
     $playerInGame = false;
     $InGamePlayers = [];
     $this->plugin->log(" handlePlayerInGameChat - | " . $player->getName() . "| msg: " . $msg);
     if (!empty($player) && !empty($msg)) {
         foreach ($this->plugin->gameLevelManager->levels as &$lv) {
             if ($lv instanceof GameLevelModel) {
                 if (isset($lv->joinedPlayers[$player->getName()])) {
                     $msg = TextFormat::GRAY . "[HG-" . TextFormat::RED . $lv->type . TextFormat::GRAY . "]" . TextFormat::YELLOW . $player->getName() . ">" . TextFormat::WHITE . $msg;
                     $player->getServer()->broadcastMessage($msg, $lv->joinedPlayers);
                     $playerInGame = true;
                     $this->plugin->log(" handlePlayerInGameChat - in-game-message " . $msg . " send to " . count($lv->joinedPlayers));
                 }
                 if (count($lv->joinedPlayers) > 0) {
                     $InGamePlayers = array_merge($lv->joinedPlayers, $InGamePlayers);
                 }
             }
         }
         if (!$playerInGame) {
             $broadcastplayers = array_diff($this->plugin->getServer()->getOnlinePlayers(), $InGamePlayers);
             $player->getServer()->broadcastMessage($msg, $broadcastplayers);
             $this->plugin->log(" handlePlayerInGameChat - not-in-game-message " . $msg . " send to " . count($broadcastplayers));
         }
     }
 }
示例#23
0
 /**
  * @param Player $source
  * @return bool
  *
  * Handles transaction execution. Returns whether transaction was successful or not.
  */
 public function execute(Player $source) : bool
 {
     if ($this->getInventory()->processSlotChange($this)) {
         //This means that the transaction should be handled the normal way
         if (!$source->getServer()->getAllowInvCheats() and !$source->isCreative()) {
             $change = $this->getChange();
             if ($change === null) {
                 //No changes to make, ignore this transaction
                 return true;
             }
             /* Verify that we have the required items */
             if ($change["out"] instanceof Item) {
                 if (!$this->getInventory()->slotContains($this->getSlot(), $change["out"])) {
                     return false;
                 }
             }
             if ($change["in"] instanceof Item) {
                 if (!$source->getFloatingInventory()->contains($change["in"])) {
                     return false;
                 }
             }
             /* All checks passed, make changes to floating inventory
              * This will not be reached unless all requirements are met */
             if ($change["out"] instanceof Item) {
                 $source->getFloatingInventory()->addItem($change["out"]);
             }
             if ($change["in"] instanceof Item) {
                 $source->getFloatingInventory()->removeItem($change["in"]);
             }
         }
         $this->getInventory()->setItem($this->getSlot(), $this->getTargetItem(), false);
     }
     /* Process transaction achievements, like getting iron from a furnace */
     foreach ($this->achievements as $achievement) {
         $source->awardAchievement($achievement);
     }
     return true;
 }
示例#24
0
 public function setGamemode(Player $player, $gm)
 {
     if ($gm < 0 or $gm > 3 or $player->gamemode === $gm) {
         return \false;
     }
     $player->getServer()->getPluginManager()->callEvent($ev = new PlayerGameModeChangeEvent($player, (int) $gm));
     if ($ev->isCancelled()) {
         return false;
     }
     if (($player->gamemode & 0x1) === ($gm & 0x1)) {
         $player->gamemode = $gm;
         $player->sendMessage(TextFormat::DARK_AQUA . "게임모드가 변경되었습니다, " . Server::getGamemodeString($player->getGamemode()) . ".\n");
     } else {
         $player->gamemode = $gm;
         $player->sendMessage(TextFormat::DARK_AQUA . "게임모드가 변경되었습니다, " . Server::getGamemodeString($player->getGamemode()) . ".\n");
         $player->getInventory()->clearAll();
         $player->getInventory()->sendContents($player->getViewers());
         $player->getInventory()->sendHeldItem($player->getViewers());
     }
     $player->namedtag->playerGameType = new Int("playerGameType", $player->gamemode);
     $player->sendMessage(TextFormat::DARK_AQUA . "새 게임모드 적용을 위해 서버에서 킥처리됩니다.");
     $this->getServer()->getScheduler()->scheduleDelayedTask(new CallbackTask([$this, "Kick"], [$player]), 50);
     return true;
 }
示例#25
0
文件: MapPortal.php 项目: robozeri/SG
 public static final function teleportToMap($levelname, Player $player)
 {
     if (!$player->getServer()->isLevelLoaded($levelname)) {
         $ret = $player->getServer()->loadLevel($levelname);
         if (!$ret) {
             $player->sendMessage("[HG]Error, unable load World: " . $levelname);
             return;
         }
     }
     if (!$player->getServer()->isLevelGenerated($levelname)) {
         $player->sendMessage("[HG] world generation is not ready! try later.");
         return;
     }
     $level = $player->getServer()->getLevelByName($levelname);
     if (is_null($level)) {
         $player->sendMessage("[HG] Error, unable access world: " . $levelname);
         return;
     }
     $player->getLevel()->updateAllLight($player->getPosition());
     $player->getLevel()->updateAround($player->getPosition());
     $player->teleport($level->getSafeSpawn());
 }
示例#26
0
 public function onActivate(Item $item, Player $player = null)
 {
     //@author iTX. rewrite @Dog194
     $tile = $this->getLevel()->getTile($this);
     if (!$tile instanceof TileCauldron) {
         return false;
     }
     switch ($item->getId()) {
         case Item::BUCKET:
             if ($item->getDamage() === 0) {
                 //empty bucket
                 if (!$this->isFull() or $tile->isCustomColor() or $tile->hasPotion()) {
                     break;
                 }
                 $bucket = clone $item;
                 $bucket->setDamage(8);
                 //water bucket
                 Server::getInstance()->getPluginManager()->callEvent($ev = new PlayerBucketFillEvent($player, $this, 0, $item, $bucket));
                 if (!$ev->isCancelled()) {
                     if ($player->isSurvival()) {
                         $player->getInventory()->setItemInHand($ev->getItem());
                     }
                     $this->meta = 0;
                     //empty
                     $this->getLevel()->setBlock($this, $this, true);
                     $tile->clearCustomColor();
                     $this->getLevel()->addSound(new SplashSound($this->add(0.5, 1, 0.5)));
                 }
             } elseif ($item->getDamage() === 8) {
                 //water bucket
                 if ($this->isFull() and !$tile->isCustomColor() and !$tile->hasPotion()) {
                     break;
                 }
                 $bucket = clone $item;
                 $bucket->setDamage(0);
                 //empty bucket
                 Server::getInstance()->getPluginManager()->callEvent($ev = new PlayerBucketEmptyEvent($player, $this, 0, $item, $bucket));
                 if (!$ev->isCancelled()) {
                     if ($player->isSurvival()) {
                         $player->getInventory()->setItemInHand($ev->getItem());
                     }
                     if ($tile->hasPotion()) {
                         //if has potion
                         $this->meta = 0;
                         //empty
                         $tile->setPotionId(0xffff);
                         //reset potion
                         $tile->setSplashPotion(false);
                         $tile->clearCustomColor();
                         $this->getLevel()->setBlock($this, $this, true);
                         $this->getLevel()->addSound(new ExplodeSound($this->add(0.5, 0, 0.5)));
                     } else {
                         $this->meta = 6;
                         //fill
                         $tile->clearCustomColor();
                         $this->getLevel()->setBlock($this, $this, true);
                         $this->getLevel()->addSound(new SplashSound($this->add(0.5, 1, 0.5)));
                     }
                     $this->update();
                 }
             }
             break;
         case Item::DYE:
             if ($tile->hasPotion()) {
                 break;
             }
             $color = Color::getDyeColor($item->getDamage());
             if ($tile->isCustomColor()) {
                 $color = Color::averageColor($color, $tile->getCustomColor());
             }
             if ($player->isSurvival()) {
                 $item->setCount($item->getCount() - 1);
                 /*if($item->getCount() <= 0){
                 			$player->getInventory()->setItemInHand(Item::get(Item::AIR));
                 		}*/
             }
             $tile->setCustomColor($color);
             $this->getLevel()->addSound(new SplashSound($this->add(0.5, 1, 0.5)));
             $this->update();
             break;
         case Item::LEATHER_CAP:
         case Item::LEATHER_TUNIC:
         case Item::LEATHER_PANTS:
         case Item::LEATHER_BOOTS:
             if ($this->isEmpty()) {
                 break;
             }
             if ($tile->isCustomColor()) {
                 --$this->meta;
                 $this->getLevel()->setBlock($this, $this, true);
                 $newItem = clone $item;
                 /** @var Armor $newItem */
                 $newItem->setCustomColor($tile->getCustomColor());
                 $player->getInventory()->setItemInHand($newItem);
                 $this->getLevel()->addSound(new SplashSound($this->add(0.5, 1, 0.5)));
                 if ($this->isEmpty()) {
                     $tile->clearCustomColor();
                 }
             } else {
                 --$this->meta;
                 $this->getLevel()->setBlock($this, $this, true);
                 $newItem = clone $item;
                 /** @var Armor $newItem */
                 $newItem->clearCustomColor();
                 $player->getInventory()->setItemInHand($newItem);
                 $this->getLevel()->addSound(new SplashSound($this->add(0.5, 1, 0.5)));
             }
             break;
         case Item::POTION:
         case Item::SPLASH_POTION:
             if (!$this->isEmpty() and ($tile->getPotionId() !== $item->getDamage() and $item->getDamage() !== Potion::WATER_BOTTLE or $item->getId() === Item::POTION and $tile->getSplashPotion() or $item->getId() === Item::SPLASH_POTION and !$tile->getSplashPotion() and $item->getDamage() !== 0 or $item->getDamage() === Potion::WATER_BOTTLE and $tile->hasPotion())) {
                 //long...
                 $this->meta = 0x0;
                 $this->getLevel()->setBlock($this, $this, true);
                 $tile->setPotionId(0xffff);
                 //reset
                 $tile->setSplashPotion(false);
                 $tile->clearCustomColor();
                 if ($player->isSurvival()) {
                     $player->getInventory()->setItemInHand(Item::get(Item::GLASS_BOTTLE));
                 }
                 $this->getLevel()->addSound(new ExplodeSound($this->add(0.5, 0, 0.5)));
             } elseif ($item->getDamage() === Potion::WATER_BOTTLE) {
                 //水瓶 喷溅型水瓶
                 $this->meta += 2;
                 if ($this->meta > 0x6) {
                     $this->meta = 0x6;
                 }
                 $this->getLevel()->setBlock($this, $this, true);
                 if ($player->isSurvival()) {
                     $player->getInventory()->setItemInHand(Item::get(Item::GLASS_BOTTLE));
                 }
                 $tile->setPotionId(0xffff);
                 $tile->setSplashPotion(false);
                 $tile->clearCustomColor();
                 $this->getLevel()->addSound(new SplashSound($this->add(0.5, 1, 0.5)));
             } elseif (!$this->isFull()) {
                 $this->meta += 2;
                 if ($this->meta > 0x6) {
                     $this->meta = 0x6;
                 }
                 $tile->setPotionId($item->getDamage());
                 $tile->setSplashPotion($item->getId() === Item::SPLASH_POTION);
                 $tile->clearCustomColor();
                 $this->getLevel()->setBlock($this, $this, true);
                 if ($player->isSurvival()) {
                     $player->getInventory()->setItemInHand(Item::get(Item::GLASS_BOTTLE));
                 }
                 $color = Potion::getColor($item->getDamage());
                 $this->getLevel()->addSound(new SpellSound($this->add(0.5, 1, 0.5), $color[0], $color[1], $color[2]));
             }
             break;
         case Item::GLASS_BOTTLE:
             $player->getServer()->getPluginManager()->callEvent($ev = new PlayerGlassBottleEvent($player, $this, $item));
             if ($ev->isCancelled()) {
                 return false;
             }
             if ($this->meta < 2) {
                 break;
             }
             if ($tile->hasPotion()) {
                 $this->meta -= 2;
                 if ($tile->getSplashPotion() === true) {
                     $result = Item::get(Item::SPLASH_POTION, $tile->getPotionId());
                 } else {
                     $result = Item::get(Item::POTION, $tile->getPotionId());
                 }
                 if ($this->isEmpty()) {
                     $tile->setPotionId(0xffff);
                     //reset
                     $tile->setSplashPotion(false);
                     $tile->clearCustomColor();
                 }
                 $this->getLevel()->setBlock($this, $this, true);
                 $this->addItem($item, $player, $result);
                 $color = Potion::getColor($result->getDamage());
                 $this->getLevel()->addSound(new SpellSound($this->add(0.5, 1, 0.5), $color[0], $color[1], $color[2]));
             } else {
                 $this->meta -= 2;
                 $this->getLevel()->setBlock($this, $this, true);
                 if ($player->isSurvival()) {
                     $result = Item::get(Item::POTION, Potion::WATER_BOTTLE);
                     $this->addItem($item, $player, $result);
                 }
                 $this->getLevel()->addSound(new GraySplashSound($this->add(0.5, 1, 0.5)));
             }
             break;
     }
     return true;
 }
示例#27
-1
 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     $targetBlock = Block::get($this->meta);
     if ($targetBlock instanceof Air) {
         if ($target instanceof Liquid and $target->getDamage() === 0) {
             $result = clone $this;
             $result->setDamage($target->getId());
             $player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketFillEvent($player, $block, $face, $this, $result));
             if (!$ev->isCancelled()) {
                 $player->getLevel()->setBlock($target, new Air(), true, true);
                 if ($player->isSurvival()) {
                     $player->getInventory()->setItemInHand($ev->getItem(), $player);
                 }
                 return true;
             } else {
                 $player->getInventory()->sendContents($player);
             }
         }
     } elseif ($targetBlock instanceof Liquid) {
         $result = clone $this;
         $result->setDamage(0);
         $player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketFillEvent($player, $block, $face, $this, $result));
         if (!$ev->isCancelled()) {
             $player->getLevel()->setBlock($block, $targetBlock, true, true);
             if ($player->isSurvival()) {
                 $player->getInventory()->setItemInHand($ev->getItem(), $player);
             }
             return true;
         } else {
             $player->getInventory()->sendContents($player);
         }
     }
     return false;
 }
示例#28
-1
 /**
  * Chat a message as a given player
  *
  * @param Player|CommandSender $sender - Entity to impersonate
  * @param str[]|str $msg - messages to send
  */
 public static function chat($sender, $msgs)
 {
     if (!is_array($msgs)) {
         $msgs = [$msg];
     }
     foreach ($msgs as $msg) {
         $sender->getServer()->getPluginManager()->callEvent($ev = new PlayerChatEvent($sender, $msg));
         if ($ev->isCancelled()) {
             continue;
         }
         if (MPMU::apiVersion("1.12.0")) {
             $s = $sender->getServer();
             $s->broadcastMessage($s->getLanguage()->translateString($ev->getFormat(), [$ev->getPlayer()->getDisplayName(), $ev->getMessage()]), $ev->getRecipients());
         } else {
             $sender->getServer()->broadcastMessage(sprintf($ev->getFormat(), $ev->getPlayer()->getDisplayName(), $ev->getMessage()), $ev->getRecipients());
         }
     }
 }
示例#29
-1
 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if ($target->getId() === Block::OBSIDIAN and $player->getServer()->netherEnabled) {
         //黑曜石 4*5最小 23*23最大
         //$level->setBlock($block, new Fire(), true);
         $tx = $target->getX();
         $ty = $target->getY();
         $tz = $target->getZ();
         //x方向
         $x_max = $tx;
         //x最大值
         $x_min = $tx;
         //x最小值
         for ($x = $tx + 1; $level->getBlock($this->temporalVector->setComponents($x, $ty, $tz))->getId() == Block::OBSIDIAN; $x++) {
             $x_max++;
         }
         for ($x = $tx - 1; $level->getBlock($this->temporalVector->setComponents($x, $ty, $tz))->getId() == Block::OBSIDIAN; $x--) {
             $x_min--;
         }
         $count_x = $x_max - $x_min + 1;
         //x方向方块
         if ($count_x >= 4 and $count_x <= 23) {
             //4 23
             $x_max_y = $ty;
             //x最大值时的y最大值
             $x_min_y = $ty;
             //x最小值时的y最大值
             for ($y = $ty; $level->getBlock($this->temporalVector->setComponents($x_max, $y, $tz))->getId() == Block::OBSIDIAN; $y++) {
                 $x_max_y++;
             }
             for ($y = $ty; $level->getBlock($this->temporalVector->setComponents($x_min, $y, $tz))->getId() == Block::OBSIDIAN; $y++) {
                 $x_min_y++;
             }
             $y_max = min($x_max_y, $x_min_y) - 1;
             //y最大值
             $count_y = $y_max - $ty + 2;
             //方向方块
             //Server::getInstance()->broadcastMessage("$y_max $x_max_y $x_min_y $x_max $x_min");
             if ($count_y >= 5 and $count_y <= 23) {
                 //5 23
                 $count_up = 0;
                 //上面
                 for ($ux = $x_min; $level->getBlock($this->temporalVector->setComponents($ux, $y_max, $tz))->getId() == Block::OBSIDIAN and $ux <= $x_max; $ux++) {
                     $count_up++;
                 }
                 //Server::getInstance()->broadcastMessage("$count_up $count_x");
                 if ($count_up == $count_x) {
                     for ($px = $x_min + 1; $px < $x_max; $px++) {
                         for ($py = $ty + 1; $py < $y_max; $py++) {
                             $level->setBlock($this->temporalVector->setComponents($px, $py, $tz), new Portal());
                         }
                     }
                     if ($player->isSurvival()) {
                         $this->useOn($block, 2);
                         $player->getInventory()->setItemInHand($this);
                     }
                     return true;
                 }
             }
         }
         //z方向
         $z_max = $tz;
         //z最大值
         $z_min = $tz;
         //z最小值
         $count_z = 0;
         //z方向方块
         for ($z = $tz + 1; $level->getBlock($this->temporalVector->setComponents($tx, $ty, $z))->getId() == Block::OBSIDIAN; $z++) {
             $z_max++;
         }
         for ($z = $tz - 1; $level->getBlock($this->temporalVector->setComponents($tx, $ty, $z))->getId() == Block::OBSIDIAN; $z--) {
             $z_min--;
         }
         $count_z = $z_max - $z_min + 1;
         if ($count_z >= 4 and $count_z <= 23) {
             //4 23
             $z_max_y = $ty;
             //z最大值时的y最大值
             $z_min_y = $ty;
             //z最小值时的y最大值
             for ($y = $ty; $level->getBlock($this->temporalVector->setComponents($tx, $y, $z_max))->getId() == Block::OBSIDIAN; $y++) {
                 $z_max_y++;
             }
             for ($y = $ty; $level->getBlock($this->temporalVector->setComponents($tx, $y, $z_min))->getId() == Block::OBSIDIAN; $y++) {
                 $z_min_y++;
             }
             $y_max = min($z_max_y, $z_min_y) - 1;
             //y最大值
             $count_y = $y_max - $ty + 2;
             //方向方块
             if ($count_y >= 5 and $count_y <= 23) {
                 //5 23
                 $count_up = 0;
                 //上面
                 for ($uz = $z_min; $level->getBlock($this->temporalVector->setComponents($tx, $y_max, $uz))->getId() == Block::OBSIDIAN and $uz <= $z_max; $uz++) {
                     $count_up++;
                 }
                 //Server::getInstance()->broadcastMessage("$count_up $count_z");
                 if ($count_up == $count_z) {
                     for ($pz = $z_min + 1; $pz < $z_max; $pz++) {
                         for ($py = $ty + 1; $py < $y_max; $py++) {
                             $level->setBlock($this->temporalVector->setComponents($tx, $py, $pz), new Portal());
                         }
                     }
                     if ($player->isSurvival()) {
                         $this->useOn($block, 2);
                         $player->getInventory()->setItemInHand($this);
                     }
                     return true;
                 }
             }
         }
         //return true;
     }
     if ($block->getId() === self::AIR and $target instanceof Solid) {
         $level->setBlock($block, new Fire(), true);
         /** @var Fire $block */
         $block = $level->getBlock($block);
         if ($block->getSide(Vector3::SIDE_DOWN)->isTopFacingSurfaceSolid() or $block->canNeighborBurn()) {
             $level->scheduleUpdate($block, $block->getTickRate() + mt_rand(0, 10));
             //	return true;
         }
         if ($player->isSurvival()) {
             $this->useOn($block, 2);
             //耐久跟报废分别写在 tool 跟 level 了
             $player->getInventory()->setItemInHand($this);
         }
         return true;
     }
     return false;
 }
示例#30
-2
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($player instanceof Player) {
         $this->meta = ((int) $player->getDirection() + 5) % 4;
     }
     $this->getLevel()->setBlock($block, $this, true, true);
     if ($player != null) {
         $level = $this->getLevel();
         if ($player->getServer()->allowSnowGolem) {
             $block0 = $level->getBlock($block->add(0, -1, 0));
             $block1 = $level->getBlock($block->add(0, -2, 0));
             if ($block0->getId() == Item::SNOW_BLOCK and $block1->getId() == Item::SNOW_BLOCK) {
                 $level->setBlock($block, new Air());
                 $level->setBlock($block0, new Air());
                 $level->setBlock($block1, new Air());
                 $golem = new SnowGolem($player->getLevel()->getChunk($this->getX() >> 4, $this->getZ() >> 4), new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)])]));
                 $golem->spawnToAll();
             }
         }
         if ($player->getServer()->allowIronGolem) {
             $block0 = $level->getBlock($block->add(0, -1, 0));
             $block1 = $level->getBlock($block->add(0, -2, 0));
             $block2 = $level->getBlock($block->add(-1, -1, 0));
             $block3 = $level->getBlock($block->add(1, -1, 0));
             $block4 = $level->getBlock($block->add(0, -1, -1));
             $block5 = $level->getBlock($block->add(0, -1, 1));
             if ($block0->getId() == Item::IRON_BLOCK and $block1->getId() == Item::IRON_BLOCK) {
                 if ($block2->getId() == Item::IRON_BLOCK and $block3->getId() == Item::IRON_BLOCK and $block4->getId() == Item::AIR and $block5->getId() == Item::AIR) {
                     $level->setBlock($block2, new Air());
                     $level->setBlock($block3, new Air());
                 } elseif ($block4->getId() == Item::IRON_BLOCK and $block5->getId() == Item::IRON_BLOCK and $block2->getId() == Item::AIR and $block3->getId() == Item::AIR) {
                     $level->setBlock($block4, new Air());
                     $level->setBlock($block5, new Air());
                 } else {
                     return;
                 }
                 $level->setBlock($block, new Air());
                 $level->setBlock($block0, new Air());
                 $level->setBlock($block1, new Air());
                 $golem = new IronGolem($player->getLevel()->getChunk($this->getX() >> 4, $this->getZ() >> 4), new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)])]));
                 $golem->spawnToAll();
             }
         }
     }
     return true;
 }