Skip to content

Commit e6aa78e

Browse files
authored
Merge pull request #9 from rainnvfx/item-placeholder
Added a modular amount placeholder for [item]
2 parents fd00eda + 8381bbb commit e6aa78e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/main/java/net/voxelarc/allaychat/chat/LocalChatManager.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,18 @@ private Component handleItem(Player player, String messageContent, Component mes
457457
ItemMeta meta = item.getItemMeta();
458458
if (meta == null) return messageComponent;
459459

460+
Component variableComponent;
461+
if (item.getAmount() > 1) {
462+
String variableFormat = plugin.getReplacementConfig().getString("item.variable", "<#34ebd8><amount>x ");
463+
variableComponent = ChatUtils.format(variableFormat, Placeholder.unparsed("amount", item.getAmount() + ""));
464+
} else {
465+
variableComponent = Component.empty();
466+
}
467+
460468
Component component = ChatUtils.format(
461469
plugin.getReplacementConfig().getString("item.text"),
462470
Placeholder.unparsed("amount", item.getAmount() + ""),
471+
Placeholder.component("variable", variableComponent),
463472
Placeholder.component("item", (meta.hasDisplayName() ? meta.displayName() : Component.translatable(item)).hoverEvent(item))
464473
);
465474

src/main/resources/replacement.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ inventory:
88
item:
99
enabled: true
1010
syntax: "[item]"
11-
text: "<dark_gray>[<#34ebd8><amount>x <item><dark_gray>]" # <player> placeholder can also be used
11+
variable: "<#34ebd8><amount>x " # <variable> only displays if the amount > 1
12+
text: "<dark_gray>[<variable><#34ebd8><item><dark_gray>]" # <amount> placeholder can also be used
1213

1314
# This is a special case, item replacement will not work fully for shulkers.
1415
shulker:
@@ -59,4 +60,4 @@ placeholder:
5960

6061
# Supports MiniMessage and PlaceholderAPI
6162
per-player:
62-
"[playtime]": "<dark_gray>[<#34ebd8><papi:player_name>'s Playtime: <papi:statistic_time_played><dark_gray>]"
63+
"[playtime]": "<dark_gray>[<#34ebd8><papi:player_name>'s Playtime: <papi:statistic_time_played><dark_gray>]"

0 commit comments

Comments
 (0)