Hello. I want to modify the Player class. How can I use something like TaskScheduler without depending on Plugin? Specifically, after handleLoginPacket, send the message with 20tick delay. This may seem nonsensical, but it is an example. Regards.
You don't need to modify the Player class for that, you just need to listen for DataPacketReceiveEvent and schedule a delayed task, though the better way will be to listen for PlayerJoinEvent for that matter
PHP: Server::getInstance()->getScheduler()->scheduleDelayedTask(new class extends Task { /** @var Player */ protected $player; public function __construct(Player $player) { $this->player = $player; } public function onRun(int $currentTick) { $this->player->sendMessage("Hello World!"); }}($this), 20);
Nope it doesn't If you really have to modify the Player class, add a class property, set the value when you get the packet, decrement the value in entityBaseTick and send the message if it reaches 0
However, EntityBaseTick works only after the entity has spawned, and does it work at the LoginPacket(Player::handleLogin()) stage?