本文整理汇总了PHP中pocketmine\event\player\PlayerMoveEvent类的典型用法代码示例。如果您正苦于以下问题:PHP PlayerMoveEvent类的具体用法?PHP PlayerMoveEvent怎么用?PHP PlayerMoveEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PlayerMoveEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onPlayerMove
public function onPlayerMove(PlayerMoveEvent $event)
{
$player = $event->getPlayer();
$world = $player->getLevel();
$block = $world->getBlock($player->floor()->subtract(0, 1));
if ($world->getName() == $this->getHotBlock()->getConfig()->get("world")) {
switch ($block->getId()) {
case Block::PLANKS:
$player->sendTip("§aYou're safe!");
break;
case Block::END_STONE:
$player->sendTip("§eGo!");
break;
case Block::NETHERRACK:
$player->sendTip("§cYou'll poisoned!");
$effect = Effect::getEffect(Effect::POISON);
$effect->setVisible(true);
$effect->setDuration(50);
$player->addEffect($effect);
break;
case Block::QUARTZ_BLOCK:
if (count($world->getPlayers()) < $this->getHotBlock()->getConfig()->get("players")) {
$player->sendTip("§cThere must be " . $this->getHotBlock()->getConfig()->get("players") . "players online");
} else {
$player->sendTip("§eYou're standing on the §l§cHot§6Block§r§e! §bMove!");
$this->getHotBlock()->getEconomy()->addMoney($player, 1, false, "HotBlock");
$player->sendPopup("§eYou have §a" . $this->getHotBlock()->getEconomy()->myMoney($player) . " §bCoins");
}
break;
}
}
}
示例2: onPlayerMoveEvent
public function onPlayerMoveEvent(PlayerMoveEvent $event)
{
$player = $event->getPlayer();
if ($player->isSpectator()) {
return;
}
$attribute = AttributeProvider::getInstance()->getAttribute($player);
if ($attribute->getCTick() <= 20) {
$attribute->setCTick($attribute->getCTick() + 1);
}
if ($attribute->getCTick() > 20) {
$attribute->setCTick(0);
}
foreach ($player->getLevel()->getNearbyEntities($player->getBoundingBox()->grow(1, 0.5, 1), $player) as $entity) {
if (!$entity->isAlive()) {
continue;
}
if (!$entity instanceof ExperienceOrb) {
continue;
}
$pk = new TakeItemEntityPacket();
$pk->eid = $player->getId();
$pk->target = $entity->getId();
Server::broadcastPacket($entity->getViewers(), $pk);
$pk = new TakeItemEntityPacket();
$pk->eid = 0;
$pk->target = $player->getId();
$player->dataPacket($pk);
$entity->kill();
$attribute->addExp($entity->getExp());
}
if ($player->isSprinting()) {
if ($attribute->getCTick() == 20) {
HungerSystem::exhaustion($player, HungerSystem::SPRINTING);
}
} else {
if ($player->isSneaking()) {
if ($attribute->getCTick() == 20) {
HungerSystem::exhaustion($player, HungerSystem::WALKING_AND_SNEAKING);
}
}
}
if ($player->isInsideOfWater()) {
if ($attribute->getCTick() == 20) {
HungerSystem::exhaustion($player, HungerSystem::SWIMMING);
}
}
}
示例3: onMove
public function onMove(PlayerMoveEvent $event)
{
if ($this->getPlugin()->isFrozen($event->getPlayer())) {
$event->setCancelled(true);
$event->getPlayer()->sendTip("§cI'm sorry that you cannot move,\n§cbut you are frozen!");
}
}
示例4: onPlayerMove
public function onPlayerMove(PlayerMoveEvent $event)
{
$player = $event->getPlayer();
if ($player == null) {
return;
}
if ($player->getLevel() == null) {
return;
}
// under
$x = (int) round($player->x - 0.5);
$y = (int) round($player->y - 1);
$z = (int) round($player->z - 0.5);
$id = $player->getLevel()->getBlockIdAt($x, $y, $z);
$data = $player->getLevel()->getBlockDataAt($x, $y, $z);
switch ($id) {
case 35:
if ($data == 1) {
$player->getInventory()->addItem(new Item(ITEM::COOKIE, 0, 1));
$player->sendPopup(TextFormat::GRAY . "GiveCookie:\n" . TextFormat::YELLOW . "> " . TextFormat::GREEN . "You've received a cookie!");
}
break;
default:
break;
}
}
示例5: onPlayerMove
public function onPlayerMove(PlayerMoveEvent $event)
{
$player = $event->getPlayer();
if ($player instanceof Player) {
if ($player->getLevel()->getName() === $this->plugin->vipLevelName) {
if (isset($this->plugin->statueManager->npcsSpawns[$player->getName()])) {
return;
}
foreach ($this->plugin->statueManager->npcs as $xnpc) {
if ($xnpc instanceof StatueModel) {
if ($player->getLevel()->getName() === $xnpc->levelName) {
$statuePos = $xnpc->position;
$pp = new Vector2(round($player->x), round($player->z));
$npc = new Vector2($statuePos->x, $statuePos->z);
$dff = abs(round($pp->distance($npc)));
if ($dff < 12 || $dff == 0) {
$builder = new StatueBuilder($this->plugin);
$builder->displayStatues($player, $this->plugin->statueManager->npcs);
$this->plugin->statueManager->npcsSpawns[$player->getName()] = $player->getName();
}
}
}
}
}
}
}
示例6: onPlayerMove
public function onPlayerMove(PlayerMoveEvent $event)
{
$player = $event->getPlayer();
$pname = strtolower($player->getName());
$levelName = $player->getLevel()->getName();
$players_in_tracker = isset($this->playerLocationTracker[$pname]);
if (!$this->plugin->isLevelLoaded($levelName)) {
if ($players_in_tracker) {
unset($this->playerLocationTracker[$pname]);
}
return;
}
$plot = $this->plugin->getPlotByPosition($player->getPosition());
// if users not in a plot make sure unset
if (is_null($plot) && $players_in_tracker) {
unset($this->playerLocationTracker[$pname]);
return;
}
if (is_null($plot)) {
return;
}
// if user was not previously tracked then save pos and return
if (!$players_in_tracker && !is_null($plot)) {
$this->playerLocationTracker[$pname] = $plot;
$this->plugin->getServer()->dispatchCommand($player, "p info summary");
return;
}
// if user has moved
if ($plot->X != $this->playerLocationTracker[$pname]->X || $plot->Z != $this->playerLocationTracker[$pname]->Z) {
$this->playerLocationTracker[$pname] = $plot;
$this->plugin->getServer()->dispatchCommand($player, "p info summary");
return;
}
}
示例7: onPlayerMove
/**
* @param PlayerMoveEvent $event
*/
public function onPlayerMove(PlayerMoveEvent $event)
{
if (!$event->isCancelled()) {
if ($this->getPlugin()->isRocketPad($event->getPlayer()->getLevel()->getBlock($event->getPlayer()->subtract(0, 1, 0)))) {
$this->getPlugin()->launchPlayer($event->getPlayer());
}
}
}
示例8: onPlayerMove
/**
* When the player move while
* he is not logged in, cancel
* the event
* @param PlayerMoveEvent $event
*/
public function onPlayerMove(PlayerMoveEvent $event)
{
$player = $event->getPlayer();
if (!User::exist($player->getName()) || User::exist($player->getName()) && !User::get($player->getName())->isLogged()) {
$event->setCancelled(true);
$player->sendMessage($this->needLogin);
}
}
示例9: onPlayerMove
public function onPlayerMove(PlayerMoveEvent $event)
{
if (!$this->plugin->getNoeulAPI()->isAuthed($event->getPlayer())) {
$this->plugin->getNoeulAPI()->sendAuthMsg($event->getPlayer());
$event->setCancelled(true);
$event->getPlayer()->onGround = true;
}
}
示例10: onMove
public function onMove(PlayerMoveEvent $event)
{
if ($this->plugin->status === "enabled" && $this->plugin->loginmanager[$event->getPlayer()->getId()] === 0 && $this->plugin->allowMoving !== true) {
$event->setCancelled(true);
} elseif ($this->plugin->safemode === true and $this->plugin->status !== "enabled") {
$event->setCancelled(true);
}
}
示例11: onMoveEvent
public function onMoveEvent(PlayerMoveEvent $event)
{
$player = $event->getPlayer();
foreach ($this->npc as $npc) {
if ($npc->getLevel()->getFolderName() === $event->getPlayer()->getLevel()->getFolderName()) {
$npc->seePlayer($player);
}
}
}
示例12: onMove
public function onMove(PlayerMoveEvent $event)
{
$player = $event->getPlayer();
$from = $event->getFrom();
$to = $event->getTo();
if ($from->getLevel()->getBlockIdAt($from->x, $from->y - 1, $from->z) === Block::REDSTONE_BLOCK) {
$player->setMotion((new Vector3($to->x - $from->x, $to->y - $from->y, $to->z - $from->z))->multiply(5));
}
}
示例13: onPlayerMove
/**
* @param PlayerMoveEvent $event
*
* @priority LOWEST
*/
public function onPlayerMove(PlayerMoveEvent $event)
{
if (!$this->auth->isPlayerAuthenticated($event->getPlayer())) {
if (!$event->getPlayer()->hasPermission("simpleauth.move")) {
$event->setCancelled(true);
$event->getPlayer()->onGround = true;
}
}
}
示例14: onMove
public function onMove(PlayerMoveEvent $event)
{
$player = $event->getPlayer();
if ($this->past_q[$player->getName()] != $player->yaw . ":" . $player->pitch) {
$this->past_q[$player->getName()] = $player->yaw . ":" . $player->pitch;
return;
}
$this->checkMove($player, round(microtime(true) * 1000));
$this->past_q[$player->getName()] = $player->yaw . ":" . $player->pitch;
}
示例15: onPlayerMove
public function onPlayerMove(PlayerMoveEvent $event)
{
$player = $event->getPlayer();
$level = $player->getLevel();
$block = Block::get($player->getInventory()->getItemInHand()->getId(), 0);
$pos = new Vector3($player->getFloorX(), $player->getFloorY() - 1, $player->getFloorZ());
if ($this->isPlayer($player)) {
$level->setBlock($pos, $block);
}
}