Inheritance: extends EntityEvent, implements pocketmine\event\Cancellable
示例#1
0
 /**
  * @priority HIGHEST
  */
 public function levelChg(EntityLevelChangeEvent $ev)
 {
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     if ($ev->isCancelled()) {
         return;
     }
     $player = $ev->getEntity();
     if (!$player instanceof Player) {
         return;
     }
     if ($player->isCreative()) {
         return;
     }
     if ($player->hasPermission("liab.keep")) {
         return;
     }
     if (!$this->saveInventory($player, $ev->getOrigin())) {
         return;
     }
     $player->getInventory()->clearAll();
     if (!$this->loadInventory($player, $ev->getTarget())) {
         return;
     }
 }
示例#2
0
 /**
  * @param EntityLevelChangeEvent $event
  * @priority LOWEST
  */
 public function onLevelChange(EntityLevelChangeEvent $event)
 {
     $player = $event->getEntity();
     if ($player instanceof Player) {
         $this->plugin->updatePermissions($player);
     }
 }
示例#3
0
 public function onLevelChange(EntityLevelChangeEvent $event)
 {
     $player = $event->getEntity();
     $level = $event->getTarget();
     if ($player instanceof Player) {
         $this->plugin->setPermissions($level, $player);
     }
 }
示例#4
0
 /**
  * @param EntityLevelChangeEvent $event
  */
 public function onPlayerLevelChange(EntityLevelChangeEvent $event)
 {
     if ($event->getEntity() instanceof Player and isset($this->blockMans[spl_object_hash($event->getEntity())])) {
         /** @var $player Player */
         $player = $event->getEntity();
         $this->despawnBlockMan($player);
     }
 }
示例#5
0
 /**
  * @param EntityLevelChangeEvent $event
  * @priority LOWEST
  */
 public function onLevelChange(EntityLevelChangeEvent $event)
 {
     $player = $event->getEntity();
     $isMultiWorldPermsEnabled = $this->plugin->getConfigValue("enable-multiworld-perms");
     $levelName = $isMultiWorldPermsEnabled ? $event->getTarget()->getName() : null;
     if ($player instanceof Player) {
         $this->plugin->updatePermissions($player, $levelName);
     }
 }
示例#6
0
 protected function switchLevel(Level $targetLevel)
 {
     if ($this->isValid()) {
         $this->server->getPluginManager()->callEvent($ev = new EntityLevelChangeEvent($this, $this->level, $targetLevel));
         if ($ev->isCancelled()) {
             return false;
         }
         $this->level->removeEntity($this);
         if ($this->chunk !== null) {
             $this->chunk->removeEntity($this);
         }
         $this->despawnFromAll();
         if ($this instanceof Player) {
             foreach ($this->usedChunks as $index => $d) {
                 if (PHP_INT_SIZE === 8) {
                     $X = $index >> 32 << 32 >> 32;
                     $Z = ($index & 4294967295.0) << 32 >> 32;
                 } else {
                     list($X, $Z) = explode(":", $index);
                     $X = (int) $X;
                     $Z = (int) $Z;
                 }
                 $this->unloadChunk($X, $Z);
             }
         }
     }
     $this->setLevel($targetLevel);
     $this->level->addEntity($this);
     if ($this instanceof Player) {
         $this->usedChunks = [];
         $pk = new SetTimePacket();
         $pk->time = $this->level->getTime();
         $pk->started = $this->level->stopTime == false;
         $this->dataPacket($pk);
     }
     $this->chunk = null;
     return true;
 }
示例#7
0
 public function onLevelChange(EntityLevelChangeEvent $ev)
 {
     if (!$this->auto) {
         return;
     }
     $pl = $ev->getEntity();
     if (!$pl instanceof Player) {
         return;
     }
     $level = $ev->getTarget()->getName();
     $this->showMotd($pl, $level);
 }
示例#8
0
 public function onLevelChange(EntityLevelChangeEvent $event)
 {
     if ($event->getEntity() instanceof Player and $event->getTarget()->getName() == $this->getConfig()->get('aworld')) {
         foreach ($this->getServer()->getLevelByName($this->getConfig()->get('aworld'))->getPlayers() as $p) {
             $p->sendMessage("A player joined the game!");
             $playersleft = $this->getConfig()->get('neededplayers') - $this->aplayers;
             $p->sendMessage("Players left untill the game begin: " . $playersleft);
         }
     }
 }
示例#9
0
 protected function switchLevel(Level $targetLevel)
 {
     if ($this->closed) {
         return false;
     }
     if ($this->isValid()) {
         $this->server->getPluginManager()->callEvent($ev = new EntityLevelChangeEvent($this, $this->level, $targetLevel));
         if ($ev->isCancelled()) {
             return false;
         }
         $this->level->removeEntity($this);
         if ($this->chunk !== null) {
             $this->chunk->removeEntity($this);
         }
         $this->despawnFromAll();
     }
     $this->setLevel($targetLevel);
     $this->level->addEntity($this);
     $this->chunk = null;
     return true;
 }
示例#10
0
 protected function switchLevel(Level $targetLevel)
 {
     if ($this->isValid()) {
         $this->server->getPluginManager()->callEvent($ev = new EntityLevelChangeEvent($this, $this->level, $targetLevel));
         if ($ev->isCancelled()) {
             return false;
         }
         $this->level->removeEntity($this);
         if ($this->chunk !== null) {
             $this->chunk->removeEntity($this);
         }
         $this->despawnFromAll();
         if ($this instanceof Player) {
             foreach ($this->usedChunks as $index => $d) {
                 Level::getXZ($index, $X, $Z);
                 $this->unloadChunk($X, $Z);
             }
         }
     }
     $this->setLevel($targetLevel);
     $this->level->addEntity($this);
     if ($this instanceof Player) {
         $this->usedChunks = [];
         $pk = new SetTimePacket();
         $pk->time = $this->level->getTime();
         $pk->started = $this->level->stopTime == false;
         $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
     }
     $this->chunk = null;
     return true;
 }
示例#11
0
 public function onLevelChange(EntityLevelChangeEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getEntity();
     if (!$pl instanceof Player) {
         return;
     }
     //echo $pl->getName()." Level Change\n";
     foreach ($this->getServer()->getLevels() as $lv) {
         $this->despawnPlayerCases($pl, $lv);
     }
     $this->getServer()->getScheduler()->scheduleDelayedTask(new PluginCallbackTask($this, [$this, "spawnPlayerCases"], [$pl, $ev->getTarget()]), 20);
     //$this->spawnPlayerCases($pl,$ev->getTarget());
 }
 /** 
  * @param EntityLevelChangeEvent $event 
  * @priority HIGHEST
  * @ignoreCancelled true
  */
 public function onEntityLevelChange(EntityLevelChangeEvent $event)
 {
     if (($player = $event->getEntity()) instanceof Player) {
         if ($this->plugin->getStorage()->getShield($player->getLevel())->isPlayerBanned($player)) {
             $event->setCancelled(true);
             $event->getPlayer()->sendTip($this->plugin->getConfig()->get("levelChangeNotAllowed"));
         }
     }
 }
示例#13
0
文件: Main.php 项目: Artide/DynMapPE
 public function onLevelChange(EntityLevelChangeEvent $event)
 {
     if ($event->getEntity() instanceof Player) {
         $request = "UPDATE `dynmap_players` SET `world` = '" . $event->getEntity()->getLevel()->getName() . "' ,`x` = '" . $event->getEntity()->getX() . "',`y` = '" . $event->getEntity()->getY() . "',`z` = '" . $event->getEntity()->getZ() . "',`health` = '" . $event->getEntity()->getHealth() . "',`armor` = '" . $event->getEntity()->getHealth() . "' WHERE `name` = '" . $event->getEntity()->getName() . "'";
         // added health and armor because manyworlds, fix armor!
         if (!($result = $this->database->query($request))) {
             $this->getLogger()->notice('There was an error running the query [' . $this->database->error . ']');
         }
         return;
     }
 }
示例#14
0
 /**
  * @param EntityLevelChangeEvent $event
  *
  * @priority MONITOR
  */
 public function onEntityLevelChange(EntityLevelChangeEvent $event)
 {
     $entity = $event->getEntity();
     if ($entity instanceof Player) {
         $this->getPlugin()->switchLevelVanish($entity, $event->getOrigin(), $event->getTarget());
     }
 }
示例#15
0
 public function onTeleport(EntityLevelChangeEvent $event)
 {
     $to = $event->getTarget();
     $player = $event->getEntity();
     foreach ($this->getConfig()->get("Arenas") as $arena => $g) {
         if ($to instanceof Level and $player instanceof Player) {
             if ($to->getName() === $g["world"] and $g["status"] === "in-gioco") {
                 $event->setCancelled(true);
                 $player->sendMessage(TextFormat::RED . "Partita già iniziata! Scegli un'altra arena!");
             } elseif ($to->getName() === $g["name"] and count($this->getServer()->getLevelByName($g["name"])->getPlayers()) === 8 and $g["status"] === "pieno") {
                 $event->setCancelled(true);
                 $player->sendMessage(TextFormat::RED . "Arena piena! Scegli un'altra arena!");
             } elseif ($to->getName() === $g["name"] and count($this->getServer()->getLevelByName($g["name"])->getPlayers()) < 8 and $g["status"] === "in-attesa") {
                 foreach ($this->getServer()->getLevelByName($g["world"])->getPlayers() as $p) {
                     $name = $player->getName();
                     $p->sendMessage(TextFormat::DARK_GRAY . "{$name} è entrato/a in partita!");
                 }
             }
         }
     }
 }
示例#16
0
 protected function switchLevel(Level $targetLevel)
 {
     if ($this->isValid()) {
         $this->server->getPluginManager()->callEvent($ev = new EntityLevelChangeEvent($this, $this->getLevel(), $targetLevel));
         if ($ev->isCancelled()) {
             return false;
         }
         $this->getLevel()->removeEntity($this);
         $this->chunk->removeEntity($this);
         $this->despawnFromAll();
         if ($this instanceof Player) {
             foreach ($this->usedChunks as $index => $d) {
                 $X = null;
                 $Z = null;
                 Level::getXZ($index, $X, $Z);
                 foreach ($this->getLevel()->getChunkEntities($X, $Z) as $entity) {
                     $entity->despawnFrom($this);
                 }
             }
             $this->getLevel()->freeAllChunks($this);
         }
     }
     $this->setLevel($targetLevel, $this instanceof Player ? true : false);
     //Hard reference
     $this->getLevel()->addEntity($this);
     if ($this instanceof Player) {
         $this->usedChunks = [];
         $pk = new SetTimePacket();
         $pk->time = $this->getLevel()->getTime();
         $pk->started = $this->getLevel()->stopTime == false;
         $this->dataPacket($pk);
     }
     $this->chunk = null;
     return true;
 }
示例#17
0
 public function onLevelChange(EntityLevelChangeEvent $event)
 {
     echo __METHOD__ . "," . __LINE__ . "\n";
     if ($event->isCancelled()) {
         return;
     }
     $player = $event->getEntity();
     if (!$player instanceof Player) {
         return;
     }
     if ($player->isCreative()) {
         return;
     }
     if (!$this->saveInventory($player, $event->getOrigin())) {
         return;
     }
     $player->getInventory()->clearAll();
     if (!$this->loadInventory($player, $event->getTarget())) {
         return;
     }
     $slot = $this->getConfig()->get("slot");
     $item = $this->getConfig()->get("ID");
     $damage = $this->getConfig()->get("Damage");
     $ammount = $this->getConfig()->get("Ammount");
     $level = $event->getLevel();
     $world = $this->getConfig()->get("world");
     if ($level == $world && $slot <= 35) {
         $player->getInventory()->setItem($slot, Item::get($item, $damage, $ammount));
     }
     $slot = $this->getConfig()->get("slot2");
     $item = $this->getConfig()->get("ID2");
     $damage = $this->getConfig()->get("Damage2");
     $ammount = $this->getConfig()->get("Ammount2");
     $level = $event->getLevel();
     $world = $this->getConfig()->get("world");
     if ($level == $world && $slot <= 35) {
         $player->getInventory()->setItem($slot, Item::get($item, $damage, $ammount));
     }
     $slot = $this->getConfig()->get("slot3");
     $item = $this->getConfig()->get("ID3");
     $damage = $this->getConfig()->get("Damage3");
     $ammount = $this->getConfig()->get("Ammount3");
     $level = $event->getLevel();
     $world = $this->getConfig()->get("world");
     if ($level == $world && $slot <= 35) {
         $player->getInventory()->setItem($slot, Item::get($item, $damage, $ammount));
     }
     $slot = $this->getConfig()->get("slot4");
     $item = $this->getConfig()->get("ID4");
     $damage = $this->getConfig()->get("Damage4");
     $ammount = $this->getConfig()->get("Ammount4");
     $level = $event->getLevel();
     $world = $this->getConfig()->get("world");
     if ($level == $world && $slot <= 35) {
         $player->getInventory()->setItem($slot, Item::get($item, $damage, $ammount));
     }
     $slot = $this->getConfig()->get("slot5");
     $item = $this->getConfig()->get("ID5");
     $damage = $this->getConfig()->get("Damage5");
     $ammount = $this->getConfig()->get("Ammount5");
     $level = $event->getLevel();
     $world = $this->getConfig()->get("world");
     if ($level == $world && $slot <= 35) {
         $player->getInventory()->setItem($slot, Item::get($item, $damage, $ammount));
     }
     $slot = $this->getConfig()->get("slot6");
     $item = $this->getConfig()->get("ID6");
     $damage = $this->getConfig()->get("Damage6");
     $ammount = $this->getConfig()->get("Ammount6");
     $level = $event->getLevel();
     $world = $this->getConfig()->get("world");
     if ($level == $world && $slot <= 35) {
         $player->getInventory()->setItem($slot, Item::get($item, $damage, $ammount));
     }
     $slot = $this->getConfig()->get("slot7");
     $item = $this->getConfig()->get("ID7");
     $damage = $this->getConfig()->get("Damage7");
     $ammount = $this->getConfig()->get("Ammount7");
     $level = $event->getLevel();
     $world = $this->getConfig()->get("world");
     if ($level == $world && $slot <= 35) {
         $player->getInventory()->setItem($slot, Item::get($item, $damage, $ammount));
     }
     $slot = $this->getConfig()->get("slot8");
     $item = $this->getConfig()->get("ID8");
     $damage = $this->getConfig()->get("Damage8");
     $ammount = $this->getConfig()->get("Ammount8");
     $level = $event->getLevel();
     $world = $this->getConfig()->get("world");
     if ($level == $world && $slot <= 35) {
         $player->getInventory()->setItem($slot, Item::get($item, $damage, $ammount));
     }
     $slot = $this->getConfig()->get("slot9");
     $item = $this->getConfig()->get("ID9");
     $damage = $this->getConfig()->get("Damage9");
     $ammount = $this->getConfig()->get("Ammount9");
     $level = $event->getLevel();
     $world = $this->getConfig()->get("world");
     if ($level == $world && $slot <= 35) {
         $player->getInventory()->setItem($slot, Item::get($item, $damage, $ammount));
     }
     $slot = $this->getConfig()->get("slot10");
     $item = $this->getConfig()->get("ID10");
     $damage = $this->getConfig()->get("Damage10");
     $ammount = $this->getConfig()->get("Ammount10");
     $level = $event->getLevel();
     $world = $this->getConfig()->get("world");
     if ($level == $world && $slot <= 35) {
         $player->getInventory()->setItem($slot, Item::get($item, $damage, $ammount));
     }
 }
示例#18
0
 public function onWorldChange(EntityLevelChangeEvent $event)
 {
     if ($event->getEntity() instanceof Player && isset($this->games[strtolower($event->getEntity()->getLevel()->getName())]["players"][$event->getEntity()->getName()])) {
         $this->leaveLobby($event->getEntity(), $event->getEntity()->getLevel());
     }
 }
示例#19
0
 public function onPlayerLevelChange(EntityLevelChangeEvent $event)
 {
     if ($event->getEntity() instanceof Player && isset($this->level)) {
         if ($this->playerIsInGame($event->getEntity()->getName()) !== false) {
             $event->setCancelled();
             $event->getEntity()->getLevel("[游戏系统] [躲猫猫] 抱歉 ,游戏中请输入 /lobby 离开");
         }
         /*else if(!$event->getEntity()->isOp() && $event->getEntity()->getLevel()==$this->level)
         		{
         			$event->setCancelled();
         			$event->getEntity()->getLevel("[游戏系统] [躲猫猫] 你没有权限进入游戏世界");
         		}*/
         //反正大RAM用不到
     }
 }
示例#20
0
 public function onWorldChange(EntityLevelChangeEvent $event)
 {
     $entity = $event->getEntity();
     CustomAlerts::getAPI()->setWorldChangeMessage("");
     //Check if the Entity is a Player
     if ($entity instanceof Player) {
         $player = $entity;
         $origin = $event->getOrigin();
         $target = $event->getTarget();
         //Check if Default WorldChange Message is enabled
         if (CustomAlerts::getAPI()->isDefaultWorldChangeMessageEnabled()) {
             CustomAlerts::getAPI()->setWorldChangeMessage(CustomAlerts::getAPI()->getDefaultWorldChangeMessage($player, $origin, $target));
         }
         //WorldChange Event
         $this->plugin->getServer()->getPluginManager()->callEvent(new CustomAlertsWorldChangeEvent($player, $origin, $target));
         if (CustomAlerts::getAPI()->getWorldChangeMessage() != "") {
             Server::getInstance()->broadcastMessage(CustomAlerts::getAPI()->getWorldChangeMessage());
         }
     }
 }