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

Solved How can I get the PurePerms nametag

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

  1. IvanCraft623

    IvanCraft623 Baby Zombie

    Messages:
    105
    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. KygekDev

    KygekDev Witch

    Messages:
    72
    GitHub:
    KygekDev
  3. esh123cookie

    esh123cookie Baby Zombie

    Messages:
    104
    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 Baby Zombie

    Messages:
    105
    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");
    }
     
  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.