diff --git a/src/main/java/de/florianmichael/viafabricplus/base/screen/VFPScreen.java b/src/main/java/de/florianmichael/viafabricplus/base/screen/VFPScreen.java index ad25f10b5..02078f2a4 100644 --- a/src/main/java/de/florianmichael/viafabricplus/base/screen/VFPScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/base/screen/VFPScreen.java @@ -40,7 +40,7 @@ */ public class VFPScreen extends Screen { - private static final String MOD_URL = "https://github.com/ViaVersion/ViaFabricPlus"; + private final static String MOD_URL = "https://github.com/ViaVersion/ViaFabricPlus"; private final boolean backButton; public Screen prevScreen; @@ -62,9 +62,19 @@ public VFPScreen(final String title, final boolean backButton) { * */ public void setupDefaultSubtitle() { - this.setupSubtitle(Text.of(MOD_URL), ConfirmLinkScreen.opening(MOD_URL, this, true)); + this.setupUrlSubtitle(MOD_URL); } + /** + * Sets the subtitle and the subtitle press action to the default values + * + * @param subtitle The subtitle which should be rendered + */ + public void setupUrlSubtitle(final String subtitle) { + this.setupSubtitle(Text.of(subtitle), ConfirmLinkScreen.opening(subtitle, this, true)); + } + + /*** * Sets the subtitle and the subtitle press action * @@ -83,7 +93,8 @@ public void setupSubtitle(@Nullable final Text subtitle) { public void setupSubtitle(@Nullable final Text subtitle, @Nullable final ButtonWidget.PressAction subtitlePressAction) { this.subtitle = subtitle; this.subtitlePressAction = subtitlePressAction; - if (subtitleWidget != null && subtitlePressAction == null) { + + if (subtitleWidget != null && subtitlePressAction == null) { // Allows to remove the subtitle when calling this method twice. remove(subtitleWidget); subtitleWidget = null; } @@ -162,7 +173,7 @@ public static void playClickSound() { /** * Opens an error screen with a specific title and throws the given throwable * - * @param title The title of the error screen + * @param title The title of the error screen * @param throwable The throwable which should be thrown */ public void showErrorScreen(final String title, final Throwable throwable) { diff --git a/src/main/java/de/florianmichael/viafabricplus/definition/boat/BoatModel_1_8.java b/src/main/java/de/florianmichael/viafabricplus/definition/boat/BoatModel_1_8.java index 7271a4808..10f8dbc22 100644 --- a/src/main/java/de/florianmichael/viafabricplus/definition/boat/BoatModel_1_8.java +++ b/src/main/java/de/florianmichael/viafabricplus/definition/boat/BoatModel_1_8.java @@ -25,7 +25,7 @@ import net.minecraft.util.Identifier; public class BoatModel_1_8 extends CompositeEntityModel { - public static final EntityModelLayer MODEL_LAYER = new EntityModelLayer(new Identifier("viafabricplus", "boat_1_8"), "main"); + public final static EntityModelLayer MODEL_LAYER = new EntityModelLayer(new Identifier("viafabricplus", "boat_1_8"), "main"); private final ImmutableList parts; public BoatModel_1_8(ModelPart root) { diff --git a/src/main/java/de/florianmichael/viafabricplus/definition/boat/BoatRenderer_1_8.java b/src/main/java/de/florianmichael/viafabricplus/definition/boat/BoatRenderer_1_8.java index 6b3180144..a5823cae7 100644 --- a/src/main/java/de/florianmichael/viafabricplus/definition/boat/BoatRenderer_1_8.java +++ b/src/main/java/de/florianmichael/viafabricplus/definition/boat/BoatRenderer_1_8.java @@ -29,7 +29,7 @@ import net.minecraft.util.math.RotationAxis; public class BoatRenderer_1_8 extends EntityRenderer { - private static final Identifier TEXTURE = new Identifier("viafabricplus", "textures/boat_1_8.png"); + private final static Identifier TEXTURE = new Identifier("viafabricplus", "textures/boat_1_8.png"); private final BoatModel_1_8 model; public BoatRenderer_1_8(EntityRendererFactory.Context ctx) { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinNamedCompoundTagType.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinNamedCompoundTagType.java index 4a8b619f2..87de82800 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinNamedCompoundTagType.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinNamedCompoundTagType.java @@ -28,7 +28,7 @@ public class MixinNamedCompoundTagType { @Unique - private static final TagLimiter viafabricplus_tag_limiter = new TagLimiter() { + private final static TagLimiter viafabricplus_tag_limiter = new TagLimiter() { private final int maxBytes = 2097152; private int bytes; diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/thirdparty/BetaCraftScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/thirdparty/BetaCraftScreen.java index 43626ed8b..6d215754a 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/thirdparty/BetaCraftScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/thirdparty/BetaCraftScreen.java @@ -41,7 +41,7 @@ public class BetaCraftScreen extends VFPScreen { public static BCServerList SERVER_LIST; public final static BetaCraftScreen INSTANCE = new BetaCraftScreen(); - private static final String BETA_CRAFT_SERVER_LIST_URL = "https://betacraft.uk/serverlist/"; + private final static String BETA_CRAFT_SERVER_LIST_URL = "https://betacraft.uk/serverlist/"; protected BetaCraftScreen() { super("BetaCraft", true); diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/thirdparty/classicube/ClassiCubeLoginScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/thirdparty/classicube/ClassiCubeLoginScreen.java index d4f4e78f8..963a0f39a 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/thirdparty/classicube/ClassiCubeLoginScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/thirdparty/classicube/ClassiCubeLoginScreen.java @@ -34,7 +34,7 @@ public class ClassiCubeLoginScreen extends VFPScreen { public final static ClassiCubeLoginScreen INSTANCE = new ClassiCubeLoginScreen(); - private static final String CLASSI_CUBE_URL = "https://www.classicube.net/"; + private final static String CLASSI_CUBE_URL = "https://www.classicube.net/"; public ClassiCubeLoginScreen() { super("ClassiCube Login", false); diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/thirdparty/classicube/ClassiCubeMFAScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/thirdparty/classicube/ClassiCubeMFAScreen.java index 2e1de2aa2..530d4a912 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/thirdparty/classicube/ClassiCubeMFAScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/thirdparty/classicube/ClassiCubeMFAScreen.java @@ -41,14 +41,12 @@ public ClassiCubeMFAScreen() { @Override public void open(Screen prevScreen) { - status = Classic4JImpl.fromError(CCError.LOGIN_CODE); + this.setupSubtitle(Classic4JImpl.fromError(CCError.LOGIN_CODE)); super.open(prevScreen); } private TextFieldWidget mfaField; - private Text status; - @Override protected void init() { super.init(); @@ -58,7 +56,7 @@ protected void init() { mfaField.setPlaceholder(Text.literal("MFA")); this.addDrawableChild(ButtonWidget.builder(Text.literal("Login"), button -> { - status = Text.translatable("classicube.viafabricplus.loading"); + this.setupSubtitle(Text.translatable("classicube.viafabricplus.loading")); final CCAccount account = ClassiCubeAccountHandler.INSTANCE.getAccount(); ClassiCubeHandler.requestAuthentication(account, mfaField.getText(), new LoginProcessHandler() { @@ -74,7 +72,7 @@ public void handleSuccessfulLogin(CCAccount account) { @Override public void handleException(Throwable throwable) { - status = Text.literal(throwable.getMessage()); + setupSubtitle(Text.literal(throwable.getMessage())); } }); }).position(width / 2 - 75, mfaField.getY() + (20 * 4) + 5).size(150, 20).build()); @@ -90,7 +88,8 @@ public void close() { public void render(DrawContext context, int mouseX, int mouseY, float delta) { this.renderBackground(context, mouseX, mouseY, delta); context.drawCenteredTextWithShadow(this.textRenderer, this.title, this.width / 2, 70, 16777215); - context.drawCenteredTextWithShadow(this.textRenderer, this.status, this.width / 2, 1, 16777215); + + this.renderSubtitle(context); super.render(context, mouseX, mouseY, delta); } diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/thirdparty/classicube/ClassiCubeServerListScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/thirdparty/classicube/ClassiCubeServerListScreen.java index 0d96855d4..1f7baf295 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/thirdparty/classicube/ClassiCubeServerListScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/thirdparty/classicube/ClassiCubeServerListScreen.java @@ -20,7 +20,6 @@ import com.mojang.blaze3d.systems.RenderSystem; import de.florianmichael.classic4j.ClassiCubeHandler; import de.florianmichael.classic4j.api.LoginProcessHandler; -import de.florianmichael.classic4j.model.classicube.account.CCAccount; import de.florianmichael.classic4j.model.classicube.server.CCServerInfo; import de.florianmichael.viafabricplus.base.screen.MappedSlotEntry; import de.florianmichael.viafabricplus.base.screen.VFPScreen; @@ -32,7 +31,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.ConfirmLinkScreen; import net.minecraft.client.gui.screen.ConnectScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget; @@ -50,7 +48,7 @@ public class ClassiCubeServerListScreen extends VFPScreen { public final static List SERVER_LIST = new ArrayList<>(); public final static ClassiCubeServerListScreen INSTANCE = new ClassiCubeServerListScreen(); - private static final String CLASSI_CUBE_SERVER_LIST_URL = "https://www.classicube.net/server/list/"; + private final static String CLASSICUBE_SERVER_LIST_URL = "https://www.classicube.net/server/list/"; public static void open(final Screen prevScreen, final LoginProcessHandler loginProcessHandler) { ClassiCubeHandler.requestServerList(ClassiCubeAccountHandler.INSTANCE.getAccount(), ccServerList -> { @@ -61,13 +59,10 @@ public static void open(final Screen prevScreen, final LoginProcessHandler login public ClassiCubeServerListScreen() { super("ClassiCube ServerList", true); - final CCAccount account = ClassiCubeAccountHandler.INSTANCE.getAccount(); + + final var account = ClassiCubeAccountHandler.INSTANCE.getAccount(); if (account != null) { - this.setupSubtitle(Text.of(CLASSI_CUBE_SERVER_LIST_URL), ConfirmLinkScreen.opening( - CLASSI_CUBE_SERVER_LIST_URL, - this, - true - )); + this.setupUrlSubtitle(CLASSICUBE_SERVER_LIST_URL); } } @@ -94,22 +89,11 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) { this.renderBackground(context, mouseX, mouseY, delta); super.render(context, mouseX, mouseY, delta); this.renderTitle(context); - final CCAccount account = ClassiCubeAccountHandler.INSTANCE.getAccount(); + + final var account = ClassiCubeAccountHandler.INSTANCE.getAccount(); if (account != null) { - context.drawTextWithShadow( - textRenderer, - Text.of("ClassiCube Profile: "), - 32, - 6, - -1 - ); - context.drawTextWithShadow( - textRenderer, - Text.of(account.username()), - 32, - 16, - -1 - ); + context.drawTextWithShadow(textRenderer, Text.of("ClassiCube Profile:"), 32, 6, -1); + context.drawTextWithShadow(textRenderer, Text.of(account.username()), 32, 16, -1); } }