CustomNameTags
此模组提供了一种完全在服务端自定义玩家名称标签的方法,无需任何客户端模组。
本文档涵盖的是该模组的最新版本,对于 2.0.0 之前的版本,请参阅旧版文档

命令
你可以使用 /nametag 命令在游戏中管理名称标签,这需要权限等级 2;或者如果你使用了权限模组,你可以拥有 "custom-nametags.commands.nametag" 权限。
文本参数支持占位符 API,以及格式化标签。
/nametag create <id> <text> 创建一个带有给定 ID 和文本的名称标签,显示在所有玩家上方。
/nametag edit <id> text <text> 更改现有名称标签的文本。
/nametag edit <id> for <who> 更改现有名称标签的目标选择器(for selector)。
/nametag edit <id> priority <priority> 更改现有名称标签的优先级(优先级越高,显示越靠上)。
/nametag delete <id> 删除具有给定 ID 的名称标签。
/nametag list 列出所有已定义的名称标签。
/nametag player <players> give <id> 赋予玩家该名称标签,即使他们通常不会拥有它。
/nametag player <players> revoke <id> 从玩家身上隐藏该名称标签,即使他们通常应该拥有它。
/nametag player <players> set <id> <text> 仅为这些玩家设置名称标签的文本。如果不存在具有该 ID 的名称标签,这将创建一个仅对这些玩家可见的名称标签。
/nametag player <players> reset <id?> 移除玩家对给定名称标签的重置,或移除他们的所有重置。
/nametag reload 重新加载配置文件。
示例
如果你想创建一个以彩虹色显示玩家名字的名称标签,可以运行以下命令:
/nametag create rainbow_name <rainbow>%player:displayname_visual%</rainbow>
这里给出的 id rainbow_name 可以是任意字符串。<rainbow> ... </rainbow> 标签表示其中的内容应为彩虹色,这是一个格式化标签。而 %player:displayname_visual% 意味着在此处插入玩家的名字,这是一个占位符。你还可以使用许多其他不同的格式化标签和占位符。
默认情况下,名称标签会附加给所有人。如果你只想让操作员看到该名称标签,可以运行:
/nametag edit rainbow_name for operators
如果你想手动分配谁获得名称标签,可以运行:
/nametag edit rainbow_name for nobody
这意味着默认情况下没有人会有这个名称标签,然后你可以使用以下命令覆盖此设置:
/nametag player senseiwells give rainbow_name
指定的玩家(在本例中为 senseiwells)将始终获得该名称标签。
如果你想覆盖特定名称标签的文本,或者仅给某个玩家提供一个专属名称标签,可以使用:
/nametag player senseiwells set rainbow_name <red>Special Red Name</red>
如果存在 ID 为 rainbow_name 的名称标签,则指定玩家的名称标签现在将显示覆盖文本“Special Red Name”,且为红色。如果不存在具有该 ID 的名称标签,则将为该指定玩家创建一个新的。
这些命令允许你创建一个基本的名称标签系统,但为了更精细的控制,必须手动编辑名称标签配置文件...
配置
此模组的配置文件位于 config/custom-nametags/config.json。
上述图片使用了以下配置:
{
"version": 2,
"nametags": {
"admin_name": {
"text": "[Admin] <rainbow>%player:displayname_visual%</rainbow>",
"update_interval": -1,
"for": "operators"
},
"name": {
"text": "[Player] %player:displayname_visual%",
"update_interval": -1,
"for": { "not": "operators" }
},
"held_item": {
"text": "Holding: <green>%player:equipment_slot mainhand%</green>",
"update_interval": 1
},
"data": {
"text": "%player:health%♥ %player:hunger%? %player:statistic minecraft:killed minecraft:player%⚔ %player:statistic minecraft:deaths%\uD83D\uDC80",
"update_interval": 1
}
},
"players": {}
}
来自模组 2.0.0 之前版本的配置文件将自动升级到新格式。你的原始配置文件将备份为 config.old.json。
名称标签
"nametags" 对象包含所有将为你的玩家显示的名称标签,以其 ID 为键。它们按列出的顺序堆叠,第一个位于最顶部。
"text" 这是将在你的姓名标签上显示的文本。如前所述,它也支持 占位符 API
以及 格式标签。
"update_interval" 这是姓名标签更新的间隔时间,单位为刻(ticks)。如果你的姓名标签不需要更新,请设置为 -1。这在你姓名标签包含包含变化数据的占位符时相关,例如 %player:health%。
"for" 这决定哪些玩家拥有此姓名标签,请参阅下方的 玩家选择器。默认为 "everyone"。
"visible_to" 这决定哪些玩家可以看到此姓名标签,请参阅下方的 玩家选择器。默认为 "everyone"。
"visible_radius", "hidden_radius" 这两个设置指定了姓名标签对其他玩家可见的范围。将这些值设置为负数以禁用它们。
"visible_through_walls" 姓名标签是否可以穿墙显示,默认为 true。
"visible_when_invisible" 当玩家处于隐身状态时是否显示姓名标签,默认为 false。
"visible_with_passengers" 当玩家有乘客时是否显示姓名标签,默认为 false。
"shift_height" 姓名标签占据的垂直空间,默认为 0.275,足以容纳单行文本。
"priority" 优先级较高的姓名标签会显示在优先级较低的姓名标签上方,默认为 0。
玩家选择器 (Player Selectors)
选择器由 "for" 和 "visible_to" 用于挑选玩家。
最简单的选择器是 "everyone"、"nobody" 和 "operators":
{
"for": "operators"
}
对于其他情况,请使用包含以下一个或多个条件的对象,所有条件必须同时匹配:
| 条件 |
匹配的玩家特征 |
"names" |
具有给定的用户名之一 |
"uuids" |
具有给定的 UUID |
"teams" |
属于给定的队伍之一 |
"tags" |
具有给定的记分板标签 |
"permission_level" |
具有至少给定的操作者等级 (0-4) |
"permission" |
具有给定的权限节点(需要权限模组) |
"not" |
不匹配给定的选择器 |
"any" |
匹配给定选择器列表中的任意一个 |
"all" |
匹配给定选择器列表中的所有选择器 |
"predicate" |
匹配 Predicate API 谓词 |
每个接受列表的条件也接受单个值。
{
// 名为 senseiwells 或 SuperSanta 的玩家
"for": { "names": ["senseiwells", "SuperSanta"] },
// 红色队伍的运营者
"for": { "permission_level": 2, "teams": "red" },
// 既是运营者又是 VIP 的人
"visible_to": { "any": [ "operators", { "permission": "group.vip" } ] },
// 除了旁观者以外的所有人
"visible_to": { "not": { "teams": "spectators" } }
}
玩家 (Players)
"players" 对象允许你为特定玩家自定义姓名标签,以其用户名或 UUID 作为键。每个条目将姓名标签 ID 映射到覆盖配置:
{
"nametags": {
"rank": { "text": "<red>[Admin]</red>", "for": "operators" },
"name": { "text": "%player:displayname_visual%" }
},
"players": {
// 你也可以使用 UUID 代替用户名
"senseiwells": {
// 仅为此玩家替换 "rank" 姓名标签的文本
"rank": "<gold>[Owner]</gold>"
},
"SuperSanta": {
// 无论 SuperSanta 是否是运营者,都给予 "rank" 姓名标签
"rank": true,
// 隐藏 "name" 姓名标签
"name": false,
// 只有该玩家拥有这个特定的姓名标签
"hearts": { "text": "%player:hearts%♥", "update_interval": 1 }
}
}
}
覆盖配置可以是:
true 或 false 以给予或隐藏姓名标签,
- 字符串以替换姓名标签的文本,
- 包含 姓名标签 (Nametags) 中任何字段的对象以替换这些字段,
加上
"enabled": false 以隐藏它。
覆盖姓名标签会使玩家获得该姓名标签,而不管其 "for" 选择器如何,除非覆盖配置指定了自己的 "for"。不匹配全局姓名标签的 ID 将定义一个仅该玩家拥有的姓名标签。
注意事项 (Caveats)
CustomNameTags 存在一些局限性,虽然在几乎所有情况下姓名标签都会按预期行为,但自定义姓名标签存在一些不一致之处。
- 当玩家按下 F1 隐藏 HUD 时,玩家自定义姓名标签仍将保持可见。
- 如果玩家是某个队伍的一员,他们的普通姓名标签将会渲染。
- 这可以通过隐藏给定队伍的所有姓名标签来解决:
/team modify <team> nametagVisibility never
CustomNameTags
This mod provides you with a way to customize your player's
name tags completely server-side with no need for any client mods.
This documentation covers the latest version of the mod, for versions prior to 2.0.0
please see the old documentation

Commands
You are able to manage your nametags from within the game with the /nametag
command, this requires permission level 2 or if you are using a permissions mod
you can have the permission "custom-nametags.commands.nametag".
Text arguments support the placeholders api,
as well as formatting tags.
/nametag create <id> <text> Creates a nametag with the given id and text, shown on every player.
/nametag edit <id> text <text> Changes the text of an existing nametag.
/nametag edit <id> for <who> Changes the for selector of an existing nametag.
/nametag edit <id> priority <priority> Changes the priority of an existing nametag (higher priorities are displayed higher).
/nametag delete <id> Deletes the nametag with the given id.
/nametag list Lists all the defined nametags.
/nametag player <players> give <id> Gives the players the nametag, even if they wouldn't normally have it.
/nametag player <players> revoke <id> Hides the nametag from the players, even if they would normally have it.
/nametag player <players> set <id> <text> Sets the text of the nametag for just those players. If no nametag with
that id exists, this creates one that only those players have.
/nametag player <players> reset <id?> Removes the players' overrides for the given nametag, or all of their overrides.
/nametag reload Reloads the config file.
Examples
If you wanted to create a nametag that displays player's names but in rainbow you can run
the following command:
/nametag create rainbow_name <rainbow>%player:displayname_visual%</rainbow>
The id given here of rainbow_name can be any string of characters. The <rainbow> ... </rainbow>
tags indicate that whatever is inbetween should be rainbow colored, this is a formatting tag.
And %player:displayname_visual% means that the player's name should be inserted here,
this is a placeholder.
There are many more different formatting tags and placeholders that you can use.
By default, nametags are attached to everyone, if you only wanted that nametag to be displayed
for operators only then you can run
/nametag edit rainbow_name for operators
In the case where you want to manually assign whether someone gets a nametag you can run
/nametag edit rainbow_name for nobody
Which means by default nobody will have this nametag, you can then override this with the following:
/nametag player senseiwells give rainbow_name
The player specified, in this case senseiwells, will always be given the nametag.
If you want to override the text of a specific nametag, or give a player a nametag only for them
you can use:
/nametag player senseiwells set rainbow_name <red>Special Red Name</red>
If a nametag with the id rainbow_name exists then the specified player's nametag will now display
the override text "Special Red Name" which is red. If a nametag with that id doesn't exist it'll
be created just for that specified player.
The commands allow you to create a basic nametag system, but for finer control the nametags config
file must be manually edited...
Configuration
The configuration file for this mod is located in config/custom-nametags/config.json.
The above image used the following configuration:
{
"version": 2,
"nametags": {
"admin_name": {
"text": "[Admin] <rainbow>%player:displayname_visual%</rainbow>",
"update_interval": -1,
"for": "operators"
},
"name": {
"text": "[Player] %player:displayname_visual%",
"update_interval": -1,
"for": { "not": "operators" }
},
"held_item": {
"text": "Holding: <green>%player:equipment_slot mainhand%</green>",
"update_interval": 1
},
"data": {
"text": "%player:health%♥ %player:hunger%? %player:statistic minecraft:killed minecraft:player%⚔ %player:statistic minecraft:deaths%\uD83D\uDC80",
"update_interval": 1
}
},
"players": {}
}
Configs from versions prior to 2.0.0 of the mod will automatically be upgraded to the
new format. Your original config will be backed up as config.old.json.
Nametags
The "nametags" object contains all the nametags that will be displayed for your
players, keyed by their id. They are stacked in the order they are listed,
the first being at the top.
"text" This is the text that will be displayed on your nametag. As previously mentioned this
supports the placeholders api
as well as formatting tags.
"update_interval" This is the interval at which the nametag will be updated, in ticks.
Set to -1 if your nametag doesn't need to be updated. This is relevant if your nametag contains
a placeholder which contains changing data, e.g. %player:health%.
"for"This decides which players have this nametag, see Player Selectors
below. Defaults to "everyone".
"visible_to"This decides which players can see this nametag, see Player Selectors
below. Defaults to "everyone".
"visible_radius", "hidden_radius" These two settings specify a range where the nametag will
be visible to other players. Set these to a negative value to disable them.
"visible_through_walls" Whether the nametag can be seen through walls, defaults to true.
"visible_when_invisible" Whether the nametag is shown while the player is invisible, defaults to false.
"visible_with_passengers" Whether the nametag is shown while the player has passengers, defaults to false.
"shift_height" The vertical space the nametag takes up, defaults to 0.275, enough for a single line of text.
"priority" Nametags with a higher priority are displayed above those with a lower one, defaults to 0.
Player Selectors
Selectors are used by "for" and "visible_to" to pick players.
The simplest selectors are "everyone", "nobody", and "operators":
{
"for": "operators"
}
For anything else, use an object with one or more of the following conditions,
all of which must match:
| Condition |
Matches players who... |
"names" |
have one of the given usernames |
"uuids" |
have one of the given uuids |
"teams" |
are on one of the given teams |
"tags" |
have one of the given scoreboard tags |
"permission_level" |
have at least the given operator level (0-4) |
"permission" |
have the given permission node (requires a permissions mod) |
"not" |
do not match the given selector |
"any" |
match any of the given list of selectors |
"all" |
match all of the given list of selectors |
"predicate" |
match a predicate api predicate |
Every condition that takes a list also accepts a single value.
{
// Players named senseiwells or SuperSanta
"for": { "names": ["senseiwells", "SuperSanta"] },
// Operators on the red team
"for": { "permission_level": 2, "teams": "red" },
// Anyone who is either an operator or a vip
"visible_to": { "any": [ "operators", { "permission": "group.vip" } ] },
// Everyone except spectators
"visible_to": { "not": { "teams": "spectators" } }
}
Players
The "players" object lets you customize nametags for specific players, keyed
by their username or uuid. Each entry maps nametag ids to an override:
{
"nametags": {
"rank": { "text": "<red>[Admin]</red>", "for": "operators" },
"name": { "text": "%player:displayname_visual%" }
},
"players": {
// You can also use uuids instead of usernames
"senseiwells": {
// Replaces the text of the "rank" nametag, just for this player
"rank": "<gold>[Owner]</gold>"
},
"SuperSanta": {
// We give the "rank" nametag no matter if SuperSanta is an operator or not
"rank": true,
// Hide the "name" nametag
"name": false,
// Only this player has this specific nametag
"hearts": { "text": "%player:hearts%♥", "update_interval": 1 }
}
}
}
An override can be:
true or false to give or hide the nametag,
- a string to replace the nametag's text,
- an object with any of the fields from Nametags to replace those fields,
plus
"enabled": false to hide it.
Overriding a nametag gives the player that nametag regardless of its "for" selector,
unless the override specifies its own "for". Ids that don't match a global
nametag define one that only that player has.
Caveats
There are some limitations of CustomNameTags, while for almost all the cases
the nametags will behave as expected, there are inconsistencies with the
custom nametags.
- When players press F1 to hide their HUD player custom nametags will remain visible.
- If the player is part of a team, their normal nametag will render.
- This can be solved by hiding all nametags for the given team:
/team modify <team> nametagVisibility never
评论 0
登录后参与评分
还没有评论,来抢沙发吧