Skip to content

Commit 12a1db4

Browse files
added the MiniMessageUtil.getMessage(String, String, Object, String, Map) method
1 parent 7f53a8d commit 12a1db4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

bukkit-utils/src/main/java/com/wizardlybump17/wlib/util/bukkit/MiniMessageUtil.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private MiniMessageUtil() {
3333
return miniMessage.deserialize(message, resolvers);
3434
}
3535

36-
public static @NotNull Component getMessage(@NotNull String message, @NotNull String placeholderKey, @NotNull Object placeholderValue, @NotNull Map<String , ?> additionalPlaceholders) {
36+
public static @NotNull Component getMessage(@NotNull String message, @NotNull String placeholderKey, @NotNull Object placeholderValue, @NotNull String prefix, @NotNull Map<String , ?> additionalPlaceholders) {
3737
MiniMessage miniMessage = MiniMessage.miniMessage();
3838
if (additionalPlaceholders.isEmpty())
3939
return getMessage(message, Map.of(placeholderKey, placeholderValue));
@@ -45,20 +45,24 @@ private MiniMessageUtil() {
4545
Object value = entry.getValue();
4646
resolvers[resolverIndex++] = TagResolver.builder()
4747
.tag(
48-
key,
48+
prefix + key,
4949
Tag.inserting(value instanceof Component component ? component : Component.text(String.valueOf(value)))
5050
)
5151
.build();
5252
}
5353
resolvers[resolverIndex] = TagResolver.builder()
5454
.tag(
55-
placeholderKey,
55+
prefix + placeholderKey,
5656
Tag.inserting(placeholderValue instanceof Component component ? component : Component.text(String.valueOf(placeholderValue)))
5757
)
5858
.build();
5959
return miniMessage.deserialize(message, resolvers);
6060
}
6161

62+
public static @NotNull Component getMessage(@NotNull String message, @NotNull String placeholderKey, @NotNull Object placeholderValue, @NotNull Map<String , ?> additionalPlaceholders) {
63+
return getMessage(message, placeholderKey, placeholderValue, "", additionalPlaceholders);
64+
}
65+
6266
public static @NotNull Component getMessage(@NotNull String message) {
6367
return getMessage(message, Map.of());
6468
}

0 commit comments

Comments
 (0)