Solved How can I get the PurePerms nametag

Discussion in 'Development' started by IvanCraft623, Oct 12, 2020.

  1. IvanCraft623

    IvanCraft623 Spider Jockey

    Messages:
    42
    GitHub:
    IvanCraft623
    I want to put join message (PurePerms nametag) has joined the game

    The name tag I mean the nametag that pureperms gives you in the game, which is the format you configure, but I don't know how to obtain it.
     
  2. Kygekraqmak

    Kygekraqmak Witch

    Messages:
    57
    GitHub:
    Kygekraqmak
  3. esh123cookie

    esh123cookie Slime

    Messages:
    85
    GitHub:
    esh123cookie
    You can do this for their tag
    PHP:
     $player->getNameTag() 
    for someone's group use this function

    PHP:
        public function getGroup(Player $player) {
         
    $this->group $this->getServer()->getPluginManager()->getPlugin("PurePerms")->getUserDataMgr()->getGroup($player)->getName();       
             return 
    $this->group;
        }
     
  4. IvanCraft623

    IvanCraft623 Spider Jockey

    Messages:
    42
    GitHub:
    IvanCraft623
    Hi guys I found the solution by looking at the PureChat code.
    For those who want to know how I got the nametag...
    I have used these variables:
    PHP:
    $player $event->getPlayer();
    $levelName  $this->getServer()->getPluginManager()->getPlugin("PureChat")->getConfig()->get("enable-multiworld-chat") ? $player->getLevel()->getName() : null;
    $nametag $this->getServer()->getPluginManager()->getPlugin("PureChat")->getNametag($player$levelName);
    An example where I use the nametag that pureperms assigns you:
    PHP:
    public function onJoin(PlayerJoinEvent $event){
        
    $player $event->getPlayer();
        
    $levelName  $this->getServer()->getPluginManager()->getPlugin("PureChat")->getConfig()->get("enable-multiworld-chat") ? $player->getLevel()->getName() : null;
        
    $nametag $this->getServer()->getPluginManager()->getPlugin("PureChat")->getNametag($player$levelName);
        
    $event->setJoinMessage("");
        
    $this->getServer()->broadcastMessage($nametag ."§r§7 has joined the server");
    }
     

Share This Page

  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.