Hi, I want to remove the commands in there. Is this possible ? https://s17.postimg.org/r7xufoq3z/cats.jpg
Oh, that won't work due to https://github.com/pmmp/PocketMine-MP/commit/1ac74fe5bc0bc9e5d8add5f00e8d197f701a0528
You would have to intercept DataPacketSendEvent event and look for AvailableCommandsPacket. You will probably just want to cancel the event if the player is not op.
You could have resource files containing each permission levels/ranks available commands in the MCPE command format and send the appropriate resource files contents in the AvailableCommandsPacket when a player joins. You can then cancel every other attempt to send an AvailableCommandsPacket by listening to DataPacketSendEvent and canceling it, like @falk suggested, to prevent your list being overwritten.
is it correct ? PHP: public function onCommandCancel(DataPacketReceiveEvent $event){ $player = $event->getPlayer(); $packet = $event->getPacket(); if($packet instanceof AvailableCommandsPacket){ $event->isCancelled(true); } }
@robske_110 (Tim) , I think the problem is entirely due to this change https://github.com/pmmp/PocketMine-MP/commit/bd5bbbea10fa18568d7ff0492c1630b082a1d030
You would want to disable commands, right? They are disabled entirely in the StartGame packet. https://github.com/pmmp/PocketMine-...c6505825dfed9/src/pocketmine/Player.php#L1714 Just by looking at the code, looks like you could also get away with clearing the command map for the server. https://github.com/pmmp/PocketMine-...7c6505825dfed9/src/pocketmine/Player.php#L513 But if you want to do it for one player, you can just send the startgame packet yourself or send an empty AvailableCommandsPacket and be done with it.
PHP: public function onCommandCancel(DataPacketReceiveEvent $event){ $player = $event->getPlayer(); $packet = $event->getPacket(); if($packet instanceof AvailableCommandsPacket){ $event->isCancelled(true); } } Why doesn't this work? @gurun
It's mostly a matter of attitude. Basically, me looking at that code, would say it's working just fine. However, it might be that you, looking at that code, have strong feelings of "it is not working". I believe the fault could be one of expectations. Basically i expect it to do something different than you do, hence it is working for me. Just a matter of attitude. So you are faced with 1 of 2 choices here. Either change the code to match your expectations of how it should work, OR change your expectations to match how the code actually works. Your choice. However, if you so decide that you don't want to change your own expectation of how it should work, it might help us understand what to change about the code if you explain what your expectations are.
My expectations with that code are that it shouldn't show available commands when you type "/" in chat! But the code doesn't match that expectation! I thought the expectations were implied when @Harviy posted this thread and explained his expectations. If i had other expectations, I would open another thread and give out my expectations @gurun
Ah, i see. Yeah just that my expectations when I saw the code was more along the lines of "I'm building a client, hence i want to cancel all the commands sent from the server, kind of thingy. But regardless, your thinking is good. Basically, you hooked into a receive handler for PM, when what you really expect is to hook into the sending part. Remember, the server sends the commands to the client, and once they are sent, it's too late to stop them. So to better match your expectations you might want to cancel the DataPacketSendEvent instead. I quickly glanced the PM code, and it feels like that is totally possible.
So this? PHP: public function onCommandCancel(DataPacketSendEvent $event){ $player = $event->getPlayer(); $packet = $event->getPacket(); if($packet instanceof AvailableCommandsPacket){ $event->isCancelled(true); } }
Looks proper yeah. But as far as if it actually works, only "run" can tell you. There are too many things I don't know about PM to say anything about that actually working or not. I only say what I see in the code. I only steal code from PM, I don't actually use it.