Skip to content

Commit

Permalink
fix velocity weird command handling
Browse files Browse the repository at this point in the history
  • Loading branch information
YouHaveTrouble committed Sep 28, 2022
1 parent 67ca2c2 commit 9e5b5b5
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CommandWhitelistBukkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.5.1</version>
<version>2.5.2</version>
</parent>

<artifactId>Bukkit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package eu.endermite.commandwhitelist.bukkit.listeners;

import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.common.CommandUtil;
import eu.endermite.commandwhitelist.common.ConfigCache;
import eu.endermite.commandwhitelist.common.commands.CWCommand;
Expand All @@ -16,7 +17,7 @@ public class PlayerCommandPreProcessListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void PlayerCommandSendEvent(org.bukkit.event.player.PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
if (player.hasPermission("commandwhitelist.bypass")) return;
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
String caseSensitiveLabel = CommandUtil.getCommandLabel(event.getMessage());
String label = caseSensitiveLabel.toLowerCase();
event.setMessage(event.getMessage().replaceFirst(caseSensitiveLabel, label));
Expand Down
2 changes: 1 addition & 1 deletion CommandWhitelistCommon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.5.1</version>
<version>2.5.2</version>
</parent>

<artifactId>Common</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion CommandWhitelistVelocity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.5.1</version>
<version>2.5.2</version>
</parent>

<artifactId>Velocity</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.velocitypowered.api.proxy.ProxyServer;
import eu.endermite.commandwhitelist.common.CWGroup;
import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.common.CommandUtil;
import eu.endermite.commandwhitelist.common.ConfigCache;
import eu.endermite.commandwhitelist.common.commands.CWCommand;
import eu.endermite.commandwhitelist.velocity.command.VelocityMainCommand;
Expand Down Expand Up @@ -87,10 +88,12 @@ public void onUserCommandExecuteEvent(com.velocitypowered.api.event.command.Comm

if (player.hasPermission(CWPermission.BYPASS.permission())) return;

// Workaround for velocity executing "/ command" as valid command
String command = event.getCommand().trim();

HashSet<String> allowedCommands = CommandWhitelistVelocity.getCommands(player);
String command = event.getCommand().split(" ")[0];
if (server.getCommandManager().hasCommand(command)
&& !allowedCommands.contains(command))
String label = CommandUtil.getCommandLabel(command);
if (server.getCommandManager().hasCommand(label) && !allowedCommands.contains(label))
event.setResult(CommandExecuteEvent.CommandResult.forwardToServer());
}

Expand Down
2 changes: 1 addition & 1 deletion CommandWhitelistWaterfall/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.5.1</version>
<version>2.5.2</version>
</parent>

<artifactId>Waterfall</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.5.1</version>
<version>2.5.2</version>
<modules>
<module>CommandWhitelistCommon</module>
<module>CommandWhitelistBukkit</module>
Expand Down

0 comments on commit 9e5b5b5

Please sign in to comment.