自定义名称
本模组为 Minecraft 添加了 /name、/itemname 和 /itemlore 命令,玩家可以使用这些命令设置前缀、后缀或昵称,或者给物品赋予彩色的名称和描述(lore)。主要设计用于小型私人服务器,但通过使用名称组,您还可以限制哪些玩家可以使用哪些前缀/后缀/昵称。
可选地,该模组还具有在游戏中显示自定义名称的功能,位于玩家头顶上方。此功能还提供了选项来自定义样式(背景颜色和文本不透明度)以及自定义显示的文本行。
还支持使用 LuckPerms 设置的前缀/后缀!
欢迎在问题追踪器中报告任何错误或建议新功能。
许可证
本模组根据 GNU LGPLv3 许可证授权。
捐赠
如果您喜欢这个模组,请考虑捐赠。
Discord
如需支持或有任何疑问,欢迎加入我的 Discord。
版本支持
| Minecraft Version |
Status |
| 26.3.x |
✅ Current |
| 26.2.x |
✔️ Available |
| 26.1.x |
✔️ Available |
| 1.21.11 |
✔️ Available |
| 1.21.9+10 |
✔️ Available |
| 1.21.6+7+8 |
✔️ Available |
| 1.21.5 |
✔️ Available |
| 1.21.4 |
✔️ Available |
| 1.21.2+3 |
✔️ Available |
| 1.21+1 |
✔️ Available |
| 1.20.5+6 |
✔️ Available |
| 1.20.4 |
✔️ Available |
| 1.20.1 |
✔️ Available |
| 1.19.4 |
✔️ Available |
| 1.19.2 |
✔️ Available |
我努力保持对最新版本的 Minecraft 的支持。有时由于我没有足够的时间立即更新模组,对新版本的更新可能会延迟。
不受支持的版本仍可下载,但不会获得新功能或错误修复。
NeoForge 移植版适用于 Minecraft 26.1 及以上版本。
用法
模组构建可以在发布页面以及 Modrinth 上找到。
本模组面向 Fabric Minecraft 服务器,但也适用于客户端。本模组需要 Fabric API。
/name 命令可以按如下方式使用:
/name prefix - 设置您名称的前缀,如果未提供前缀,则清除您的前缀。
- 需要操作员权限或
customname.prefix 权限。
/name suffix - 设置您名称的后缀,如果未提供后缀,则清除您的后缀。
- 需要操作员权限或
customname.suffix 权限。
/name nickname - 设置将替代您 IGN 显示的昵称,如果未提供昵称,则清除您的昵称。
- 需要操作员权限或
customname.nick 权限。
/name other <prefix|suffix|nickname> <player>
- 语法与其各自的
/name <prefix|suffix|nickname> 命令相同,但用于设置其他玩家的前缀/后缀/昵称。除了相应的 customname.<nametype> 权限外,还需要操作员权限或 customname.other 权限。
当启用高级工具提示时,悬停在玩家名称上会显示其真实名称。
/itemname 命令可用于重命名您当前手持的物品。需要操作员权限或 customname.itemname 权限。
类似地,/itemlore 可用于设置您手中物品的描述(lore)。需要操作员权限或 customname.itemlore 权限。
\n 可用于创建新行,\\ 可用于转义反斜杠。
与 /name 命令类似,不带参数运行这些命令会重置您手中物品的名称/描述。
Minecraft 的格式化代码可用于格式化您的前缀、后缀、昵称或物品名称/描述。
使用 & 代替 § 字符(要在(物品)名称中使用 &,请输入 &&)。
除了 Minecraft 默认格式化代码外,还可以使用 &#<hex code> 格式。
这里和这里提供了易于创建格式化名称的有用工具。
可以在配置文件中禁用名称中格式化代码的使用。
与 /name 命令一样,本模组还支持从 LuckPerms 模组读取前缀和后缀。
API
其他 Fabric 或 NeoForge 模组可以通过 CustomNameApi 类读取由 Custom Names 管理的名称:
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import xyz.eclipseisoffline.eclipsescustomname.api.CustomNameApi;
import xyz.eclipseisoffline.eclipsescustomname.api.CustomNameType;
Component prefix = CustomNameApi.getName(player, CustomNameType.PREFIX);
Component nickname = CustomNameApi.getName(player, CustomNameType.NICKNAME);
Component displayNickname = CustomNameApi.getDisplayNickname(player);
Component suffix = CustomNameApi.getName(player, CustomNameType.SUFFIX);
Component fullName = CustomNameApi.getFullName(player);
当未设置该名称类型的值时,getName 返回 null。getDisplayNickname 会回退到玩家的原始(vanilla)名称,而 getFullName 则返回 Custom Names 使用的完整显示名称。
在 Fabric 上,如果安装了 Patbox 的 Placeholder API,Custom Names 还会注册以下玩家占位符:
%eclipsescustomname:prefix%、%eclipsescustomname:nickname%、%eclipsescustomname:suffix%、
%eclipsescustomname:luckperms_prefix%、%eclipsescustomname:luckperms_suffix% 以及 %eclipsescustomname:full_name%。
配置文件
该模组的配置文件位于 {root config directory}/eclipsescustomname.json。
默认情况下,配置文件内容如下所示:
{
"enable_formatting": true,
"require_permissions": true,
"blacklisted_names": [],
"max_name_length": 16,
"operators_bypass_restrictions": false,
"display_above_player": {
"enabled": false,
"text_opacity": 255,
"background_color": "#40000000",
"lines": [
"luckperms_prefix prefix nickname suffix luckperms_suffix"
]
},
"name_groups": {
"prefix": {},
"nickname": {},
"suffix": {}
}
}
enable_formatting:可用于禁用名称中的 Minecraft 格式化代码。
require_permissions:可用于取消权限要求。设置为 false 后,所有玩家均可使用 /name、/itemname 和 /itemlore 命令。
blacklisted_names:一个正则表达式列表,用于黑名单过滤。当前缀、后缀或昵称匹配其中任何一个正则表达式时,将无法使用该名称。
max_name_length:控制玩家前缀/昵称/后缀的最大长度,上限为 32。
operators_bypass_restrictions:可用于为管理员(operators)禁用名称限制。启用此选项后,管理员以及拥有 customname.bypass_restrictions 权限的玩家可以在昵称中使用空格、绕过最大长度限制等。
display_above_player:控制是否在游戏中在玩家头顶上方显示其自定义名称。目前这与通过队伍(teams)隐藏名称标签的功能不兼容。可以使用以下选项进一步配置外观:
text_opacity:控制文本的不透明度。255 表示完全可见,0 表示透明。
background_color:名称的背景颜色(HEX 格式)。采用 ARGB 格式,因此前两位数字表示 alpha 值。
lines:控制在玩家头顶上方显示的各行内容。您可以使用此选项自定义哪些名称类型显示在哪一行。默认情况下,所有名称类型均显示在同一行。示例中列出了所有可能的名称类型。
name_groups:可用于为每种名称类型创建名称组。名称组由一组名称列表组成,其格式与名称命令中使用的格式相同。您可以通过授予玩家相应组的权限,将其分配到一个或多个名称组中。随后他们将能够使用这些组中列出的名称。
例如,考虑以下名称组配置:
"name_groups": {
"prefix": {
"vip": [
"&f&l[&7VIP&f&l]",
"&f&l[&9VIP&f&l]",
"&f&l[&aVIP&f&l]",
"&f&l[&bVIP&f&l]",
"&f&l[&cVIP&f&l]"
],
"legendary": [
"&f&l[&7Legendary&f&l]",
"&f&l[&9Legendary&f&l]",
"&f&l[&aLegendary&f&l]",
"&f&l[&bLegendary&f&l]",
"&f&l[&cLegendary&f&l]"
]
},
"nickname": {},
"suffix": {}
}
然后,您可以给予玩家 customname.group.prefix.vip 权限,以允许他们使用 vip 组中的前缀,
并赋予 customname.group.prefix.legendary 权限,以允许他们使用 legendary 组中的前缀。当玩家输入 /name prefix 命令时,他们会看到这些前缀作为建议;而在不带任何参数运行 /name prefix 时,聊天菜单将允许他们选择前缀。
请注意,授予玩家 customname.prefix 权限仍将允许他们使用任意前缀。上述说明同样适用于昵称和后缀。
Custom Names
This mod adds a /name, a /itemname and a /itemlore command to Minecraft, which players can use to set a prefix, suffix, or nickname,
or give their items colourful names and lore. Mostly designed to be used in small, private servers, although through the
use of name groups you can also limit which players can use which prefixes/suffixes/nicknames.
Optionally, the mod also has a feature to display custom names in-game, above a player's head. This also features options
to customise the style (background colour and text opacity), as well as customising the lines of text shown.
Supports prefixes/suffixes set with LuckPerms as well!
Feel free to report any bugs, or suggest new features, at the issue tracker.
License
This mod is licensed under GNU LGPLv3.
Donating
If you like this mod, consider donating.
Discord
For support and/or any questions you may have, feel free to join my discord.
Version support
| Minecraft Version |
Status |
| 26.3.x |
✅ Current |
| 26.2.x |
✔️ Available |
| 26.1.x |
✔️ Available |
| 1.21.11 |
✔️ Available |
| 1.21.9+10 |
✔️ Available |
| 1.21.6+7+8 |
✔️ Available |
| 1.21.5 |
✔️ Available |
| 1.21.4 |
✔️ Available |
| 1.21.2+3 |
✔️ Available |
| 1.21+1 |
✔️ Available |
| 1.20.5+6 |
✔️ Available |
| 1.20.4 |
✔️ Available |
| 1.20.1 |
✔️ Available |
| 1.19.4 |
✔️ Available |
| 1.19.2 |
✔️ Available |
I try to keep support up for the latest drop of Minecraft. Updates to newer Minecraft
versions may be delayed from time to time, as I do not always have the time to immediately update my mods.
Unsupported versions are still available to download, but they won't receive new features or bugfixes.
NeoForge ports are available for Minecraft 26.1 onwards.
Usage
Mod builds can be found on the releases page, as well as on Modrinth.
This mod is oriented at Fabric Minecraft servers, but works on the client as well. This mod requires the Fabric API.
The /name command can be used as follows:
/name prefix - sets a prefix for your name, or when no prefix is given, clears your prefix.
- Requires operator or the
customname.prefix permission.
/name suffix - sets a suffix for your name, or when no suffix is given, clears your suffix.
- Requires operator or the
customname.suffix permission.
/name nickname - sets a nickname that will appear instead of your IGN, or when no nickname is given, clears your nickname.
- Requires operator or the
customname.nick permission.
/name other <prefix|suffix|nickname> <player>
- Same syntax as their respective
/name <prefix|suffix|nickname> commands, but to set another player's prefix/suffix/nickname. Requires operator or the customname.other permission on top of the respective customname.<nametype> permission.
When hovering over a player's name with advanced tooltips enabled, their real name will show up.
The /itemname command can be used to rename the item you're currently holding. Requires operator or the customname.itemname permission.
Similarly, the /itemlore can be used to set the lore of an item you're holding. Requires operator or the customname.itemlore permission.
\n can be used to create new lines, \\ can be used to escape a backslash.
Similar to the /name commands, running these commands without arguments resets the item name/lore of the item you're holding.
Minecraft's formatting codes can be used to format your prefix, suffix, nickname, or your item names/lores.
Instead of the § character, use & (to use & in an (item)name, type &&).
Alongside Minecraft's default formatting codes, the &#<hex code> format can be used as well.
Useful tools to easily create formatted names are available here and here.
Usage of formatting codes in names can be disabled in the config file.
Alongside the /name command, this mod also supports reading prefixes and suffixes from the LuckPerms mod.
API
Other Fabric or NeoForge mods can read names managed by Custom Names through the CustomNameApi class:
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import xyz.eclipseisoffline.eclipsescustomname.api.CustomNameApi;
import xyz.eclipseisoffline.eclipsescustomname.api.CustomNameType;
Component prefix = CustomNameApi.getName(player, CustomNameType.PREFIX);
Component nickname = CustomNameApi.getName(player, CustomNameType.NICKNAME);
Component displayNickname = CustomNameApi.getDisplayNickname(player);
Component suffix = CustomNameApi.getName(player, CustomNameType.SUFFIX);
Component fullName = CustomNameApi.getFullName(player);
getName returns null when there is no value set for that name type. getDisplayNickname
falls back to the player's vanilla name, and getFullName returns the complete display name used by Custom Names.
On Fabric, if Patbox's Placeholder API is installed, Custom Names also registers these player placeholders:
%eclipsescustomname:prefix%, %eclipsescustomname:nickname%, %eclipsescustomname:suffix%,
%eclipsescustomname:luckperms_prefix%, %eclipsescustomname:luckperms_suffix%, and %eclipsescustomname:full_name%.
Config file
The mod's configuration file is present in {root config directory}/eclipsescustomname.json.
By default, the configuration file looks like this:
{
"enable_formatting": true,
"require_permissions": true,
"blacklisted_names": [],
"max_name_length": 16,
"operators_bypass_restrictions": false,
"display_above_player": {
"enabled": false,
"text_opacity": 255,
"background_color": "#40000000",
"lines": [
"luckperms_prefix prefix nickname suffix luckperms_suffix"
]
},
"name_groups": {
"prefix": {},
"nickname": {},
"suffix": {}
}
}
enable_formatting can be used to disable the use of Minecraft formatting codes in names.
require_permissions can be used to disable the permission requirement. When set to false, the /name, /itemname and /itemlore commands are available to everyone.
blacklisted_names is a list of regexes that are blacklisted. When a prefix, suffix or nickname matches one of these regexes, they won't be able to be used.
max_name_length controls how long a player prefix/nickname/suffix can be, which can be 32 at most.
operators_bypass_restrictions can be used to disable name restrictions for operators. When this is enabled, operators and people with the permission customname.bypass_restrictions can use spaces in nicknames, bypass the max length restriction, and more.
display_above_player controls whether the player's custom name should display above their head in game. This is currently not compatible with hiding name tags using teams. The appearance can be further configured using the following options:
text_opacity: controls the opacity of the text. 255 is fully visible, 0 is transparent.
background_color: the HEX-background colour of the name. This is in ARGB format, so the first 2 digits indicate the alpha value.
lines: controls the lines shown above a player's head. You can use this option to customise on which lines which name types are displayed. By default, all name types are displayed on a single line. All possible name types are listed in the example above.
name_groups can be used to create name groups for each name type. Name groups consist of a list of names, which follow the same format used in name commands. You can assign players to one or more name groups by giving them permissions to the respective groups. They will then be able to use names listed in those groups.
For example, consider this name groups config:
"name_groups": {
"prefix": {
"vip": [
"&f&l[&7VIP&f&l]",
"&f&l[&9VIP&f&l]",
"&f&l[&aVIP&f&l]",
"&f&l[&bVIP&f&l]",
"&f&l[&cVIP&f&l]"
],
"legendary": [
"&f&l[&7Legendary&f&l]",
"&f&l[&9Legendary&f&l]",
"&f&l[&aLegendary&f&l]",
"&f&l[&bLegendary&f&l]",
"&f&l[&cLegendary&f&l]"
]
},
"nickname": {},
"suffix": {}
}
You can then give players the customname.group.prefix.vip permission to allow them to use prefixes from the vip group,
and the customname.group.prefix.legendary permission to allow them to use prefixes from the legendary group. Players
will see these prefixes suggested when entering the /name prefix command, and, when running /name prefix without any
arguments, a chat menu will allow them to select a prefix.
Note that granting players the customname.prefix permission will still allow them to use any prefix. Everything said above
also applies to nicknames and suffixes.
评论 0
登录后参与评分
还没有评论,来抢沙发吧