Skip to content

Commit

Permalink
Components.immutable -> Components.nullToEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed May 10, 2024
1 parent 4be1c04 commit c23daaa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
Expand Up @@ -210,7 +210,7 @@ public FriendsEntry(GameProfile profile) {
@NotNull
@Override
public Component getNarration() {
return Components.immutable(getName());
return Components.literal(getName());
}

@Override
Expand Down
Expand Up @@ -64,7 +64,7 @@ public ProtocolClient(String host, boolean successToast, boolean failureToast) {
WorldHost.LOGGER.error("Failed to connect to {}.", target, e);
if (failureToast) {
WHToast.builder("world-host.wh_connect.connect_failed")
.description(Components.immutable(e.getLocalizedMessage()))
.description(Components.nullToEmpty(e.getLocalizedMessage()))
.show();
}
if (socket != null) {
Expand All @@ -74,7 +74,7 @@ public ProtocolClient(String host, boolean successToast, boolean failureToast) {
WorldHost.LOGGER.error("Failed to close WH socket", e1);
if (failureToast) {
WHToast.builder("world-host.wh_connect.close_failed")
.description(Components.immutable(e1.getLocalizedMessage()))
.description(Components.nullToEmpty(e1.getLocalizedMessage()))
.show();
}
}
Expand Down Expand Up @@ -170,7 +170,7 @@ public ProtocolClient(String host, boolean successToast, boolean failureToast) {
WorldHost.LOGGER.error("Failed to close WH socket.", e);
if (WorldHost.CONFIG.isEnableReconnectionToasts()) {
WHToast.builder("world-host.wh_connect.close_failed")
.description(Components.immutable(e.getLocalizedMessage()))
.description(Components.nullToEmpty(e.getLocalizedMessage()))
.show();
}
}
Expand Down
Expand Up @@ -31,7 +31,7 @@ public Error(String message) {
public void handle(ProtocolClient client) {
if (critical) {
WHToast.builder("world-host.protocol_error_occurred")
.description(Components.immutable(message))
.description(Components.literal(message))
.show();
throw new RuntimeException(message);
} else {
Expand Down
Expand Up @@ -3,6 +3,7 @@
import com.demonwav.mcdev.annotations.Translatable;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.MutableComponent;
Expand All @@ -13,7 +14,11 @@
//#endif

public class Components {
public static final Component EMPTY = immutable("");
//#if MC >= 1.19.2
public static final Component EMPTY = CommonComponents.EMPTY;
//#else
//$$ public static final Component EMPTY = TextComponent.EMPTY;
//#endif

public static MutableComponent literal(String text) {
//#if MC >= 1.19.1
Expand Down Expand Up @@ -41,7 +46,7 @@ public static MutableComponent translatable(@Translatable(foldMethod = true) Str
//#endif
}

public static Component immutable(String text) {
public static Component nullToEmpty(String text) {
return Component.nullToEmpty(text);
}

Expand Down

0 comments on commit c23daaa

Please sign in to comment.