mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-12-28 17:37:52 +01:00
Tweak some stuff relating to FormattedText, make invite not get escaped, ever
This commit is contained in:
parent
ad7bca010f
commit
eba37d9b6f
@ -226,7 +226,7 @@ public class SendableDiscordMessageImpl implements SendableDiscordMessage {
|
||||
throw new IllegalStateException("DiscordSRVApi not available");
|
||||
}
|
||||
this.replacements.put(PlaceholderService.PATTERN,
|
||||
wrapFunction(matcher -> api.placeholderService().getResultAsString(matcher, context)));
|
||||
wrapFunction(matcher -> api.placeholderService().getResultAsPlain(matcher, context)));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,6 @@ public interface PlaceholderService {
|
||||
PlaceholderLookupResult lookupPlaceholder(@NotNull String placeholder, @NotNull Object... context);
|
||||
|
||||
Object getResult(@NotNull Matcher matcher, @NotNull Set<Object> context);
|
||||
CharSequence getResultAsString(@NotNull Matcher matcher, @NotNull Set<Object> context);
|
||||
CharSequence getResultAsPlain(@NotNull Matcher matcher, @NotNull Set<Object> context);
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package com.discordsrv.common.invite;
|
||||
|
||||
import com.discordsrv.api.placeholder.FormattedText;
|
||||
import com.discordsrv.api.placeholder.annotation.Placeholder;
|
||||
import com.discordsrv.common.DiscordSRV;
|
||||
import com.discordsrv.common.config.main.DiscordInviteConfig;
|
||||
@ -92,7 +93,7 @@ public class DiscordInviteModule extends AbstractModule<DiscordSRV> {
|
||||
}
|
||||
|
||||
@Placeholder("discord_invite")
|
||||
public String getInvite() {
|
||||
return invite != null ? invite : UNKNOWN_INVITE;
|
||||
public CharSequence getInvite() {
|
||||
return new FormattedText(invite != null ? invite : UNKNOWN_INVITE);
|
||||
}
|
||||
}
|
||||
|
@ -175,16 +175,16 @@ public class PlaceholderServiceImpl implements PlaceholderService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getResultAsString(@NotNull Matcher matcher, @NotNull Set<Object> context) {
|
||||
public CharSequence getResultAsPlain(@NotNull Matcher matcher, @NotNull Set<Object> context) {
|
||||
Object result = getResult(matcher, context);
|
||||
return getResultAsString(result);
|
||||
return getResultAsPlain(result);
|
||||
}
|
||||
|
||||
private CharSequence getResultAsString(Object result) {
|
||||
private CharSequence getResultAsPlain(Object result) {
|
||||
if (result == null) {
|
||||
return "";
|
||||
} else if (result instanceof CharSequence) {
|
||||
return result.toString();
|
||||
return (CharSequence) result;
|
||||
}
|
||||
|
||||
Object output = null;
|
||||
@ -213,7 +213,7 @@ public class PlaceholderServiceImpl implements PlaceholderService {
|
||||
private String updateContent(List<PlaceholderLookupResult> results, String placeholder, Matcher matcher, String input) {
|
||||
Object representation = getResultRepresentation(results, placeholder, matcher);
|
||||
|
||||
CharSequence output = getResultAsString(representation);
|
||||
CharSequence output = getResultAsPlain(representation);
|
||||
if (output == null) {
|
||||
output = String.valueOf(representation);
|
||||
}
|
||||
@ -241,9 +241,9 @@ public class PlaceholderServiceImpl implements PlaceholderService {
|
||||
case SUCCESS:
|
||||
replacement = result.getValue();
|
||||
if (replacement == null) {
|
||||
replacement = getResultAsString(null);
|
||||
replacement = getResultAsPlain(null);
|
||||
}
|
||||
if (StringUtils.isNotBlank(getResultAsString(replacement))) {
|
||||
if (StringUtils.isNotBlank(getResultAsPlain(replacement))) {
|
||||
return replacement;
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user