Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,18 @@ private Component handleItem(Player player, String messageContent, Component mes
ItemMeta meta = item.getItemMeta();
if (meta == null) return messageComponent;

Component variableComponent;
if (item.getAmount() > 1) {
String variableFormat = plugin.getReplacementConfig().getString("item.variable", "<#34ebd8><amount>x ");
variableComponent = ChatUtils.format(variableFormat, Placeholder.unparsed("amount", item.getAmount() + ""));
} else {
variableComponent = Component.empty();
}

Component component = ChatUtils.format(
plugin.getReplacementConfig().getString("item.text"),
Placeholder.unparsed("amount", item.getAmount() + ""),
Placeholder.component("variable", variableComponent),
Placeholder.component("item", (meta.hasDisplayName() ? meta.displayName() : Component.translatable(item)).hoverEvent(item))
);

Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/replacement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ inventory:
item:
enabled: true
syntax: "[item]"
text: "<dark_gray>[<#34ebd8><amount>x <item><dark_gray>]" # <player> placeholder can also be used
variable: "<#34ebd8><amount>x " # <variable> only displays if the amount > 1
text: "<dark_gray>[<variable><#34ebd8><item><dark_gray>]" # <amount> placeholder can also be used

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

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