mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-11 22:16:57 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b7d7646641 | |||
| 697a5e5720 | |||
| 598756fec0 | |||
| 95ea1d8319 | |||
| 9da87b2769 |
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>eu.endermite</groupId>
|
||||
<artifactId>CommandWhitelist</artifactId>
|
||||
<version>1.7.5</version>
|
||||
<version>1.7.8</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>CommandWhitelist</name>
|
||||
|
||||
+2
-3
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PlayerCommandPreProcessListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void PlayerCommandSendEvent(org.bukkit.event.player.PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.hasPermission("commandwhitelist.bypass"))
|
||||
@@ -27,10 +27,9 @@ public class PlayerCommandPreProcessListener implements Listener {
|
||||
for (String comm : s.getValue()) {
|
||||
comm = comm.toLowerCase();
|
||||
if (command.equalsIgnoreCase(comm) || command.startsWith(comm + " ")) {
|
||||
String rawCmd = event.getMessage();
|
||||
List<String> bannedSubCommands = CommandsList.getSuggestions(player);
|
||||
for (String bannedSubCommand : bannedSubCommands) {
|
||||
if (rawCmd.startsWith(bannedSubCommand)) {
|
||||
if (command.startsWith(bannedSubCommand)) {
|
||||
event.setCancelled(true);
|
||||
ConfigCache config = CommandWhitelist.getConfigCache();
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getPrefix() + RandomStuff.getMessage(config.getCommandDeniedList(), config.getSubCommandDenied())));
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import org.bukkit.event.Listener;
|
||||
import java.util.*;
|
||||
|
||||
public class PlayerCommandSendListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void PlayerCommandSendEvent(org.bukkit.event.player.PlayerCommandSendEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.hasPermission("commandwhitelist.bypass"))
|
||||
|
||||
+11
-3
@@ -14,14 +14,22 @@ public class TabCompleteBlockerListener implements Listener {
|
||||
return;
|
||||
Player player = (Player) event.getSender();
|
||||
String buffer = event.getBuffer();
|
||||
String cmd = buffer.replace(CommandsList.getLastArgument(buffer), "");
|
||||
|
||||
List<String> blockedCommands = CommandsList.getSuggestions(player);
|
||||
List<String> suggestions = event.getCompletions();
|
||||
|
||||
for (String s : blockedCommands) {
|
||||
String slast = CommandsList.getLastArgument(s);
|
||||
String scommand = s.replace(slast, "");
|
||||
cmd = cmd.replace(CommandsList.getLastArgument(cmd), "");
|
||||
if (cmd.startsWith("/" + scommand)) {
|
||||
String[] cmdSplit = buffer.split(" ");
|
||||
StringBuilder cmdBuilder = new StringBuilder();
|
||||
for (int i = 0; i <= cmdSplit.length-1; i++)
|
||||
cmdBuilder.append(cmdSplit[i]).append(" ");
|
||||
|
||||
String cmd = cmdBuilder.toString();
|
||||
if (cmd.startsWith("/"+scommand)) {
|
||||
// This sometimes throws exceptions. No clue why, it just does. try/catch is the only fix.
|
||||
// Probably happening when plugin adds suggestions in this event on the same priority - not confirmed.
|
||||
try {
|
||||
while (suggestions.contains(slast))
|
||||
suggestions.remove(slast);
|
||||
|
||||
Reference in New Issue
Block a user