The code you have is completely wrong. Foreach the Contents of the inventory and check if at least is a tool.
yea, i need test for many times, and i found my way, thx btw. And, i was edited the thread, new topic.
In Nukkit existst something like player.getMovementSpeed () maybe exists something like that in PocketMine too
You should have rather posted your working code and marked it as solved. Beginners might want the exact same and could just look at this thread instead of creating a new one. Anyways, I think third-party PocketMine softwares (not all of them) have Player::getSpeed(). Though, I don't think that changes with a speed hack. You should create an own plugin for this, not just use that function. (if it even works)
It's simple: PHP: $speed = abs($player->getMotion()->x) + abs($player->getMotion->z); abs(); turns a negative value into a positive one, so it always returns a positive value, that's how you still get the real speed although the player's X motion is -1 and his Z motion is 1.
PHP: $Effect = Effect::getEffect(1); /* speed id */ $effect->setAmplifier(2); /* speed Power */ $effect->setVisible(true); $effect->setDuration(10000000000); /* speed Time */ $sender->addEffect($effect);
If your still looking for an answer to this, one way that I have used is despawn the player and spawn a Human entity with the players ID then sync the movement so you can manage the Human entity's movement.