diff --git a/src/main/java/net/wurstclient/mixin/MultiplayerScreenMixin.java b/src/main/java/net/wurstclient/mixin/MultiplayerScreenMixin.java index bb83c7a4..8b2761dc 100644 --- a/src/main/java/net/wurstclient/mixin/MultiplayerScreenMixin.java +++ b/src/main/java/net/wurstclient/mixin/MultiplayerScreenMixin.java @@ -31,6 +31,8 @@ public class MultiplayerScreenMixin extends Screen implements IMultiplayerScreen @Shadow protected MultiplayerServerListWidget serverListWidget; + private ButtonWidget lastServerButton; + private MultiplayerScreenMixin(WurstClient wurst, Text text_1) { super(text_1); @@ -54,6 +56,10 @@ public class MultiplayerScreenMixin extends Screen implements IMultiplayerScreen if(!WurstClient.INSTANCE.isEnabled()) return; + lastServerButton = addButton(new ButtonWidget(width / 2 - 154, 10, 100, + 20, "Last Server", b -> LastServerRememberer + .joinLastServer((MultiplayerScreen)(Object)this))); + addButton(new ButtonWidget(width / 2 + 154 + 4, height - 52, 100, 20, "Server Finder", b -> minecraft.openScreen( new ServerFinderScreen((MultiplayerScreen)(Object)this)))); @@ -63,6 +69,12 @@ public class MultiplayerScreenMixin extends Screen implements IMultiplayerScreen new CleanUpScreen((MultiplayerScreen)(Object)this)))); } + @Inject(at = {@At("TAIL")}, method = {"tick()V"}) + public void onTick(CallbackInfo ci) + { + lastServerButton.active = LastServerRememberer.getLastServer() != null; + } + @Inject(at = {@At("HEAD")}, method = {"connect(Lnet/minecraft/client/network/ServerInfo;)V"}) private void onConnect(ServerInfo entry, CallbackInfo ci) diff --git a/src/main/java/net/wurstclient/other_feature/OtfList.java b/src/main/java/net/wurstclient/other_feature/OtfList.java index 983366f3..9eace7a4 100644 --- a/src/main/java/net/wurstclient/other_feature/OtfList.java +++ b/src/main/java/net/wurstclient/other_feature/OtfList.java @@ -21,6 +21,7 @@ public final class OtfList public final CleanUpOtf cleanUpOtf = new CleanUpOtf(); public final DisableOtf disableOtf = new DisableOtf(); public final HackListOtf hackListOtf = new HackListOtf(); + public final LastServerOtf lastServerOtf = new LastServerOtf(); public final ServerFinderOtf serverFinderOtf = new ServerFinderOtf(); public final TabGuiOtf tabGuiOtf = new TabGuiOtf(); public final WurstCapesOtf wurstCapesOtf = new WurstCapesOtf(); diff --git a/src/main/java/net/wurstclient/other_features/LastServerOtf.java b/src/main/java/net/wurstclient/other_features/LastServerOtf.java new file mode 100644 index 00000000..5d6b045e --- /dev/null +++ b/src/main/java/net/wurstclient/other_features/LastServerOtf.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2014 - 2020 | Alexander01998 | All rights reserved. + * + * This source code is subject to the terms of the GNU General Public + * License, version 3. If a copy of the GPL was not distributed with this + * file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt + */ +package net.wurstclient.other_features; + +import net.wurstclient.SearchTags; +import net.wurstclient.other_feature.OtherFeature; + +@SearchTags({"last server"}) +public final class LastServerOtf extends OtherFeature +{ + public LastServerOtf() + { + super("LastServer", + "Wurst adds a \"Last Server\" button to the server selection\n" + + "screen that automatically brings you back to the last\n" + + "server you played on.\n\n" + + "Useful when you get kicked and/or have a lot of servers."); + } +}