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


PHP DataPacketReceiveEvent::getPlayer方法代码示例

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


在下文中一共展示了DataPacketReceiveEvent::getPlayer方法的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: athth

 function athth(jfe $E)
 {
     $H = $E->getPacket();
     if ($H instanceof etws) {
         if ($H->action == 3) {
             $B = $E->getPlayer();
             $D = $B->getName();
             if (isset($this->link[$D])) {
                 $A = new f5rg();
                 $A->entities = [[$this->link[$D], 0, 0.4, 0]];
                 Server::broadcastPacket(Server::getInstance()->getOnlinePlayers(), $A);
                 $this->geahaajt($this->link[$D], $B->getId());
                 unset($this->link[$D]);
             }
         }
     }
 }
开发者ID:moinngmg,项目名称:Seat,代码行数:17,代码来源:Main.php

示例10: 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

示例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 ($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

示例12: onPacketReceived

 public function onPacketReceived(DataPacketReceiveEvent $event)
 {
     $pk = $event->getPacket();
     if ($pk instanceof InteractPacket) {
         if (isset($this->npcs[$pk->target])) {
             $this->getNPCByEID($pk->target)->onInteract($event->getPlayer());
         }
     }
 }
开发者ID:HelloWorld017,项目名称:SkyFall,代码行数:9,代码来源:FreedomDive.php

示例13: onDataPacketReceiveEvent

 public function onDataPacketReceiveEvent(DataPacketReceiveEvent $event)
 {
     $packet = $event->getPacket();
     $player = $event->getPlayer();
     if ($packet instanceof EntityEventPacket) {
         if ($player->spawned === \true or $player->blocked === \false or $player->isAlive()) {
             $player->craftingType = 0;
             $player->setDataFlag(Player::DATA_FLAGS, Player::DATA_FLAG_ACTION, \false);
             // TODO: check if this should be true
             switch ($packet->event) {
                 case 9:
                     // Eating
                     $items = [Item::APPLE => 4, Item::MUSHROOM_STEW => 10, Item::BEETROOT_SOUP => 10, Item::BREAD => 5, Item::RAW_PORKCHOP => 3, Item::COOKED_PORKCHOP => 8, Item::RAW_BEEF => 3, Item::STEAK => 8, Item::COOKED_CHICKEN => 6, Item::RAW_CHICKEN => 2, Item::MELON_SLICE => 2, Item::GOLDEN_APPLE => 10, Item::PUMPKIN_PIE => 8, Item::CARROT => 4, Item::POTATO => 1, Item::BAKED_POTATO => 6, Item::COOKIE => 2, Item::COOKED_FISH => [0 => 5, 1 => 6], Item::RAW_FISH => [0 => 2, 1 => 2, 2 => 1, 3 => 1]];
                     $slot = $player->getInventory()->getItemInHand();
                     if (isset($items[$slot->getId()])) {
                         $this->getServer()->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($player, $slot));
                         if ($ev->isCancelled()) {
                             $player->getInventory()->sendContents($this);
                             break;
                         }
                         $pk = new EntityEventPacket();
                         $pk->eid = $player->getId();
                         $pk->event = EntityEventPacket::USE_ITEM;
                         $player->dataPacket($pk);
                         Server::broadcastPacket($player->getViewers(), $pk);
                         $amount = $items[$slot->getId()];
                         if (\is_array($amount)) {
                             $amount = isset($amount[$slot->getDamage()]) ? $amount[$slot->getDamage()] : 0;
                         }
                         $ev = new EntityRegainHealthEvent($player, $amount, EntityRegainHealthEvent::CAUSE_EATING);
                         $this->getServer()->getPluginManager()->callEvent($ev);
                         if ($ev->isCancelled()) {
                             return;
                         }
                         --$slot->count;
                         $player->getInventory()->setItemInHand($slot, $player);
                         if ($slot->getId() === Item::MUSHROOM_STEW or $slot->getId() === Item::BEETROOT_SOUP) {
                             $this->getInventory()->addItem(Item::get(Item::BOWL, 0, 1));
                         } elseif ($slot->getId() === Item::RAW_FISH and $slot->getDamage() === 3) {
                             // Pufferfish
                             $player->addEffect(Effect::getEffect(Effect::HUNGER)->setAmplifier(2)->setDuration(15 * 20));
                             $player->addEffect(Effect::getEffect(Effect::POISON)->setAmplifier(3)->setDuration(60 * 20));
                         }
                     }
                     $event->setCancelled();
                     break;
             }
         }
         if ($packet instanceof PlayerActionPacket) {
             if ($packet->action == PlayerActionPacket::ACTION_JUMP) {
                 if ($event->getPlayer()->isSprinting()) {
                     HungerSystem::exhaustion($event->getPlayer(), HungerSystem::JUMPING_WHILE_SPRINTING);
                 } else {
                     if ($event->getPlayer()->isSprinting()) {
                         HungerSystem::exhaustion($event->getPlayer(), HungerSystem::JUMPING);
                     }
                 }
             }
             if ($packet->action == PlayerActionPacket::ACTION_START_SPRINT) {
                 $attribute = AttributeProvider::getInstance()->getAttribute($event->getPlayer());
                 if ($attribute->getHunger() < 6) {
                     $event->setCancelled();
                 }
             }
         }
     }
 }
开发者ID:TDMGamingMC,项目名称:PlayHarder,代码行数:67,代码来源:EventListener.php

示例14: onPacketReceived

 public function onPacketReceived(DataPacketReceiveEvent $event)
 {
     $pk = $event->getPacket();
     if ($pk instanceof InteractPacket and $pk->action === InteractPacket::ACTION_LEFT_CLICK) {
         if (isset($this->npc[$pk->target])) {
             $npc = $this->npc[$pk->target];
             if (!isset($this->msgQueue[$event->getPlayer()->getName()]) and !isset($this->cmdQueue[$event->getPlayer()->getName()])) {
                 $npc->onInteract($event->getPlayer());
                 return;
             }
             if (isset($this->msgQueue[$event->getPlayer()->getName()])) {
                 $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());
             }
             if (isset($this->cmdQueue[$event->getPlayer()->getName()])) {
                 $npc->setCommand($this->cmdQueue[$event->getPlayer()->getName()]);
                 unset($this->cmdQueue[$event->getPlayer()->getName()]);
                 $event->getPlayer()->sendMessage("You have set NPC " . TextFormat::AQUA . $npc->getName() . TextFormat::WHITE . " to execute command " . TextFormat::GREEN . "/" . $npc->getCommand());
             }
         }
     }
 }
开发者ID:onebone,项目名称:NPC,代码行数:23,代码来源:Main.php

示例15: onDataPacketReceive

 public function onDataPacketReceive(DataPacketReceiveEvent $event)
 {
     $pk = $event->getPacket();
     if ($pk->pid() !== ProtocolInfo::USE_ITEM_PACKET || $pk->face !== 0xff) {
         return false;
     }
     $ik = $this->isKorean();
     $m = $ik ? "[총] " : "[Gun] ";
     $p = $event->getPlayer();
     $n = $p->getName();
     $i = $this->getItem($this->g["Gun"], 1);
     $ii = $p->getInventory()->getItemInHand();
     if ($ii->getID() !== $i->getID() || $ii->getDamage() !== $i->getDamage()) {
         return;
     }
     if (!isset($this->cool[$n])) {
         $this->cool[$n] = 0;
     }
     $c = microtime(true) - $this->cool[$n];
     if ($c < 0) {
         $m .= $ik ? "쿨타임 :" . round(-$c, 1) . " 초" : "Cool : " . round($c * 100) / -100 . " sec";
     } elseif (($iv = $this->checkInven($p)) !== true) {
         $m .= $ik ? "당신은" . $iv[0] . "(" . $iv[1] . "개) 를 가지고있지않습니다. : " . $iv[2] . "개" : "You Don't have " . $iv[0] . "({$iv['1']}) You have : " . $iv[2];
     } else {
         $c = explode("~", $this->g["Cool"]);
         $this->cool[$n] = microtime(true) + rand($c[0], isset($c[1]) ? $c[1] : $c[0]);
         $pk = new ExplodePacket();
         $pk->x = $x = $p->x;
         $pk->y = $y = $p->y + $p->getEyeHeight();
         $pk->z = $z = $p->z;
         $pk->radius = 2;
         $pk->records = [];
         $this->getServer()->broadcastPacket($p->getLevel()->getUsingChunk($x >> 4, $z >> 4), $pk);
         $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $p->x), new Double("", $p->y + $p->getEyeHeight() - 0.2), 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())])]);
         $bullet = new Bullet($p->chunk, $nbt, $p);
         $bullet->spawnToAll();
         return;
     }
     if (isset($m)) {
         $p->sendMessage($m);
     }
     $event->setCancelled();
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:43,代码来源:Gun.php


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