Skip to content

Fix #3422: 1.21.11: How to match Velocity command?#3476

Closed
kangobot[bot] wants to merge 1 commit intomasterfrom
fix/issue-3422
Closed

Fix #3422: 1.21.11: How to match Velocity command?#3476
kangobot[bot] wants to merge 1 commit intomasterfrom
fix/issue-3422

Conversation

@kangobot
Copy link
Contributor

@kangobot kangobot bot commented Feb 15, 2026

Automated fix proposed by AI analysis of the linked issue.

Changes

  • New: main/chatcontrol-proxy-core/src/main/java/org/mineacademy/chatcontrol/proxy/operator/ProxyRule.java: New class for proxy-level command rules matching. Extends ProxyOperator to inherit all operators (then deny, then warn, then command, then proxy, etc.). Adds regex pattern matching, sender conditions, and a RuleCheck inner class that processes rules against proxy commands.
  • New: main/chatcontrol-proxy-core/src/main/java/org/mineacademy/chatcontrol/proxy/operator/ProxyRules.java: New class that manages proxy command rules. Extends RuleSetReader with keyword "match", loads from rules/command.rs. Mirrors ProxyPlayerMessages structure but for regex-based command rules.
  • New: main/chatcontrol-proxy-core/src/main/resources/rules/command.rs: Default proxy command rules file. All rules are commented out by default, providing examples for users to customize. This file is extracted by RuleSetReader.loadFromFile() on first run.
  • main/chatcontrol-proxy-core/src/main/java/org/mineacademy/chatcontrol/proxy/ProxyEvents.java: Add import for ProxyRule
  • main/chatcontrol-proxy-core/src/main/java/org/mineacademy/chatcontrol/proxy/ProxyEvents.java: Add EventHandledException import for handleCommand method
  • main/chatcontrol-proxy-core/src/main/java/org/mineacademy/chatcontrol/proxy/ProxyEvents.java: Add handleCommand method that runs proxy command rules against the executed command and returns true if the command should be cancelled
  • main/chatcontrol-velocity/src/main/java/org/mineacademy/chatcontrol/velocity/listener/PlayerListener.java: Add import for CommandExecuteEvent
  • main/chatcontrol-velocity/src/main/java/org/mineacademy/chatcontrol/velocity/listener/PlayerListener.java: Add Player import for command event handler type check
  • main/chatcontrol-velocity/src/main/java/org/mineacademy/chatcontrol/velocity/listener/PlayerListener.java: Add command event handler that checks proxy command rules and denies if a rule matches with 'then deny'
  • main/chatcontrol-bungeecord/src/main/java/org/mineacademy/chatcontrol/bungee/listener/PlayerListener.java: Extend the BungeeCord ChatEvent handler to also handle proxy command rules when the event is a command. Routes commands to ProxyEvents.handleCommand() and cancels the event if denied.
  • main/chatcontrol-velocity/src/main/java/org/mineacademy/chatcontrol/velocity/VelocityControl.java: Add ProxyRules import
  • main/chatcontrol-velocity/src/main/java/org/mineacademy/chatcontrol/velocity/VelocityControl.java: Load proxy command rules on plugin reload
  • main/chatcontrol-bungeecord/src/main/java/org/mineacademy/chatcontrol/bungee/BungeeControl.java: Add ProxyRules import
  • main/chatcontrol-bungeecord/src/main/java/org/mineacademy/chatcontrol/bungee/BungeeControl.java: Load proxy command rules on plugin reload
  • main/chatcontrol-proxy-core/src/main/java/org/mineacademy/chatcontrol/proxy/operator/ProxyRule.java: Add $0, $1, $2 regex group reference support to match Bukkit rules syntax. Replace from highest group number down to avoid $1 replacing part of $10.
  • main/chatcontrol-proxy-core/src/main/java/org/mineacademy/chatcontrol/proxy/operator/ProxyRule.java: Add @nonnull annotation to match parent method signature for consistency
  • main/chatcontrol-proxy-core/src/main/java/org/mineacademy/chatcontrol/proxy/operator/ProxyRule.java: Add NonNull import for the replaceVariablesLegacy override annotation

This is a draft PR — human review required before merging.

@devpedrobarbosa
Copy link
Collaborator

@kangarko

I'll have to test this one out before we can push it, will do it by today.

@kangarko kangarko closed this Feb 23, 2026
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.

2 participants