mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2025-02-04 23:52:39 +01:00
Fix null input on FormattedText
This commit is contained in:
parent
99912dc937
commit
99ac8ac130
@ -23,16 +23,26 @@
|
||||
|
||||
package com.discordsrv.api.placeholder.format;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents content that doesn't need to be processed for the purposes of DiscordSRV's processing.
|
||||
*/
|
||||
public class FormattedText implements CharSequence {
|
||||
|
||||
@Contract(value = "null -> null; !null -> new", pure = true)
|
||||
public static FormattedText of(@Nullable CharSequence text) {
|
||||
if (text == null) {
|
||||
return null;
|
||||
}
|
||||
return new FormattedText(text);
|
||||
}
|
||||
|
||||
private final CharSequence text;
|
||||
|
||||
public FormattedText(CharSequence text) {
|
||||
private FormattedText(@NotNull CharSequence text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class ComponentResultStringifier implements PlaceholderResultMapper {
|
||||
case PLAIN:
|
||||
return discordSRV.componentFactory().plainSerializer().serialize(component);
|
||||
case DISCORD:
|
||||
return new FormattedText(discordSRV.componentFactory().discordSerialize(component));
|
||||
return FormattedText.of(discordSRV.componentFactory().discordSerialize(component));
|
||||
case ANSI:
|
||||
return discordSRV.componentFactory().ansiSerializer().serialize(component);
|
||||
case LEGACY:
|
||||
|
@ -197,6 +197,6 @@ public class DiscordInviteModule extends AbstractModule<DiscordSRV> {
|
||||
|
||||
@Placeholder("discord_invite")
|
||||
public CharSequence getInvite() {
|
||||
return new FormattedText(invite != null ? invite : UNKNOWN_INVITE);
|
||||
return FormattedText.of(invite != null ? invite : UNKNOWN_INVITE);
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ public class MinecraftToDiscordChatModule extends AbstractGameMessageModule<Mine
|
||||
}
|
||||
|
||||
String finalMessage = messagePlaceholders.toString();
|
||||
return new FormattedText(preventEveryoneMentions(everyoneMentionAllowed, finalMessage));
|
||||
return FormattedText.of(preventEveryoneMentions(everyoneMentionAllowed, finalMessage));
|
||||
})
|
||||
.applyPlaceholderService()
|
||||
.build();
|
||||
|
@ -50,7 +50,7 @@ public final class GamePermissionUtil {
|
||||
}
|
||||
|
||||
String data = meta.getMeta(uuid, metaKey).join();
|
||||
return new FormattedText(data);
|
||||
return FormattedText.of(data);
|
||||
}
|
||||
|
||||
public static Component getPrefix(DiscordSRV discordSRV, UUID uuid) {
|
||||
|
Loading…
Reference in New Issue
Block a user