1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Command list

Discussion in 'Plugin Help' started by Harviy, Nov 19, 2016.

  1. Harviy

    Harviy Spider

    Messages:
    13
  2. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    yup, remove the command permission from the player
     
  3. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
  4. Harviy

    Harviy Spider

    Messages:
    13
    There is no other way? I really need it.
     
  5. falk

    falk Slime Poggit Reviewer

    Messages:
    75
    GitHub:
    falkirks
    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.
     
  6. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    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.
     
  7. Harviy

    Harviy Spider

    Messages:
    13
    is it correct ?
    PHP:
        public function onCommandCancel(DataPacketReceiveEvent $event){
            
    $player $event->getPlayer();
            
    $packet $event->getPacket();
            if(
    $packet instanceof AvailableCommandsPacket){
                
    $event->isCancelled(true);
            }
        }
     
  8. atTheDisco

    atTheDisco Creeper

    Messages:
    1
  9. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    no, i don't think so
     
  10. Infernus101

    Infernus101 Witch

    Messages:
    54
    GitHub:
    infernus102
    Any leads on this? which packet?
     
  11. gurun

    gurun MiNET

    Messages:
    20
    GitHub:
    niclasolofsson
    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.
     
    falk and Primus like this.
  12. Infernus101

    Infernus101 Witch

    Messages:
    54
    GitHub:
    infernus102
    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
     
  13. gurun

    gurun MiNET

    Messages:
    20
    GitHub:
    niclasolofsson
    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.
     
  14. Infernus101

    Infernus101 Witch

    Messages:
    54
    GitHub:
    infernus102
    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
     
    Last edited: Dec 3, 2016
    gurun likes this.
  15. gurun

    gurun MiNET

    Messages:
    20
    GitHub:
    niclasolofsson
    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.
     
    SOFe, dktapps, HimbeersaftLP and 2 others like this.
  16. Infernus101

    Infernus101 Witch

    Messages:
    54
    GitHub:
    infernus102
    So this?
    PHP:
      public function onCommandCancel(DataPacketSendEvent $event){
            
    $player $event->getPlayer();
            
    $packet $event->getPacket();
            if(
    $packet instanceof AvailableCommandsPacket){
                
    $event->isCancelled(true);
            }
        }
     
    aminozomty likes this.
  17. gurun

    gurun MiNET

    Messages:
    20
    GitHub:
    niclasolofsson
    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.
     
  18. Infernus101

    Infernus101 Witch

    Messages:
    54
    GitHub:
    infernus102
    Still shows all the commands available on the server when you do "/" :(
     
  19. Intyre

    Intyre Administrator Staff Member PMMP Team

    Messages:
    81
    GitHub:
    Intyre
    How do you expect that to work? Why don't you read the PM code?
    [​IMG]
     
    99leonchang, SOFe, dktapps and 5 others like this.
  20. gurun

    gurun MiNET

    Messages:
    20
    GitHub:
    niclasolofsson
    He means you should change this line to something else ..
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.