Skip to content

Commit

Permalink
feat: 警告中显示禁用物品名称 (#942)
Browse files Browse the repository at this point in the history
  • Loading branch information
StarWishsama committed Oct 19, 2024
1 parent 2233a35 commit 5caab10
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1155,14 +1155,21 @@ public boolean canUse(@Nonnull Player p, boolean sendMessage) {
} else if (isDisabled()) {
// The Item has been disabled in the config
if (sendMessage) {
Slimefun.getLocalization().sendMessage(p, "messages.disabled-item", true);
Slimefun.getLocalization()
.sendMessage(
p, "messages.disabled-item", true, msg -> msg.replace("%item_name%", getItemName()));
}

return false;
} else if (!Slimefun.getWorldSettingsService().isEnabled(p.getWorld(), this)) {
// The Item was disabled in the current World
if (sendMessage) {
Slimefun.getLocalization().sendMessage(p, "messages.disabled-in-world", true);
Slimefun.getLocalization()
.sendMessage(
p,
"messages.disabled-in-world",
true,
msg -> msg.replace("%item_name%", getItemName()));
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ private Result tryOpenGuide(Player p, PlayerRightClickEvent e, SlimefunGuideMode
if (SlimefunUtils.isItemSimilar(item, SlimefunGuide.getItem(layout), false, false)) {

if (!Slimefun.getWorldSettingsService().isWorldEnabled(p.getWorld())) {
Slimefun.getLocalization().sendMessage(p, "messages.disabled-item", true);
Slimefun.getLocalization().sendMessage(p, "messages.disabled-item", true, msg -> {
if (item.hasItemMeta()) {
return msg.replace("%item_name%", item.getItemMeta().getDisplayName());
} else {
return msg;
}
});
return Result.DENY;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/languages/zh-CN/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ messages:
invalid-research: '&4%research% &c不是一个有效的研究名!'
give-research: '&b你成功解锁了玩家 %player% 的研究 &7"%research%&7"'
hungry: '&c你太饿了, 先吃点东西再试试吧!'
disabled-in-world: '&4&l这个物品在此世界已被禁用'
disabled-item: '&4&l这个物品已经被禁用了! 你是怎么得到它的?'
disabled-in-world: '&4&l%item_name% 在此世界已被禁用'
disabled-item: '&4&l%item_name% 已经被禁用了! 你是怎么得到它的?'

This comment has been minimized.

Copy link
@XXY233

XXY233 Oct 19, 2024

好像有问题,&4&l 应该放在 %item_name% 的后面

no-tome-yourself: '&c你不能对你自己使用 &4学识巨著 &c...'
multimeter: '&b已储存的能源: &3%stored% &b/ &3%capacity%'
piglin-barter: '&4你不能使用 Slimefun 的物品和猪灵易物'
Expand Down

0 comments on commit 5caab10

Please sign in to comment.