From 6636c289f7e740431357f9d10bd0c91486269b3c Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Thu, 9 May 2024 11:55:21 -0500 Subject: [PATCH] Address some warnings --- .../gaming32/worldhost/gui/widget/FriendsButton.java | 2 +- .../worldhost/gui/widget/OnlineStatusButton.java | 12 ++++++------ .../gaming32/worldhost/protocol/ProtocolClient.java | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java index d158679..0c04298 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java @@ -18,7 +18,7 @@ //$$ import com.mojang.blaze3d.vertex.PoseStack; //#endif -public class FriendsButton extends Button implements FriendsListUpdate { +public final class FriendsButton extends Button implements FriendsListUpdate { private int bgX, bgWidth; public FriendsButton(int x, int y, int width, int height, OnPress onPress) { diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/OnlineStatusButton.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/OnlineStatusButton.java index 73f7803..27bc6ef 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/OnlineStatusButton.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/OnlineStatusButton.java @@ -13,6 +13,7 @@ import net.minecraft.network.chat.Style; import org.jetbrains.annotations.NotNull; +import java.util.List; import java.util.function.Supplier; //#if MC >= 1.20.0 @@ -27,19 +28,18 @@ //$$ import io.github.gaming32.worldhost.gui.PlainTextButton; //#endif -public class OnlineStatusButton extends PlainTextButton { +public final class OnlineStatusButton extends PlainTextButton { private static final ChatFormatting[] COLORS = { ChatFormatting.RED, ChatFormatting.GOLD, ChatFormatting.DARK_GREEN }; - @SuppressWarnings("unchecked") - private static final Supplier[] TEXTS = new Supplier[] { + private static final List> TEXTS = List.of( () -> Components.translatable("world-host.online_status.offline", WorldHost.reconnectDelay / 20 + 1), () -> Components.translatable("world-host.online_status.connecting"), () -> Components.translatable("world-host.online_status.online") - }; + ); private final int alignedX; private final boolean rightAlign; @@ -87,7 +87,7 @@ private static Component generateStatusComponent() { return Components.translatable( "world-host.online_status", Components.literal("\u25cf").withStyle(COLORS[status]), - TEXTS[status].get() + TEXTS.get(status).get() ); } @@ -110,7 +110,7 @@ private static Component generateStatusComponent() { final int status = getStatus(); if (status != currentStatus || (status == 0 && (WorldHost.reconnectDelay + 1) % 20 == 0)) { currentStatus = status; - final var accessor = (PlainTextButtonAccessor)this; + final var accessor = (PlainTextButtonAccessor)(Object)this; final Component message = generateStatusComponent(); setMessage(message); accessor.setPTBMessage(message); diff --git a/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java b/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java index a4f6f77..f5fa30f 100644 --- a/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java +++ b/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java @@ -24,7 +24,7 @@ import java.util.concurrent.Future; import java.util.concurrent.LinkedBlockingQueue; -public class ProtocolClient implements AutoCloseable, ProxyPassthrough { +public final class ProtocolClient implements AutoCloseable, ProxyPassthrough { public static final int PROTOCOL_VERSION = 5; private final String originalHost;