当前位置: 首页>>代码示例>>PHP>>正文


PHP server\DataPacketReceiveEvent类代码示例

本文整理汇总了PHP中pocketmine\event\server\DataPacketReceiveEvent的典型用法代码示例。如果您正苦于以下问题:PHP DataPacketReceiveEvent类的具体用法?PHP DataPacketReceiveEvent怎么用?PHP DataPacketReceiveEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DataPacketReceiveEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onReceivePacket

 public function onReceivePacket(DataPacketReceiveEvent $event)
 {
     $player = $event->getPlayer();
     $packet = $event->getPacket();
     if ($packet->pid() == Info::LOGIN_PACKET) {
         if ($packet->protocol1 < Info::CURRENT_PROTOCOL) {
             //Check if outdated client message is custom
             if (CustomAlerts::getAPI()->isOutdatedClientMessageCustom()) {
                 CustomAlerts::getAPI()->setOutdatedClientMessage(CustomAlerts::getAPI()->getDefaultOutdatedClientMessage($player));
             }
             //Outdated Client Kick Event
             $this->plugin->getServer()->getPluginManager()->callEvent(new CustomAlertsOutdatedClientKickEvent($player));
             //Check if Outdated Client message is not empty
             if (CustomAlerts::getAPI()->getOutdatedClientMessage() != null) {
                 $player->close("", CustomAlerts::getAPI()->getOutdatedClientMessage());
                 $event->setCancelled(true);
             }
         } elseif ($packet->protocol1 > Info::CURRENT_PROTOCOL) {
             //Check if outdated server message is custom
             if (CustomAlerts::getAPI()->isOutdatedServerMessageCustom()) {
                 CustomAlerts::getAPI()->setOutdatedServerMessage(CustomAlerts::getAPI()->getDefaultOutdatedServerMessage($player));
             }
             //Outdated Server Kick Event
             $this->plugin->getServer()->getPluginManager()->callEvent(new CustomAlertsOutdatedServerKickEvent($player));
             //Check if Outdated Server message is not empty
             if (CustomAlerts::getAPI()->getOutdatedServerMessage() != null) {
                 $player->close("", CustomAlerts::getAPI()->getOutdatedServerMessage());
                 $event->setCancelled(true);
             }
         }
     }
 }
开发者ID:xHFx,项目名称:CustomAlerts,代码行数:32,代码来源:EventListener.php

示例2: onPotionUse

 public function onPotionUse(DataPacketReceiveEvent $ev)
 {
     //TODO : Give a potion effect to player when he eats potion
     $packet = $ev->getPacket();
     if ($packet instanceof EntityEventPacket) {
     }
 }
开发者ID:Khoneki,项目名称:ToAruPotion,代码行数:7,代码来源:ToAruPotion.php

示例3: onPkt

 public function onPkt(DataPacketReceiveEvent $e)
 {
     if ($e->getPacket()->pid() !== 0x0) {
         return;
     }
     $this->lastPing[strtolower($e->getPlayer()->getName())] = Binary::readLong($e->getPacket()->buffer) / 1000.0;
 }
开发者ID:AvivShopen,项目名称:bad-plugins,代码行数:7,代码来源:Main.php

示例4: onDataPacketReceiveEvent

 public function onDataPacketReceiveEvent(DataPacketReceiveEvent $event)
 {
     $packet = $event->getPacket();
     $player = $event->getPlayer();
     if ($packet instanceof InteractPacket) {
         if ($boat instanceof Boat) {
             if ($packet->action === 1) {
                 $this->riding[$player->getName()] = $packet->target;
             } elseif ($packet->action === 3) {
                 if (isset($this->riding[$player->getName()])) {
                     unset($this->riding[$player->getName()]);
                     $this->removeWaterField($player);
                 }
             }
         }
     } elseif ($packet instanceof MovePlayerPacket) {
         if (isset($this->riding[$player->getName()])) {
             $boat = $player->getLevel()->getEntity($this->riding[$player->getName()]);
             if ($boat instanceof Boat) {
                 $x = (int) floor($boat->x);
                 $y = (int) floor($boat->y) - 1;
                 $z = (int) floor($boat->z);
                 if (isset($this->waterField[$player->getName()]["pos"]) and $this->waterField[$player->getName()]["pos"] == "{$x}:{$y}:{$z}") {
                     return;
                 }
                 $this->setWaterField($player, $x, $y, $z, $player->getLevel());
             }
         }
     }
     //
 }
开发者ID:JiangsNetworkAlpha,项目名称:FlyingBoats,代码行数:31,代码来源:EventListener.php

示例5: onDataPacketReceive

 public function onDataPacketReceive(DataPacketReceiveEvent $event)
 {
     $pk = $event->getPacket();
     if ($pk instanceof LoginPacket) {
         $pk->username = str_replace([" ", "!", "?", "-", ",", "."], "_", $pk->username);
     }
 }
开发者ID:LegionPE,项目名称:LegionPE-Eta,代码行数:7,代码来源:SessionInterface.php

示例6: onReceivePacket

 /**
  * @param DataPacketReceiveEvent $event
  * @priority LOW
  */
 public function onReceivePacket(DataPacketReceiveEvent $event)
 {
     $pk = $event->getPacket();
     if ($pk->pid() === ProtocolInfo::LOGIN_PACKET) {
         /** @var \pocketmine\network\protocol\LoginPacket $pk */
         $pk->username = $this->correctName($pk->username);
         //			var_dump($pk->username);
     }
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:13,代码来源:NameCorrector.php

示例7: onReceive

 public function onReceive(DataPacketReceiveEvent $event)
 {
     $p = $event->getPlayer();
     $pk = $event->getPacket();
     if ($pk instanceof PlayerActionPacket) {
         if ($pk->action === PlayerActionPacket::ACTION_START_BREAK) {
             $this->positions[$p->getName()] = $p->getLocation();
         }
     }
 }
开发者ID:diamond-gold,项目名称:BlockBreakClimbingFix,代码行数:10,代码来源:Main.php

示例8: onJump

 public function onJump(DataPacketReceiveEvent $event)
 {
     $packet = $event->getPacket();
     if (!$packet instanceof PlayerActionPacket) {
         return;
     }
     $player = $event->getPlayer();
     if ($packet->action === PlayerActionPacket::ACTION_JUMP && isset($this->onChair[$player->getName()])) {
         $removepk = new RemoveEntityPacket();
         $removepk->eid = $this->onChair[$player->getName()];
         $this->getServer()->broadcastPacket($this->getServer()->getOnlinePlayers(), $removepk);
         unset($this->onChair[$player->getName()]);
     }
 }
开发者ID:MrDoni98,项目名称:PmChair,代码行数:14,代码来源:PmChair.php

示例9: onPacketReceived

 public function onPacketReceived(DataPacketReceiveEvent $event)
 {
     $pk = $event->getPacket();
     $player = $event->getPlayer();
     if ($pk instanceof UseItemPacket and $pk->face === 0xff) {
         $item = $player->getInventory()->getItemInHand();
         if ($item->getId() == 369) {
             $mot = (new Random())->nextSignedFloat() * M_PI * 2;
             $tnt = Entity::createEntity("PrimedTNT", $player->getLevel()->getChunk($player->x >> 4, $player->z >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $player->x + 0.5), new Double("", $player->y), new Double("", $player->z + 0.5)]), "Motion" => new Enum("Motion", [new Double("", -sin($mot) * 0.02), new Double("", 0.2), new Double("", -cos($mot) * 0.02)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)]), "Fuse" => new Byte("Fuse", 100)]));
             $tnt->spawnToAll();
             $player->getLevel()->addSound(new AnviluseSound($player), array($player));
             return true;
         }
     }
 }
开发者ID:XxmellonxX,项目名称:MTNT1B,代码行数:15,代码来源:Tnt.php

示例10: onInteract

 public function onInteract(DataPacketReceiveEvent $event)
 {
     $packet = $event->getPacket();
     if ($event->getPacket()->pid() === Info::INTERACT_PACKET) {
         $packet = $event->getPacket();
         $player = $event->getPlayer();
         $target = $player->getLevel()->getEntity($packet->target);
         if ($target instanceof Chair) {
             $action = $packet->action;
             if ($action === 2 or $action === 3) {
                 $target->standupSittingEntity();
                 $target->close();
             }
         }
     }
 }
开发者ID:MrDoni98,项目名称:PocketMine-MP-Plugins,代码行数:16,代码来源:MainClass.php

示例11: onDataPacketReceive

 public function onDataPacketReceive(DataPacketReceiveEvent $event)
 {
     $pk = $event->getPacket();
     if ($pk->pid() !== ProtocolInfo::USE_ITEM_PACKET || $pk->face !== 0xff) {
         return false;
     }
     $p = $event->getPlayer();
     $inv = $p->getInventory();
     $i = $inv->getItemInHand();
     if (isset($this->armorTable[$id = $i->getID()])) {
         $ai = $inv->getArmorItem($type = $this->armorTable[$id]);
         $inv->setArmorItem($type, $i, $p);
         $inv->setItem($inv->getHeldItemSlot(), $ai);
         $inv->sendContents($p);
         $inv->sendArmorContents($p);
     }
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:17,代码来源:FastArmor.php

示例12: onDataPacketReceiveEvent

 public function onDataPacketReceiveEvent(DataPacketReceiveEvent $event)
 {
     if ($this->plugin->trackingOn) {
         $packet = $event->getPacket();
         // $pkId = $packet->pid();
         $class_path_ar = explode('\\', get_class($packet));
         $pkName = end($class_path_ar);
         if (isset($this->plugin->receivedPackets[$pkName])) {
             $this->plugin->receivedPackets[$pkName]++;
         } else {
             $this->plugin->receivedPackets[$pkName] = 1;
         }
     }
     /*
      if(isset($this->plugin->receivedPackets[$pkId])) {
         $this->plugin->receivedPackets[$pkId]++;
     } else {
         $this->plugin->receivedPackets[$pkId] = 1;
     }
     */
 }
开发者ID:dishrex,项目名称:PacketTracker,代码行数:21,代码来源:EventListener.php

示例13: onDataPacketReceive

 public function onDataPacketReceive(DataPacketReceiveEvent $event)
 {
     $pk = $event->getPacket();
     if ($pk->pid() !== ProtocolInfo::USE_ITEM_PACKET || $pk->face !== 0xff) {
         return false;
     }
     $p = $event->getPlayer();
     $inv = $p->getInventory();
     $i = $inv->getItemInHand();
     if ($i->getID() == 262) {
         $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $p->x), new Double("", $p->y + $p->getEyeHeight()), new Double("", $p->z)]), "Motion" => new Enum("Motion", [new Double("", -sin($p->getyaw() / 180 * M_PI) * cos($p->getPitch() / 180 * M_PI)), new Double("", -sin($p->getPitch() / 180 * M_PI)), new Double("", cos($p->getyaw() / 180 * M_PI) * cos($p->getPitch() / 180 * M_PI))]), "Rotation" => new Enum("Rotation", [new Float("", $p->getyaw()), new Float("", $p->getPitch())])]);
         $arrow = new Arrow($p->chunk, $nbt, $p);
         $ev = new EntityShootBowEvent($p, Item::get(264, 0, 0), $arrow, 1.5);
         $this->getServer(0)->getPluginManager()->callEvent($ev);
         if ($ev->isCancelled()) {
             $arrow->kill();
         } else {
             $i->setCount($i->getCount() - 1);
             $inv->setItem($inv->getHeldItemSlot(), $i);
             $arrow->spawnToAll();
         }
     }
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:23,代码来源:ArrowShot.php

示例14: onPacketReceived

 public function onPacketReceived(DataPacketReceiveEvent $event)
 {
     $pk = $event->getPacket();
     if ($pk instanceof InteractPacket) {
         if (isset($this->npc[$pk->target])) {
             if (isset($this->msgQueue[$event->getPlayer()->getName()])) {
                 $npc = $this->npc[$pk->target];
                 $npc->setMessage($this->msgQueue[$event->getPlayer()->getName()]);
                 unset($this->msgQueue[$event->getPlayer()->getName()]);
                 $event->getPlayer()->sendMessage("You have set NPC " . TextFormat::AQUA . $npc->getName() . TextFormat::WHITE . " to say " . TextFormat::GREEN . $npc->getMessage());
                 return;
             } else {
                 $this->npc[$pk->target]->onInteract($event->getPlayer());
             }
         }
     }
 }
开发者ID:wodnr0804,项目名称:NPC,代码行数:17,代码来源:Main.php

示例15: onPacketReceived

 public function onPacketReceived(DataPacketReceiveEvent $event)
 {
     $packet = $event->getPacket();
     $player = $event->getPlayer();
     if ($packet instanceof InteractPacket) {
         $boat = $player->getLevel()->getEntity($packet->target);
         if ($boat instanceof Boat) {
             if ($packet->action === 1) {
                 $pk = new SetEntityLinkPacket();
                 $pk->from = $boat->getId();
                 $pk->to = $player->getId();
                 $pk->type = 2;
                 $this->getServer()->broadcastPacket($player->getLevel()->getPlayers(), $pk);
                 $pk = new SetEntityLinkPacket();
                 $pk->from = $boat->getId();
                 $pk->to = 0;
                 $pk->type = 2;
                 $player->dataPacket($pk);
                 $this->riding[$player->getName()] = $packet->target;
             } elseif ($packet->action === 3) {
                 $pk = new SetEntityLinkPacket();
                 $pk->from = $boat->getId();
                 $pk->to = $player->getId();
                 $pk->type = 3;
                 $this->getServer()->broadcastPacket($player->getLevel()->getPlayers(), $pk);
                 $pk = new SetEntityLinkPacket();
                 $pk->from = $boat->getId();
                 $pk->to = 0;
                 $pk->type = 3;
                 $player->dataPacket($pk);
                 if (isset($this->riding[$event->getPlayer()->getName()])) {
                     unset($this->riding[$event->getPlayer()->getName()]);
                 }
             }
         }
     } elseif ($packet instanceof MovePlayerPacket) {
         if (isset($this->riding[$player->getName()])) {
             $boat = $player->getLevel()->getEntity($this->riding[$player->getName()]);
             if ($boat instanceof Boat) {
                 $boat->x = $packet->x;
                 $boat->y = $packet->y;
                 $boat->z = $packet->z;
             }
         }
     }
 }
开发者ID:AmieXD,项目名称:mts-plugin1,代码行数:46,代码来源:plugin.php


注:本文中的pocketmine\event\server\DataPacketReceiveEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。