Skip to content

Commit 9e5b5b5

Browse files
fix velocity weird command handling
1 parent 67ca2c2 commit 9e5b5b5

File tree

7 files changed

+13
-9
lines changed

7 files changed

+13
-9
lines changed

CommandWhitelistBukkit/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>eu.endermite.commandwhitelist</groupId>
88
<artifactId>CommandWhitelist</artifactId>
9-
<version>2.5.1</version>
9+
<version>2.5.2</version>
1010
</parent>
1111

1212
<artifactId>Bukkit</artifactId>

CommandWhitelistBukkit/src/main/java/eu/endermite/commandwhitelist/bukkit/listeners/PlayerCommandPreProcessListener.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package eu.endermite.commandwhitelist.bukkit.listeners;
22

33
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
4+
import eu.endermite.commandwhitelist.common.CWPermission;
45
import eu.endermite.commandwhitelist.common.CommandUtil;
56
import eu.endermite.commandwhitelist.common.ConfigCache;
67
import eu.endermite.commandwhitelist.common.commands.CWCommand;
@@ -16,7 +17,7 @@ public class PlayerCommandPreProcessListener implements Listener {
1617
@EventHandler(priority = EventPriority.HIGHEST)
1718
public void PlayerCommandSendEvent(org.bukkit.event.player.PlayerCommandPreprocessEvent event) {
1819
Player player = event.getPlayer();
19-
if (player.hasPermission("commandwhitelist.bypass")) return;
20+
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
2021
String caseSensitiveLabel = CommandUtil.getCommandLabel(event.getMessage());
2122
String label = caseSensitiveLabel.toLowerCase();
2223
event.setMessage(event.getMessage().replaceFirst(caseSensitiveLabel, label));

CommandWhitelistCommon/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>eu.endermite.commandwhitelist</groupId>
88
<artifactId>CommandWhitelist</artifactId>
9-
<version>2.5.1</version>
9+
<version>2.5.2</version>
1010
</parent>
1111

1212
<artifactId>Common</artifactId>

CommandWhitelistVelocity/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>eu.endermite.commandwhitelist</groupId>
88
<artifactId>CommandWhitelist</artifactId>
9-
<version>2.5.1</version>
9+
<version>2.5.2</version>
1010
</parent>
1111

1212
<artifactId>Velocity</artifactId>

CommandWhitelistVelocity/src/main/java/eu/endermite/commandwhitelist/velocity/CommandWhitelistVelocity.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.velocitypowered.api.proxy.ProxyServer;
1212
import eu.endermite.commandwhitelist.common.CWGroup;
1313
import eu.endermite.commandwhitelist.common.CWPermission;
14+
import eu.endermite.commandwhitelist.common.CommandUtil;
1415
import eu.endermite.commandwhitelist.common.ConfigCache;
1516
import eu.endermite.commandwhitelist.common.commands.CWCommand;
1617
import eu.endermite.commandwhitelist.velocity.command.VelocityMainCommand;
@@ -87,10 +88,12 @@ public void onUserCommandExecuteEvent(com.velocitypowered.api.event.command.Comm
8788

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

91+
// Workaround for velocity executing "/ command" as valid command
92+
String command = event.getCommand().trim();
93+
9094
HashSet<String> allowedCommands = CommandWhitelistVelocity.getCommands(player);
91-
String command = event.getCommand().split(" ")[0];
92-
if (server.getCommandManager().hasCommand(command)
93-
&& !allowedCommands.contains(command))
95+
String label = CommandUtil.getCommandLabel(command);
96+
if (server.getCommandManager().hasCommand(label) && !allowedCommands.contains(label))
9497
event.setResult(CommandExecuteEvent.CommandResult.forwardToServer());
9598
}
9699

CommandWhitelistWaterfall/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>eu.endermite.commandwhitelist</groupId>
88
<artifactId>CommandWhitelist</artifactId>
9-
<version>2.5.1</version>
9+
<version>2.5.2</version>
1010
</parent>
1111

1212
<artifactId>Waterfall</artifactId>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>eu.endermite.commandwhitelist</groupId>
88
<artifactId>CommandWhitelist</artifactId>
9-
<version>2.5.1</version>
9+
<version>2.5.2</version>
1010
<modules>
1111
<module>CommandWhitelistCommon</module>
1212
<module>CommandWhitelistBukkit</module>

0 commit comments

Comments
 (0)