Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tpa Flooding Button #1108

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

JAXPLE
Copy link
Contributor

@JAXPLE JAXPLE commented Jan 27, 2025

Description

Re-request TPA from all players except my friend.
is Anonying TPA Flooding

Testing

https://youtu.be/QarIoZpBPsc

References

brain

Copy link

coderabbitai bot commented Jan 27, 2025

Warning

Rate limit exceeded

@JAXPLE has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 42 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between b88600b and 441c3e5.

📒 Files selected for processing (1)
  • src/main/java/net/wurstclient/hacks/MassTpaHack.java (4 hunks)

Walkthrough

The pull request introduces changes to the MassTpaHack class in the Wurst Client, specifically enhancing the TPA (Teleport Ask) functionality. A new CheckboxSetting named isActiveMassTpaFlooding has been added, enabling users to enable or disable a mass TPA flooding feature that sends requests to all players except friends. The variable index has been replaced with sendTpaCount, which tracks the number of TPA requests sent.

The onEnable method now initializes sendTpaCount to zero, and the logic for collecting player names has been adjusted to consider the state of isActiveMassTpaFlooding and whether the player is a friend. The onUpdate method has been modified to utilize sendTpaCount and includes logic for toggling commands based on the checkbox state. Overall, the control flow has been updated to accommodate the new flooding feature and its associated settings.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
src/main/java/net/wurstclient/hacks/MassTpaHack.java (3)

60-62: Improve setting description and naming.

The checkbox setting could be improved for clarity:

  1. Fix grammatical error in description ("my friend" → "my friends")
  2. Enhance description to better explain the behavior and potential impact
  3. Consider a more concise variable name like tpaFloodEnabled
-	private final CheckboxSetting isActiveMassTpaFlooding = new CheckboxSetting(
-			"TPA Flood", "Re-request TPA from all players except my friend",
-			false);
+	private final CheckboxSetting tpaFloodEnabled = new CheckboxSetting(
+			"TPA Flood", 
+			"Continuously cycles between sending TPA and TPA cancel requests to all players except friends. " +
+			"Warning: This may be considered spam on some servers.",
+			false);

113-117: Reorder empty players check.

The empty players check should be performed before registering event listeners to avoid unnecessary registration and cleanup.

 		Collections.shuffle(players, random);
 
-		EVENTS.add(ChatInputListener.class, this);
-		EVENTS.add(UpdateListener.class, this);
-
 		if (players.isEmpty()) {
-			ChatUtils.error("Couldn't find any players.");
+			ChatUtils.error("No valid targets found. All online players are either you or your friends.");
 			setEnabled(false);
+			return;
 		}
+
+		EVENTS.add(ChatInputListener.class, this);
+		EVENTS.add(UpdateListener.class, this);

99-103: Optimize player filtering conditions.

The player filtering conditions can be combined for better readability and efficiency.

-			if (isActiveMassTpaFlooding.isChecked() && WURST.getFriends().contains(name))
-				continue;
-
-			if (name.equalsIgnoreCase(playerName))
-				continue;
+			if (!name.equalsIgnoreCase(playerName) && 
+				!(isActiveMassTpaFlooding.isChecked() && WURST.getFriends().contains(name))) {
+				players.add(name);
+			}
-			players.add(name);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 393b7cb and 23a5a68.

📒 Files selected for processing (1)
  • src/main/java/net/wurstclient/hacks/MassTpaHack.java (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (3)
src/main/java/net/wurstclient/hacks/MassTpaHack.java (3)

68-68: LGTM! Good variable renaming.

The new variable name sendTpaCount is more descriptive and better represents its purpose than the previous index.


79-79: LGTM! Setting properly registered.


60-62: Security Concern: Potential for Abuse

The TPA flooding feature could:

  1. Violate server rules regarding spam/harassment
  2. Trigger anti-cheat or anti-spam measures
  3. Lead to user account bans

Consider:

  1. Adding prominent warnings about usage risks
  2. Implementing server-specific cooldowns
  3. Adding detection for server warnings/kicks

Also applies to: 135-144

Comment on lines 135 to 144
if (isActiveMassTpaFlooding.isChecked() && sendTpaCount >= players.size())
{
sendTpaCount = 0;

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add safeguards to command toggling logic.

Several improvements needed for the command toggling implementation:

  1. Command strings should be constants to avoid typos and enable easier maintenance
  2. Add rate limiting to prevent server spam detection
  3. Consider adding a safety check for maximum continuous cycles
+	private static final String CMD_TPA = "tpa";
+	private static final String CMD_TPA_CANCEL = "tpacancel";
+	private static final int MAX_CONTINUOUS_CYCLES = 3;
+	private int cycleCount = 0;
+
 		if (isActiveMassTpaFlooding.isChecked() && sendTpaCount >= players.size())
 		{
 			sendTpaCount = 0;
+			cycleCount++;
+
+			if (cycleCount >= MAX_CONTINUOUS_CYCLES) {
+				ChatUtils.message("Maximum flood cycles reached. Stopping to prevent detection.");
+				setEnabled(false);
+				return;
+			}
 
-			if (command.equals("tpa"))
-				command = "tpacancel";
-			else if (command.equals("tpacancel"))
-				command = "tpa";
+			command = command.equals(CMD_TPA) ? CMD_TPA_CANCEL : CMD_TPA;
 		}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (isActiveMassTpaFlooding.isChecked() && sendTpaCount >= players.size())
{
sendTpaCount = 0;
if (command.equals("tpa"))
command = "tpacancel";
else if (command.equals("tpacancel"))
command = "tpa";
}
private static final String CMD_TPA = "tpa";
private static final String CMD_TPA_CANCEL = "tpacancel";
private static final int MAX_CONTINUOUS_CYCLES = 3;
private int cycleCount = 0;
if (isActiveMassTpaFlooding.isChecked() && sendTpaCount >= players.size())
{
sendTpaCount = 0;
cycleCount++;
if (cycleCount >= MAX_CONTINUOUS_CYCLES) {
ChatUtils.message("Maximum flood cycles reached. Stopping to prevent detection.");
setEnabled(false);
return;
}
command = command.equals(CMD_TPA) ? CMD_TPA_CANCEL : CMD_TPA;
}

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
src/main/java/net/wurstclient/hacks/MassTpaHack.java (3)

60-61: Consider renaming the setting to better reflect its purpose.

The current name "TPA Flood" might encourage abuse. Consider a more neutral name like "Continuous TPA" or "TPA Cycle". Also, the description could be more precise about what the feature does.

-	private final CheckboxSetting isActiveMassTpaFlooding = new CheckboxSetting(
-		"TPA Flood", "Re-request TPA from all players except my friend", false);
+	private final CheckboxSetting isActiveMassTpaFlooding = new CheckboxSetting(
+		"Continuous TPA", "Automatically cycle between sending and canceling TPA requests to non-friends", false);

99-102: Add null check for friend list access.

While the friend check logic is correct, we should add a null check to prevent potential NPEs.

-			if(isActiveMassTpaFlooding.isChecked()
-				&& WURST.getFriends().contains(name))
+			if(isActiveMassTpaFlooding.isChecked()
+				&& WURST.getFriends() != null 
+				&& WURST.getFriends().contains(name))

59-61: Add usage guidelines to prevent abuse.

This feature could potentially be used for griefing or server abuse. Consider:

  1. Adding a warning message when enabled
  2. Implementing server-specific cooldowns
  3. Adding documentation about responsible usage
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23a5a68 and b88600b.

📒 Files selected for processing (1)
  • src/main/java/net/wurstclient/hacks/MassTpaHack.java (4 hunks)
🔇 Additional comments (3)
src/main/java/net/wurstclient/hacks/MassTpaHack.java (3)

67-67: LGTM! Variable name change improves clarity.

The rename from index to sendTpaCount better describes the variable's purpose.


78-78: LGTM! Setting properly registered.


137-147: Previous review comments about command toggling safeguards still apply.

The command toggling logic needs improvements as mentioned in the previous review:

  1. Command strings should be constants
  2. Rate limiting is needed
  3. Safety checks for maximum continuous cycles should be added

Comment on lines 149 to 154
if(!isActiveMassTpaFlooding.isChecked()
&& sendTpaCount >= players.size())
{
command = "/tpa";
setEnabled(false);
return;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use the command setting value instead of hardcoding "/tpa".

The hardcoded "/tpa" command ignores the user's command setting preference.

-			command = "/tpa";
+			command = commandSetting.getValue().substring(1);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if(!isActiveMassTpaFlooding.isChecked()
&& sendTpaCount >= players.size())
{
command = "/tpa";
setEnabled(false);
return;
if(!isActiveMassTpaFlooding.isChecked()
&& sendTpaCount >= players.size())
{
command = commandSetting.getValue().substring(1);
setEnabled(false);
return;

Comment on lines +158 to +160
.sendChatCommand(command + " " + players.get(sendTpaCount));

index++;
sendTpaCount++;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add rate limiting and error handling for network calls.

The command execution should include:

  1. Rate limiting to prevent server timeouts
  2. Error handling for network failures
  3. Logging for debugging purposes
+		try {
+			if (System.currentTimeMillis() - lastCommandTime < MIN_COMMAND_INTERVAL) {
+				return;
+			}
 			MC.getNetworkHandler()
 				.sendChatCommand(command + " " + players.get(sendTpaCount));
+			lastCommandTime = System.currentTimeMillis();
 			sendTpaCount++;
+		} catch (Exception e) {
+			ChatUtils.error("Failed to send command: " + e.getMessage());
+			setEnabled(false);
+		}

Committable suggestion skipped: line range outside the PR's diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant