Skip to content

Commit

Permalink
Native support for playes's display name (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
TrinitroToluen0 authored Apr 20, 2024
1 parent c0caff2 commit bccb241
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Hierarchy:
# Tags can be used both in nametag and chat. (These are not related to ScoreHud)
# Defaults are:
# {name} - The user's name
# {display_name} - The player's display name
# {nametag_ranks_prefix} - Set of all rank prefixes in nametag
# {nametag_highest-rank_prefix} - Highest rank prefix in nametag
# {nametag_name-color} - The color of the name in nametag
Expand Down
3 changes: 3 additions & 0 deletions src/IvanCraft623/RankSystem/tag/TagManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public function registerDefaults() : void {
$this->registerTag(new Tag("name", static function(Session $user) : string {
return $user->getName();
}));
$this->registerTag(new Tag("display_name", static function (Session $user): string {
return $user->getPlayer()->getDisplayName();

Check failure on line 51 in src/IvanCraft623/RankSystem/tag/TagManager.php

View workflow job for this annotation

GitHub Actions / PHPStan Analysis

Cannot call method getDisplayName() on pocketmine\player\Player|null.
}));
$this->registerTag(new Tag("nametag_ranks_prefix", static function(Session $user) : string {
return implode("", array_map(fn(Rank $rank) => $rank->getNameTagFormat()["prefix"], $user->getRanks()));
}));
Expand Down

0 comments on commit bccb241

Please sign in to comment.