Skip to content

Commit

Permalink
Merge branch 'MassTap-Scheduler' into LogOutSpot
Browse files Browse the repository at this point in the history
  • Loading branch information
JAXPLE committed Feb 9, 2025
2 parents db93560 + 7323fc4 commit 6eae08f
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions src/main/java/net/wurstclient/hacks/MassTpaHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,14 @@ public final class MassTpaHack extends Hack
+ " requests when someone accepts one of them.",
true);

private final CheckboxSetting isActiveMassTpaFlooding = new CheckboxSetting(
"TPA Flood", "Re-request TPA from all players except my friend", false);

private final Random random = new Random();
private final ArrayList<String> players = new ArrayList<>();

private String command;
private int index;
private int sendTpaCount;
private int timer;

public MassTpaHack()
Expand All @@ -72,14 +75,15 @@ public MassTpaHack()
addSetting(delay);
addSetting(ignoreErrors);
addSetting(stopWhenAccepted);
addSetting(isActiveMassTpaFlooding);
}

@Override
protected void onEnable()
{
// reset state
players.clear();
index = 0;
sendTpaCount = 0;
timer = 0;

// cache command in case the setting is changed mid-run
Expand All @@ -92,6 +96,10 @@ protected void onEnable()
String name = info.getProfile().getName();
name = StringHelper.stripTextFormat(name);

if(isActiveMassTpaFlooding.isChecked()
&& WURST.getFriends().contains(name))
continue;

if(name.equalsIgnoreCase(playerName))
continue;

Expand Down Expand Up @@ -126,16 +134,30 @@ public void onUpdate()
return;
}

if(index >= players.size())
if(isActiveMassTpaFlooding.isChecked()
&& sendTpaCount >= players.size())
{
sendTpaCount = 0;

if(command.equals("tpa"))
command = "tpacancel";

else if(command.equals("tpacancel"))
command = "tpa";
}

if(!isActiveMassTpaFlooding.isChecked()
&& sendTpaCount >= players.size())
{
command = commandSetting.getValue().substring(1);
setEnabled(false);
return;
}

MC.getNetworkHandler()
.sendChatCommand(command + " " + players.get(index));
.sendChatCommand(command + " " + players.get(sendTpaCount));

index++;
sendTpaCount++;
timer = delay.getValueI() - 1;
}

Expand Down

0 comments on commit 6eae08f

Please sign in to comment.