From 5507ad3bc5e0e8203de8eeccbcc41927030bc106 Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Sat, 17 Feb 2024 20:35:33 +0100 Subject: [PATCH] Random code cleanup --- .../mixin/base/integration/MixinAddServerScreen.java | 8 ++------ .../mixin/base/integration/MixinDirectConnectScreen.java | 9 ++------- .../mixin/base/integration/MixinMultiplayerScreen.java | 9 ++------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinAddServerScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinAddServerScreen.java index 2ce98f6f..bf7c7cce 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinAddServerScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinAddServerScreen.java @@ -78,7 +78,6 @@ public abstract class MixinAddServerScreen extends Screen { viaFabricPlus$addressField = null; } - // Create the button ButtonWidget.Builder buttonBuilder = ButtonWidget.builder(forcedVersion == null ? Text.translatable("base.viafabricplus.set_version") : Text.literal(forcedVersion.getName()), button -> { // Store current input in case the user cancels the version selection viaFabricPlus$nameField = serverNameField.getText(); @@ -87,11 +86,8 @@ public abstract class MixinAddServerScreen extends Screen { client.setScreen(new PerServerVersionScreen(this, version -> ((IServerInfo) server).viaFabricPlus$forceVersion(version))); }).size(98, 20); - // Set the button's position according to the configured orientation - buttonBuilder = GeneralSettings.withOrientation(buttonBuilder, buttonPosition, width, height); - - // Add the button to the screen - this.addDrawableChild(buttonBuilder.build()); + // Set the button's position according to the configured orientation and add the button to the screen + this.addDrawableChild(GeneralSettings.withOrientation(buttonBuilder, buttonPosition, width, height).build()); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinDirectConnectScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinDirectConnectScreen.java index 5ac23c64..0507c22e 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinDirectConnectScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinDirectConnectScreen.java @@ -43,15 +43,10 @@ public abstract class MixinDirectConnectScreen extends Screen { if (buttonPosition == 0) { // Off return; } - - // Create the button ButtonWidget.Builder builder = ButtonWidget.builder(Text.literal("ViaFabricPlus"), button -> ProtocolSelectionScreen.INSTANCE.open(this)).size(98, 20); - // Set the button's position according to the configured orientation - builder = GeneralSettings.withOrientation(builder, buttonPosition, width, height); - - // Add the button to the screen - this.addDrawableChild(builder.build()); + // Set the button's position according to the configured orientation and add the button to the screen + this.addDrawableChild(GeneralSettings.withOrientation(builder, buttonPosition, width, height).build()); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerScreen.java index 0a07f3c3..ecec0977 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerScreen.java @@ -43,15 +43,10 @@ public abstract class MixinMultiplayerScreen extends Screen { if (buttonPosition == 0) { // Off return; } - - // Create the button ButtonWidget.Builder builder = ButtonWidget.builder(Text.literal("ViaFabricPlus"), button -> ProtocolSelectionScreen.INSTANCE.open(this)).size(98, 20); - // Set the button's position according to the configured orientation - builder = GeneralSettings.withOrientation(builder, buttonPosition, width, height); - - // Add the button to the screen - this.addDrawableChild(builder.build()); + // Set the button's position according to the configured orientation and add the button to the screen + this.addDrawableChild(GeneralSettings.withOrientation(builder, buttonPosition, width, height).build()); } }