mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-12 06:26:57 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 153ad5f983 | |||
| 9e5b5b5fc7 |
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>Bukkit</artifactId>
|
<artifactId>Bukkit</artifactId>
|
||||||
|
|||||||
+7
-2
@@ -1,6 +1,7 @@
|
|||||||
package eu.endermite.commandwhitelist.bukkit.listeners;
|
package eu.endermite.commandwhitelist.bukkit.listeners;
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
|
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
|
||||||
|
import eu.endermite.commandwhitelist.common.CWPermission;
|
||||||
import eu.endermite.commandwhitelist.common.CommandUtil;
|
import eu.endermite.commandwhitelist.common.CommandUtil;
|
||||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
import eu.endermite.commandwhitelist.common.ConfigCache;
|
||||||
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
||||||
@@ -16,10 +17,14 @@ public class PlayerCommandPreProcessListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void PlayerCommandSendEvent(org.bukkit.event.player.PlayerCommandPreprocessEvent event) {
|
public void PlayerCommandSendEvent(org.bukkit.event.player.PlayerCommandPreprocessEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player.hasPermission("commandwhitelist.bypass")) return;
|
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||||
String caseSensitiveLabel = CommandUtil.getCommandLabel(event.getMessage());
|
String caseSensitiveLabel = CommandUtil.getCommandLabel(event.getMessage());
|
||||||
String label = caseSensitiveLabel.toLowerCase();
|
String label = caseSensitiveLabel.toLowerCase();
|
||||||
event.setMessage(event.getMessage().replaceFirst(caseSensitiveLabel, label));
|
|
||||||
|
String fullCommand = event.getMessage().substring(label.length()+1);
|
||||||
|
fullCommand = "/"+label+fullCommand;
|
||||||
|
|
||||||
|
event.setMessage(fullCommand);
|
||||||
BukkitAudiences audiences = CommandWhitelistBukkit.getAudiences();
|
BukkitAudiences audiences = CommandWhitelistBukkit.getAudiences();
|
||||||
ConfigCache config = CommandWhitelistBukkit.getConfigCache();
|
ConfigCache config = CommandWhitelistBukkit.getConfigCache();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>Common</artifactId>
|
<artifactId>Common</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>Velocity</artifactId>
|
<artifactId>Velocity</artifactId>
|
||||||
|
|||||||
+6
-3
@@ -11,6 +11,7 @@ import com.velocitypowered.api.proxy.Player;
|
|||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import eu.endermite.commandwhitelist.common.CWGroup;
|
import eu.endermite.commandwhitelist.common.CWGroup;
|
||||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
import eu.endermite.commandwhitelist.common.CWPermission;
|
||||||
|
import eu.endermite.commandwhitelist.common.CommandUtil;
|
||||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
import eu.endermite.commandwhitelist.common.ConfigCache;
|
||||||
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
||||||
import eu.endermite.commandwhitelist.velocity.command.VelocityMainCommand;
|
import eu.endermite.commandwhitelist.velocity.command.VelocityMainCommand;
|
||||||
@@ -87,10 +88,12 @@ public class CommandWhitelistVelocity {
|
|||||||
|
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
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);
|
HashSet<String> allowedCommands = CommandWhitelistVelocity.getCommands(player);
|
||||||
String command = event.getCommand().split(" ")[0];
|
String label = CommandUtil.getCommandLabel(command);
|
||||||
if (server.getCommandManager().hasCommand(command)
|
if (server.getCommandManager().hasCommand(label) && !allowedCommands.contains(label))
|
||||||
&& !allowedCommands.contains(command))
|
|
||||||
event.setResult(CommandExecuteEvent.CommandResult.forwardToServer());
|
event.setResult(CommandExecuteEvent.CommandResult.forwardToServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>Waterfall</artifactId>
|
<artifactId>Waterfall</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.3</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>CommandWhitelistCommon</module>
|
<module>CommandWhitelistCommon</module>
|
||||||
<module>CommandWhitelistBukkit</module>
|
<module>CommandWhitelistBukkit</module>
|
||||||
|
|||||||
Reference in New Issue
Block a user