Skip to content

Commit a60601e

Browse files
committed
TooManyHax and Panic Improvements
1 parent 8278045 commit a60601e

File tree

8 files changed

+437
-12
lines changed

8 files changed

+437
-12
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,12 @@ Examples:
263263
- Keeps results anchored as you move. Default OFF.
264264
- Greatly helps with FPS when using things like Search or X-Ray and moving quickly
265265

266+
### TooManyHax Improved
267+
- Submenu of TooManyHax in the ClickUI/Navigator shows a list of toggleable hacks instead of needing to manually enter the name of each one via cmd.
268+
269+
### Panic Improved
270+
- It now saves your current enabled hacks and allows you to restore them via ClickUI/Navigator or keybind.
271+
266272
### Unsafe Chat Toast
267273
- Optional; toggle via NoChatReports or Wurst Options.
268274

src/main/java/net/wurstclient/WurstClient.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ public void setEnabled(boolean enabled)
309309
if(!enabled)
310310
{
311311
hax.panicHack.setEnabled(true);
312-
hax.panicHack.onUpdate();
313312
}
314313
}
315314

src/main/java/net/wurstclient/command/CmdList.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public final class CmdList
4747
public final LeaveCmd leaveCmd = new LeaveCmd();
4848
public final ModifyCmd modifyCmd = new ModifyCmd();
4949
public final PathCmd pathCmd = new PathCmd();
50+
public final PanicCmd panicCmd = new PanicCmd();
5051
public final PotionCmd potionCmd = new PotionCmd();
5152
public final ProtectCmd protectCmd = new ProtectCmd();
5253
public final RenameCmd renameCmd = new RenameCmd();
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (c) 2014-2025 Wurst-Imperium and contributors.
3+
*
4+
* This source code is subject to the terms of the GNU General Public
5+
* License, version 3. If a copy of the GPL was not distributed with this
6+
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
7+
*/
8+
package net.wurstclient.commands;
9+
10+
import net.wurstclient.command.CmdException;
11+
import net.wurstclient.command.CmdSyntaxError;
12+
import net.wurstclient.command.Command;
13+
import net.wurstclient.hacks.PanicHack;
14+
15+
public final class PanicCmd extends Command
16+
{
17+
public PanicCmd()
18+
{
19+
super("panic",
20+
"Quickly disables every enabled hack and allows restoring them.",
21+
".panic", ".panic restore");
22+
}
23+
24+
@Override
25+
public void call(String[] args) throws CmdException
26+
{
27+
if(args.length > 1)
28+
throw new CmdSyntaxError();
29+
30+
PanicHack panic = WURST.getHax().panicHack;
31+
32+
if(args.length == 0)
33+
{
34+
panic.setEnabled(true);
35+
return;
36+
}
37+
38+
if("restore".equalsIgnoreCase(args[0]))
39+
{
40+
panic.restoreSavedHacks();
41+
return;
42+
}
43+
44+
throw new CmdSyntaxError();
45+
}
46+
}

src/main/java/net/wurstclient/hacks/PanicHack.java

Lines changed: 74 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,106 @@
77
*/
88
package net.wurstclient.hacks;
99

10+
import java.util.LinkedHashSet;
11+
import java.util.Set;
12+
1013
import net.wurstclient.Category;
1114
import net.wurstclient.DontBlock;
1215
import net.wurstclient.SearchTags;
13-
import net.wurstclient.events.UpdateListener;
1416
import net.wurstclient.hack.Hack;
17+
import net.wurstclient.hack.HackList;
18+
import net.wurstclient.settings.ButtonSetting;
19+
import net.wurstclient.util.ChatUtils;
20+
import net.wurstclient.util.text.WText;
1521

1622
@SearchTags({"legit", "disable"})
1723
@DontBlock
18-
public final class PanicHack extends Hack implements UpdateListener
24+
public final class PanicHack extends Hack
1925
{
26+
private final Set<String> savedHackNames = new LinkedHashSet<>();
27+
28+
private final ButtonSetting restoreButton = new ButtonSetting(
29+
"Restore saved hacks",
30+
WText.literal(
31+
"Re-enables the hacks that were active when Panic was triggered."),
32+
this::restoreSavedHacks);
33+
2034
public PanicHack()
2135
{
2236
super("Panic");
2337
setCategory(Category.OTHER);
38+
addSetting(restoreButton);
39+
addPossibleKeybind("panic restore", "Restore hacks saved by Panic");
2440
}
2541

2642
@Override
2743
protected void onEnable()
2844
{
29-
EVENTS.add(UpdateListener.class, this);
45+
int saved = snapshotEnabledHacks();
46+
disableOtherHacks();
47+
setEnabled(false);
48+
49+
if(saved > 0)
50+
ChatUtils
51+
.message("Disabled " + saved + " hack" + (saved == 1 ? "" : "s")
52+
+ ". Use \"Restore saved hacks\" to re-enable them.");
53+
else
54+
ChatUtils.message("No other hacks were enabled.");
3055
}
3156

32-
@Override
33-
protected void onDisable()
57+
private int snapshotEnabledHacks()
3458
{
35-
EVENTS.remove(UpdateListener.class, this);
59+
savedHackNames.clear();
60+
61+
for(Hack hack : WURST.getHax().getAllHax())
62+
if(hack.isEnabled() && hack != this)
63+
savedHackNames.add(hack.getName());
64+
65+
return savedHackNames.size();
3666
}
3767

38-
@Override
39-
public void onUpdate()
68+
private void disableOtherHacks()
4069
{
4170
for(Hack hack : WURST.getHax().getAllHax())
4271
if(hack.isEnabled() && hack != this)
4372
hack.setEnabled(false);
73+
}
74+
75+
public void restoreSavedHacks()
76+
{
77+
if(savedHackNames.isEmpty())
78+
{
79+
ChatUtils.error("There is no saved Panic state to restore.");
80+
return;
81+
}
82+
83+
HackList hax = WURST.getHax();
84+
Set<String> missing = new LinkedHashSet<>();
85+
int restored = 0;
86+
87+
for(String name : savedHackNames)
88+
{
89+
Hack hack = hax.getHackByName(name);
90+
if(hack == null || hack == this)
91+
{
92+
missing.add(name);
93+
continue;
94+
}
4495

45-
setEnabled(false);
96+
boolean wasEnabled = hack.isEnabled();
97+
hack.setEnabled(true);
98+
if(!wasEnabled && hack.isEnabled())
99+
restored++;
100+
}
101+
102+
if(!missing.isEmpty())
103+
savedHackNames.removeAll(missing);
104+
105+
if(restored > 0)
106+
ChatUtils.message("Restored " + restored + " hack"
107+
+ (restored == 1 ? "" : "s") + " from Panic.");
108+
else
109+
ChatUtils.message(
110+
"All saved Panic hacks are already enabled or blocked.");
46111
}
47112
}

0 commit comments

Comments
 (0)