Skip to content

Commit 46517cc

Browse files
committed
ignore value if it's the same as the placeholder
1 parent 9c9c5d5 commit 46517cc

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

spigot/value/miniplaceholders/src/main/java/me/hsgamer/topper/spigot/value/miniplaceholders/MiniPlaceholderValueProvider.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,20 @@ public MiniPlaceholderValueProvider(String placeholder) {
1818

1919
@Override
2020
public @NotNull ValueWrapper<String> apply(@NotNull Player key) {
21+
String parsed;
2122
try {
2223
Component component = MiniMessage.miniMessage().deserialize(placeholder,
2324
MiniPlaceholders.getAudiencePlaceholders(key),
2425
MiniPlaceholders.getGlobalPlaceholders()
2526
);
26-
String parsed = PlainTextComponentSerializer.plainText().serialize(component).trim();
27-
return ValueWrapper.handled(parsed);
27+
parsed = PlainTextComponentSerializer.plainText().serialize(component).trim();
28+
if (placeholder.equals(parsed)) {
29+
return ValueWrapper.notHandled();
30+
}
2831
} catch (Exception e) {
2932
return ValueWrapper.error("Error while parsing the placeholder: " + placeholder, e);
3033
}
34+
35+
return ValueWrapper.handled(parsed);
3136
}
3237
}

spigot/value/placeholderapi/src/main/java/me/hsgamer/topper/spigot/value/placeholderapi/PlaceholderValueProvider.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,16 @@ public PlaceholderValueProvider(String placeholder, boolean isOnlineOnly) {
2121
return ValueWrapper.notHandled();
2222
}
2323

24+
String replaced;
2425
try {
25-
return ValueWrapper.handled(PlaceholderAPI.setPlaceholders(player, placeholder));
26+
replaced = PlaceholderAPI.setPlaceholders(player, placeholder);
27+
if (placeholder.equals(replaced)) {
28+
return ValueWrapper.notHandled();
29+
}
2630
} catch (Exception e) {
2731
return ValueWrapper.error("Error while parsing the placeholder: " + placeholder, e);
2832
}
33+
34+
return ValueWrapper.handled(placeholder);
2935
}
3036
}

0 commit comments

Comments
 (0)