Travel in MCPE faster and easier than you ever tought !
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.2KB

  1. <?php
  2. /*
  3. _____ _ _____ _
  4. | ___| __ _ ___ | |_ |_ _| _ __ __ _ __ __ ___ | |
  5. | |_ / _` | / __| | __| | | | '__| / _` | \ \ / / / _ \ | |
  6. | _| | (_| | \__ \ | |_ | | | | | (_| | \ V / | __/ | |
  7. |_| \__,_| |___/ \__| |_| |_| \__,_| \_/ \___| |_|
  8. Travel in MCPE faster and easier than you ever tought !
  9. @author Ad5001
  10. @link http://github.com/Ad5001/FastTravel
  11. */
  12. namespace Ad5001\FastTravel\tasks;
  13. use pocketmine\Server;
  14. use pocketmine\scheduler\PluginTask;
  15. use pocketmine\Player;
  16. use Ad5001\FastTravel\Main;
  17. class FastingTask extends PluginTask {
  18. public function __construct(Main $main) {
  19. parent::__construct($main);
  20. $this->main = $main;
  21. $this->server = $main->getServer();
  22. $this->boostPlayers = [];
  23. }
  24. public function onRun($tick) {
  25. foreach($this->server->getOnlinePlayers() as $p) {
  26. $r = $p->round();
  27. $r->y = $p->getFloorY() - 1;
  28. if($p->getLevel()->getBlock($r)->getId() == $this->main->getBoostBlock()->getId() && $p->getLevel()->getBlock($r)->getDamage() == $this->main->getBoostBlock()->getDamage()) {
  29. $attr = $p->getAttributeMap()->getAttribute(\pocketmine\entity\Attribute::MOVEMENT_SPEED);
  30. $attr->setValue(0.11 * $this->main->getConfig()->get("BoostAmplifier"));
  31. $this->boostPlayers[$p->getName()] = 8; // 2 seconds.
  32. } elseif(isset($this->boostPlayers[$p->getName()])) {
  33. $this->boostPlayers[$p->getName()]--;
  34. if($this->boostPlayers[$p->getName()] <= 0) {
  35. $attr = $p->getAttributeMap()->getAttribute(\pocketmine\entity\Attribute::MOVEMENT_SPEED);
  36. $attr->setValue(0.11);
  37. }
  38. }
  39. if($p->getLevel()->getBlock($r)->getId() == $this->main->getJumpBlock()->getId() && $p->getLevel()->getBlock($r)->getDamage() == $this->main->getJumpBlock()->getDamage()) {
  40. $p->setMotion(new \pocketmine\math\Vector3($p->getMotion()->x, $this->main->getConfig()->get("JumpAmplifier"), $p->getMotion()->x));
  41. }
  42. }
  43. }
  44. }