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

AutoSteal Whitelist #914

Closed
wants to merge 21 commits into from
Closed

AutoSteal Whitelist #914

wants to merge 21 commits into from

Conversation

mdenials
Copy link
Contributor

Added a whitelist for autosteal

Copy link

coderabbitai bot commented Dec 17, 2023

Warning

Rate Limit Exceeded

@mdenials has exceeded the limit for the number of files or commits that can be reviewed per hour. Please wait 10 minutes and 53 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. 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 Files that changed from the base of the PR and between eea5463 and 5f04867.

Walkthrough

The changes involve enhancing an AutoStealHack in a Minecraft client mod by adding new settings that allow users to filter unwanted items and toggle the filter functionality. The updates focus on the implementation of conditional logic in various screen mixins to check against these new settings when shift-clicking slots, ensuring that only desired items are automatically stolen based on the user's configuration.

Changes

File(s) Change Summary
.../hacks/AutoStealHack.java Added ItemListSetting and CheckboxSetting for item filters, updated addSetting, and added methods to handle new settings.
.../mixin/GenericContainerScreenMixin.java, .../mixin/ShulkerBoxScreenMixin.java Modified shiftClickSlots method to incorporate new item handling logic with conditional checks based on the autoSteal settings and introduced relevant variables and imports.

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 X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

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.

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between be4da08 and 48ae2c0.
Files selected for processing (3)
  • src/main/java/net/wurstclient/hacks/AutoStealHack.java (1 hunks)
  • src/main/java/net/wurstclient/mixin/GenericContainerScreenMixin.java (2 hunks)
  • src/main/java/net/wurstclient/mixin/ShulkerBoxScreenMixin.java (2 hunks)
Additional comments: 8
src/main/java/net/wurstclient/hacks/AutoStealHack.java (2)
  • 61-74: The new methods areFilterEnabled and getItemList are implemented correctly and follow Java best practices for getter methods.

  • 50-52: The addition of the new settings to the addSetting method is correct and ensures that they are registered and usable within the hack.

src/main/java/net/wurstclient/mixin/GenericContainerScreenMixin.java (1)
  • 105-113: The logic for checking the whitelist appears to be correct, but it's important to ensure that the Registries.ITEM.getId(item).toString() method reliably converts the Item to a string that matches the format used in the ItemListSetting. If there's any discrepancy in the format, the whitelist check might fail to recognize items correctly.
Verification successful

Let's generate a new script to find the file where ItemListSetting is defined or used and to search for any usage of Registries.ITEM.getId(item).toString() to infer the format of the string it returns.


Based on the search results, the ItemListSetting class uses the Registries.ITEM.getId(item).toString() method to handle item names as strings, which indicates that the format of the string representation of items used in the whitelist is consistent with the format returned by this method. Therefore, the whitelist check in the GenericContainerScreenMixin.java file should work as intended, recognizing items correctly based on the user's configuration.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the string representation of items used in the whitelist matches the format returned by Registries.ITEM.getId(item).toString()
# This can be done by checking the format of strings stored in the ItemListSetting and comparing them with the output of the mentioned method.
# Pseudo-command for demonstration purposes:
# Check the format of strings in the ItemListSetting (assuming the setting is stored in a file or can be accessed via a command)
cat path_to_item_list_setting_storage | grep -o 'expected_item_format_regex'
# Check the format of strings returned by Registries.ITEM.getId(item).toString() (assuming there's a way to invoke this method from the command line)
# This would likely require a Java command or script that can access the game's or mod's code to run the method and output the format.
java -jar path_to_minecraft_or_mod_jar 'Registries.ITEM.getId(item).toString()' | grep -o 'expected_item_format_regex'

Length of output: 333



Script:

#!/bin/bash
# Find the file where ItemListSetting is defined or used
fd 'ItemListSetting' --exec rg 'ItemListSetting' {}

# Search for any usage or comments related to Registries.ITEM.getId(item).toString() to infer the format of the string it returns
rg 'Registries.ITEM.getId\(.+\).toString\(\)'

Length of output: 1314

src/main/java/net/wurstclient/mixin/ShulkerBoxScreenMixin.java (5)
  • 22-25: The imports for Item, ItemStack, Registries, and ItemListSetting have been correctly added and are used within the shiftClickSlots method.

  • 96-105: The new logic within the shiftClickSlots method correctly handles the whitelist feature. It checks if the item is on the whitelist and if the filter is enabled before deciding to skip the item.

  • 96-99: Variables stack, item, and itemName are declared and used appropriately within the loop to handle the item's information and check against the whitelist.

  • 104-105: The conditional check to determine if an item should be ignored based on the whitelist is correctly implemented and follows the logic described in the PR's objective.

  • 93-108: The changes made to the shiftClickSlots method align with the PR's objective of introducing a whitelist feature for the AutoSteal hack, allowing users to specify items that should not be automatically stolen.

Comment on lines 102 to 116
for(int i = from; i < to; i++)
{
Slot slot = handler.slots.get(i);
ItemStack stack = slot.getStack();
Item item = stack.getItem();
String itemName = Registries.ITEM.getId(item).toString();

if(slot.getStack().isEmpty())
continue;

if(!autoSteal.getItemList().contains(itemName) && autoSteal.areFilterEnabled())
continue;

waitForDelay();
if(this.mode != mode || client.currentScreen == null)
Copy link

Choose a reason for hiding this comment

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

The new whitelist logic in shiftClickSlots method is implemented correctly according to the PR's objective. However, consider adding more robust error handling in the runInThread method to handle exceptions that may occur during the execution of the shiftClickSlots method.

private void runInThread(Runnable r)
{
	new Thread(() -> {
		try
		{
			r.run();
		}
		catch(Exception e)
		{
			// Consider implementing a more robust error handling strategy here.
			// For example, logging the error to a file or notifying the user.
			e.printStackTrace();
		}
	}).start();
}

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 48ae2c0 and eea5463.
Files selected for processing (1)
  • src/main/java/net/wurstclient/mixin/GenericContainerScreenMixin.java (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/main/java/net/wurstclient/mixin/GenericContainerScreenMixin.java

@mdenials mdenials closed this by deleting the head repository Dec 26, 2023
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