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

Solved Removing Players From Player-list!

Discussion in 'Development' started by AlexPads, Feb 18, 2019.

Thread Status:
Not open for further replies.
  1. AlexPads

    AlexPads Spider Jockey

    Messages:
    27
    GitHub:
    alexpads
    Is there any possible way to remove a player from the Player list if they do /vanish?

    so far i have:

    PHP:
    $uuid $sender->getUniqueId();
                
    $entry = new PlayerListEntry();
                
    $entry->uuid $uuid;
    Obviously that does not work any ideas?
    (I already have the rest of the command Setup)
     
  2. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    Maybe this will help you ;)
    https://github.com/pmmp/PocketMine-...ne/network/mcpe/protocol/PlayerListPacket.php
     
  3. AlexPads

    AlexPads Spider Jockey

    Messages:
    27
    GitHub:
    alexpads
  4. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    PHP:
    /** @var Player $player */
    $entry = new PlayerListEntry();
    $entry->uuid $player->getUUID();

    $pk = new PlayerListPacket();
    $pk->entries[] = $entry;
    $pk->type PlayerListPacket::TYPE_REMOVE;

    foreach(
    $this->getServer()->getOnlinePlayers() as $players){
        
    $players->sendDataPacket($pk);
    }

     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    I'm not sure whether it's safe to call these method, looks safe though.
    You can use...
    PHP:
    $server->removePlayerListData($player->getUniqueId());
    ... to remove them from the player list.
    Re-add them back to the player list once they're no longer vanish:
    PHP:
    $server->updatePlayerListData($player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->getSkin(), $player->getXuid());
    Problems: $player->setDisplayName() updates the player list so it's going to be a problem if you have a plugin that calls that. Generally, plugins that implement nicknames (/nick) use that method to set nicks.
     
    jasonwynn10 likes this.
  6. AlexPads

    AlexPads Spider Jockey

    Messages:
    27
    GitHub:
    alexpads
    @Muqsit Do you know what the classes are for Remove and Update Player list data because i cant find them.

    Also thanks i am trying your method if it interferes ill see about the other one.
     
  7. AlexPads

    AlexPads Spider Jockey

    Messages:
    27
    GitHub:
    alexpads
    @KielKing Thank you!!!!!!! Your Method Worked!
     
  8. AlexPads

    AlexPads Spider Jockey

    Messages:
    27
    GitHub:
    alexpads
    @KielKing How Would you make it Remove the Vanish Like stop the Packet.
     
  9. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    Try
    PHP:
    /** @var Player $player */
    $entry = new PlayerListEntry();
    $entry->uuid $player->getUUID();
    $pk = new PlayerListPacket();
    $pk->entries[] = $entry;
    $pk->type PlayerListPacket::TYPE_ADD

    foreach(
    $this->getServer()->getOnlinePlayers() as $players){   
     
    $players->sendDataPacket($pk);
    }
     
  10. AlexPads

    AlexPads Spider Jockey

    Messages:
    27
    GitHub:
    alexpads
    Code:
    [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\network\mcpe\NetworkBinaryStream::putEntityUniqueId() must be of the type integer, null given, called in phar://C:/Users/AlexPads/Desktop/Servers/New Hub Files/PocketMine-MP.phar/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php on line 90" (EXCEPTION) in "src/pocketmine/network/mcpe/NetworkBinaryStream" at line 303
    It's Saying that it can't Find me and it kicks you when you use the command. But it seems like it would make sense the issues is with the GetUUID() thats where the error is.
     
  11. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    Just change that to $player->getUniqueId()
     
  12. AlexPads

    AlexPads Spider Jockey

    Messages:
    27
    GitHub:
    alexpads
    @wolfdale that is what it is set as when it gives the error the error is saying that it can't find me because my packet is gone
     
  13. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    The code he gave you used getUUID(), which does not exist
    PHP:
    /** @var Player $player */
    $entry = new PlayerListEntry();
    $entry->uuid $player->getUniqueId();//**HERE**
    $pk = new PlayerListPacket();
    $pk->entries[] = $entry;
    $pk->type PlayerListPacket::TYPE_ADD

    foreach(
    $this->getServer()->getOnlinePlayers() as $players){   
     
    $players->sendDataPacket($pk);
    }

     
  14. AlexPads

    AlexPads Spider Jockey

    Messages:
    27
    GitHub:
    alexpads
    @wolfdale Yes I understand that is what i am Using :)

    i changed it i use PhpStorm it showed me what to put there when the code was put in!

    The error is saying it cant find the player that it is getting null for an answer!
    the code but with

    TYPE_REMOVE is working just fine! its adding the player back is the problem!

    Here is the entire plugin on GitHub if you would like to look: https://github.com/AlexPads/SuperVanish
     
  15. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
  16. AlexPads

    AlexPads Spider Jockey

    Messages:
    27
    GitHub:
    alexpads
    is that one just

    PHP:
    PlayerListEntry::createAdditionEntry($player);
    or how I have never seen that one before.
     
  17. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    I forgot to add this when player is null. Sorry :facepalm:
    BTW here is your code!
    PHP:
    /** @var Player $player */
    $entry = new PlayerListEntry();
    $entry->uuid $player->getUUID();
    if(
    $entry->uuid === null){
    return;
    }
    $pk = new PlayerListPacket();
    $pk->entries[] = $entry;
    $pk->type PlayerListPacket::TYPE_ADD;

    foreach(
    $this->getServer()->getOnlinePlayers() as $players){  

    $players->sendDataPacket($pk);
    }
     
  18. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    I though you were using phpstorm? :D Click into the link in my last post to see the required arguments you need to provide it
     
  19. AlexPads

    AlexPads Spider Jockey

    Messages:
    27
    GitHub:
    alexpads
    @wolfdale I am And it did tell me what to put in but when i add it it does nothing and gives not errors players can still not see me back in their player lists. its not yellow and has no red lines so it says there is nothing wrong with the line.

    also

    @ZackyVN Still not working that way i am testing @wolfdale i'm testing his method now Thanks!
     
  20. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    Not sure if you did it correctly, its meant to be used like this
    PHP:
    $entry PlayerListEntry::createAdditionEntry();//fill in arguments, im too lazy xD
    $pk = new PlayerListPacket();
    $pk->entries[] = $entry;
    $pk->type PlayerListPacket::TYPE_ADD;
    foreach(
    $this->getServer()->getOnlinePlayers() as $players){
    $players->sendDataPacket($pk);
    }
     
Thread Status:
Not open for further replies.
  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.