Skip to content

Commit d2f34a6

Browse files
committed
OfflineSettings
1 parent e7bfed4 commit d2f34a6

File tree

15 files changed

+1843
-36
lines changed

15 files changed

+1843
-36
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,12 @@ Because so many of these mods are entirely original, I plan to release some of t
307307
- Deselect by holding SHIFT + P
308308
- Useful for aiding in the breaking of bedrock with TNT and pistons. New piston can be spawned in the same tick as explosion, breaking bedrock all while just standing near it.
309309

310+
### OfflineSettings
311+
- Auto Reconnect without 5 second timer, perfect for when you're logged out from another location
312+
- Rejoin the current server with a random alt, with an alt with a specific name or with the same name as another player
313+
- Auto detect cracked/offline servers on connect (even when hack is disabled)
314+
- Reconnect to server and immediately send a command, such as /op player
315+
- Adds mixin buttons to disconnect/kick/ban screens for all cracked/offline servers that have the above functions
310316

311317
## What’s changed or improved in this fork?
312318

@@ -444,6 +450,9 @@ Examples:
444450

445451
![Library](https://i.imgur.com/pWqgNz8.png)
446452

453+
### Alt Manager Improved
454+
- Can now multi-select and delete alt accounts
455+
447456
### Unsafe Chat Toast
448457
- Optional; toggle via NoChatReports or Wurst Options.
449458

src/main/java/net/wurstclient/altmanager/screens/AltManagerScreen.java

Lines changed: 73 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.nio.file.Path;
1717
import java.nio.file.Paths;
1818
import java.util.ArrayList;
19+
import java.util.Collections;
1920
import java.util.HashSet;
2021
import java.util.List;
2122
import java.util.Objects;
@@ -35,7 +36,6 @@
3536
import net.minecraft.client.gui.GuiGraphics;
3637
import net.minecraft.client.gui.components.AbstractWidget;
3738
import net.minecraft.client.gui.components.Button;
38-
import net.minecraft.client.gui.components.ObjectSelectionList;
3939
import net.minecraft.client.gui.components.Renderable;
4040
import net.minecraft.client.gui.components.events.GuiEventListener;
4141
import net.minecraft.client.gui.screens.AlertScreen;
@@ -51,6 +51,7 @@
5151
import net.minecraft.util.StringUtil;
5252
import net.wurstclient.WurstClient;
5353
import net.wurstclient.altmanager.*;
54+
import net.wurstclient.clickgui.widgets.MultiSelectEntryListWidget;
5455
import net.wurstclient.mixinterface.IMinecraftClient;
5556
import net.wurstclient.util.MultiProcessingUtils;
5657
import net.wurstclient.util.json.JsonException;
@@ -77,6 +78,8 @@ public final class AltManagerScreen extends Screen
7778
private Button exportButton;
7879
private Button logoutButton;
7980

81+
private List<Alt> pendingDeletion = Collections.emptyList();
82+
8083
public AltManagerScreen(Screen prevScreen, AltManager altManager)
8184
{
8285
super(Component.literal("Alt Manager"));
@@ -165,6 +168,7 @@ public void init()
165168
Button.builder(Component.literal("Logout"), b -> pressLogout())
166169
.bounds(width - 50 - 8, 8, 50, 20).build());
167170

171+
listGui.ensureSelection();
168172
updateAltButtons();
169173
boolean windowMode = !minecraft.options.fullscreen().get();
170174
importButton.active = windowMode;
@@ -173,11 +177,17 @@ public void init()
173177

174178
private void updateAltButtons()
175179
{
176-
boolean altSelected = listGui.getSelected() != null;
177-
useButton.active = altSelected;
178-
starButton.active = altSelected;
179-
editButton.active = altSelected;
180-
deleteButton.active = altSelected;
180+
if(useButton == null || starButton == null || editButton == null
181+
|| deleteButton == null || logoutButton == null)
182+
return;
183+
184+
int selectionCount = listGui != null ? listGui.getSelectionCount() : 0;
185+
boolean hasSingleSelection = selectionCount == 1;
186+
187+
useButton.active = hasSingleSelection;
188+
starButton.active = hasSingleSelection;
189+
editButton.active = hasSingleSelection;
190+
deleteButton.active = selectionCount > 0;
181191

182192
logoutButton.active =
183193
((IMinecraftClient)minecraft).getWurstSession() != null;
@@ -250,16 +260,27 @@ private void pressEdit()
250260

251261
private void pressDelete()
252262
{
253-
Alt alt = listGui.getSelectedAlt();
254-
if(alt == null)
263+
List<Alt> selected = listGui.getSelectedAlts();
264+
if(selected.isEmpty())
255265
return;
256266

257-
Component text =
258-
Component.literal("Are you sure you want to remove this alt?");
267+
pendingDeletion = List.copyOf(selected);
268+
boolean plural = pendingDeletion.size() > 1;
259269

260-
String altName = alt.getDisplayName();
261-
Component message = Component.literal(
262-
"\"" + altName + "\" will be lost forever! (A long time!)");
270+
Component text = plural ? Component.literal("Remove selected alts?")
271+
: Component.literal("Remove this alt?");
272+
273+
Component message;
274+
if(plural)
275+
{
276+
message = Component.literal(pendingDeletion.size()
277+
+ " accounts will be lost forever! (A long time!)");
278+
}else
279+
{
280+
String altName = pendingDeletion.get(0).getDisplayName();
281+
message = Component.literal(
282+
"\"" + altName + "\" will be lost forever! (A long time!)");
283+
}
263284

264285
ConfirmScreen screen = new ConfirmScreen(this::confirmRemove, text,
265286
message, Component.literal("Delete"), Component.literal("Cancel"));
@@ -398,13 +419,10 @@ private void confirmGenerate(boolean confirmed)
398419

399420
private void confirmRemove(boolean confirmed)
400421
{
401-
Alt alt = listGui.getSelectedAlt();
402-
if(alt == null)
403-
return;
404-
405422
if(confirmed)
406-
altManager.remove(alt);
423+
pendingDeletion.forEach(altManager::remove);
407424

425+
pendingDeletion = Collections.emptyList();
408426
minecraft.setScreen(this);
409427
}
410428

@@ -543,14 +561,23 @@ public void onClose()
543561
}
544562

545563
private final class Entry
546-
extends ObjectSelectionList.Entry<AltManagerScreen.Entry>
564+
extends MultiSelectEntryListWidget.Entry<AltManagerScreen.Entry>
547565
{
548566
private final Alt alt;
549567
private long lastClickTime;
568+
private final String selectionKey;
550569

551-
public Entry(Alt alt)
570+
public Entry(ListGui parent, Alt alt)
552571
{
572+
super(parent);
553573
this.alt = Objects.requireNonNull(alt);
574+
selectionKey = Integer.toHexString(System.identityHashCode(alt));
575+
}
576+
577+
@Override
578+
public String selectionKey()
579+
{
580+
return selectionKey;
554581
}
555582

556583
@Override
@@ -567,6 +594,8 @@ public boolean mouseClicked(MouseButtonEvent context,
567594
if(context.button() != GLFW.GLFW_MOUSE_BUTTON_LEFT)
568595
return false;
569596

597+
super.mouseClicked(context, doubleClick);
598+
570599
long timeSinceLastClick = Util.getMillis() - lastClickTime;
571600
lastClickTime = Util.getMillis();
572601

@@ -595,8 +624,9 @@ public void renderContent(GuiGraphics context, int mouseX, int mouseY,
595624
}
596625

597626
// face
627+
boolean selected = parent().getSelectedEntries().contains(this);
598628
AltRenderer.drawAltFace(context, alt.getName(), x + 1, y + 1, 24,
599-
24, listGui.getSelected() == this);
629+
24, selected);
600630

601631
Font tr = minecraft.font;
602632

@@ -626,15 +656,23 @@ else if(alt.isUncheckedPremium())
626656
}
627657

628658
private final class ListGui
629-
extends ObjectSelectionList<AltManagerScreen.Entry>
659+
extends MultiSelectEntryListWidget<AltManagerScreen.Entry>
630660
{
631661
public ListGui(Minecraft minecraft, AltManagerScreen screen,
632662
List<Alt> list)
633663
{
634664
super(minecraft, screen.width, screen.height - 96, 36, 30);
635665

636-
list.stream().map(AltManagerScreen.Entry::new)
666+
list.stream().map(alt -> new AltManagerScreen.Entry(this, alt))
637667
.forEach(this::addEntry);
668+
669+
setSelectionListener(screen::updateAltButtons);
670+
}
671+
672+
@Override
673+
protected String getSelectionKey(AltManagerScreen.Entry entry)
674+
{
675+
return entry.selectionKey();
638676
}
639677

640678
@Override
@@ -657,8 +695,18 @@ protected void clearEntries()
657695
*/
658696
public Alt getSelectedAlt()
659697
{
660-
AltManagerScreen.Entry selected = getSelected();
661-
return selected != null ? selected.alt : null;
698+
return getSelectedAlts().stream().findFirst().orElse(null);
699+
}
700+
701+
public List<Alt> getSelectedAlts()
702+
{
703+
return getSelectedEntries().stream().map(entry -> entry.alt)
704+
.toList();
705+
}
706+
707+
public int getSelectionCount()
708+
{
709+
return getSelectedEntries().size();
662710
}
663711

664712
/**

0 commit comments

Comments
 (0)