-
-
Notifications
You must be signed in to change notification settings - Fork 8
GH-225 Add better way to check restricted command - previous idea only checked root commands #225
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
Conversation
…ed root commands Took 2 minutes
|
Warning Rate limit exceeded@Rollczi has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 12 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. 📒 Files selected for processing (1)
WalkthroughThe way command restrictions are checked was updated. Instead of splitting the message by spaces and taking the first token, the new method takes the entire command after the leading slash and lowercases it. It then checks if the command starts with any restricted commands using a slightly different approach. The logic for blocking commands based on whitelist or blacklist mode stays the same. No public interfaces or exported classes were changed. ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightActionBlockerController.java (2)
202-208: AtomicBoolean isn't needed hereSince this code runs in a single thread (event handler), you don't need
AtomicBoolean. A regular boolean would work fine and be more readable.- AtomicBoolean isAnyMatch = new AtomicBoolean(false); + boolean isAnyMatch = false; - this.config.commands.restrictedCommands.forEach(restrictedCommand -> { - if (fullCommand.startsWith(restrictedCommand)) { - isAnyMatch.set(true); - } - }); + for (String restrictedCommand : this.config.commands.restrictedCommands) { + if (fullCommand.startsWith(restrictedCommand)) { + isAnyMatch = true; + break; // Exit loop early once we find a match + } + }
198-212: Consider case-insensitive matchingThe old code converted commands to lowercase, but the new code doesn't. This might cause unexpected behavior if your restricted commands list has mixed case entries.
String fullCommand = message.substring(1); + String fullCommandLower = fullCommand.toLowerCase(); AtomicBoolean isAnyMatch = new AtomicBoolean(false); this.config.commands.restrictedCommands.forEach(restrictedCommand -> { - if (fullCommand.startsWith(restrictedCommand)) { + if (fullCommandLower.startsWith(restrictedCommand.toLowerCase())) { isAnyMatch.set(true); } });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightActionBlockerController.java(2 hunks)
🔇 Additional comments (3)
eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightActionBlockerController.java (3)
9-9: Added import for AtomicBooleanGood job adding the import needed for the new command-checking logic.
198-201: Improved command extractionThe new approach extracts the full command text without splitting by spaces. This is better than the previous method as it allows checking all parts of the command.
212-212: Updated shouldBlock logicThe logic for deciding whether to block the command has been correctly updated to use the new matching approach.
Jakubk15
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
f06ce0a to
a3fadd1
Compare
Rollczi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review w postaci commita, chciałem zaznaczyć, że tutaj taką realną zmianą było usunięcie .split(" ")[0]. a tak po za tym kod nie musiał się tak komplikować. Dodałem też startsWithIgnoreCase
Now algorithm checks for matching first words.
meaning:
restrictedCommands:
should block all gamemode commands, and all tpa requests to CitralFlo (not anyone else)