Hi, I'm trying to make a system to apply various tags to messages, such as `{player}` and `{faction}` I do know how to simply use `str_replace()` to modify the tag in the message to the value, but i cant seem to figure out a efficient system to create tags to replace with... here is what im currently doing... PHP: public static $tags = [];public static function updateTag(string $tag, string $value) { self::$tags[$tag] = $value;} explanation: $tags is a variable that is supposed to hold all the tags registered i have to call updateTag() before each message to make sure the values for each tag is send while it works... it sucks, very inefficient... i dont wanna call it 10-15 times per command just to change the tags as it goes though the command. any better ideas?
if i am not wrong, you wanna add extra text into a message when it is displaying U can use PlayerChatEvent, i dont recommend using $player->setDisplayName() then adding more text into it using setMessage("[Text] ".$ev->getMessage()); that what i would do
yes, he can just set nametag to cfg, for example my tag is HeroWeed in the cfg, and onChatEvent, get player tag in the cfg and str_replace it with player nametag (in the chat)
also if you want to show that to people under player name (above head) you can use $player->setScoreTag() its working fine for me
or he can do it easier, just set PHP: $player->setDisplayNameTag($player->getName . "\n" . "TagHere");//and explode it with . or \nexplode("\n", /*name of player here*/); //like $name//now set player nametag in chat with $name[0] it'll set player name to first param in tag