mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-08-28 09:06:44 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 55ee46e167 | |||
| 55b9647890 | |||
| 6e38130675 | |||
| 3b3621d1d2 | |||
| 6a3dc807af | |||
| c5bf4b757f | |||
| 402dd8b48f | |||
| 74af326f80 | |||
| 7a707068e2 | |||
| b4fda1cb9e | |||
| a42f546e4d | |||
| 7222b910e5 | |||
| e3c6103ec7 |
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.9.0</version>
|
<version>2.12.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>Bukkit</artifactId>
|
<artifactId>Bukkit</artifactId>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<description>You decide what commands players can use or tab complete on your server!</description>
|
<description>You decide what commands players can use or tab complete on your server!</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>21</java.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<url>youhavetrouble.me</url>
|
<url>youhavetrouble.me</url>
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>net.kyori</pattern>
|
<pattern>net.kyori</pattern>
|
||||||
<shadedPattern>eu.endermite</shadedPattern>
|
<shadedPattern>eu.endermite.net.kyori</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -73,12 +73,12 @@
|
|||||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>dmulloy2-repo</id>
|
<id>sonatype-snapshots</id>
|
||||||
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
|
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>papermc</id>
|
<id>papermc</id>
|
||||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
@@ -86,19 +86,19 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.papermc.paper</groupId>
|
<groupId>io.papermc.paper</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>paper-api</artifactId>
|
||||||
<version>1.19.4-R0.1-SNAPSHOT</version>
|
<version>1.21.8-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-platform-bukkit</artifactId>
|
<artifactId>adventure-platform-bukkit</artifactId>
|
||||||
<version>4.3.3</version>
|
<version>4.4.1-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-text-minimessage</artifactId>
|
<artifactId>adventure-text-minimessage</artifactId>
|
||||||
<version>4.17.0</version>
|
<version>4.23.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -108,9 +108,9 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.comphenix.protocol</groupId>
|
<groupId>net.dmulloy2</groupId>
|
||||||
<artifactId>ProtocolLib</artifactId>
|
<artifactId>ProtocolLib</artifactId>
|
||||||
<version>5.1.0</version>
|
<version>5.4.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -119,11 +119,5 @@
|
|||||||
<version>3.0.2</version>
|
<version>3.0.2</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.mojang</groupId>
|
|
||||||
<artifactId>brigadier</artifactId>
|
|
||||||
<version>1.0.18</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
+8
-4
@@ -20,7 +20,10 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class CommandWhitelistBukkit extends JavaPlugin {
|
public class CommandWhitelistBukkit extends JavaPlugin {
|
||||||
@@ -85,7 +88,8 @@ public class CommandWhitelistBukkit extends JavaPlugin {
|
|||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
p.updateCommands();
|
p.updateCommands();
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.config_reloaded));
|
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.config_reloaded));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -122,13 +126,13 @@ public class CommandWhitelistBukkit extends JavaPlugin {
|
|||||||
* @param player Bukkit Player
|
* @param player Bukkit Player
|
||||||
* @return subcommands unavailable for the player
|
* @return subcommands unavailable for the player
|
||||||
*/
|
*/
|
||||||
public static HashSet<String> getSuggestions(org.bukkit.entity.Player player) {
|
public static HashSet<String> getSuggestions(Player player) {
|
||||||
HashSet<String> suggestionList = new HashSet<>();
|
HashSet<String> suggestionList = new HashSet<>();
|
||||||
HashMap<String, CWGroup> groups = configCache.getGroupList();
|
HashMap<String, CWGroup> groups = configCache.getGroupList();
|
||||||
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
|
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
|
||||||
if (s.getKey().equalsIgnoreCase("default"))
|
if (s.getKey().equalsIgnoreCase("default"))
|
||||||
suggestionList.addAll(s.getValue().getSubCommands());
|
suggestionList.addAll(s.getValue().getSubCommands());
|
||||||
if (player.hasPermission(s.getValue().getPermission())) continue;
|
if (!player.hasPermission(s.getValue().getPermission())) continue;
|
||||||
suggestionList.addAll(s.getValue().getSubCommands());
|
suggestionList.addAll(s.getValue().getSubCommands());
|
||||||
}
|
}
|
||||||
return suggestionList;
|
return suggestionList;
|
||||||
|
|||||||
+5
-4
@@ -13,12 +13,13 @@ public class AsyncTabCompleteBlockerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onCommandTabComplete(AsyncTabCompleteEvent event) {
|
public void onCommandTabComplete(AsyncTabCompleteEvent event) {
|
||||||
if (!(event.getSender() instanceof Player)) return;
|
if (!(event.getSender() instanceof Player player)) return;
|
||||||
Player player = (Player) event.getSender();
|
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||||
String buffer = event.getBuffer();
|
String buffer = event.getBuffer();
|
||||||
if ((buffer.split(" ").length == 1 && !buffer.endsWith(" ")) || !buffer.startsWith("/")) {
|
int commandEnd = buffer.indexOf(' ');
|
||||||
CommandWhitelistBukkit.getConfigCache().debug("Actively prevented "+event.getSender().getName()+"'s tab completion (sus packet)");
|
if (commandEnd < 0 || buffer.charAt(0) != '/' || !CommandWhitelistBukkit.getCommands(player)
|
||||||
|
.contains(buffer.substring(1, commandEnd).toLowerCase())) {
|
||||||
|
CommandWhitelistBukkit.getConfigCache().debug("Actively prevented " + event.getSender().getName() + "'s tab completion (sus packet)");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-2
@@ -11,12 +11,13 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class PlayerCommandPreProcessListener implements Listener {
|
public class PlayerCommandPreProcessListener implements Listener {
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void PlayerCommandSendEvent(org.bukkit.event.player.PlayerCommandPreprocessEvent event) {
|
public void PlayerExecuteCommand(PlayerCommandPreprocessEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||||
String caseSensitiveLabel = CommandUtil.getCommandLabel(event.getMessage());
|
String caseSensitiveLabel = CommandUtil.getCommandLabel(event.getMessage());
|
||||||
@@ -33,7 +34,14 @@ public class PlayerCommandPreProcessListener implements Listener {
|
|||||||
messageWithoutSlash,
|
messageWithoutSlash,
|
||||||
config.prefix + CommandWhitelistBukkit.getCommandDeniedMessage(label)
|
config.prefix + CommandWhitelistBukkit.getCommandDeniedMessage(label)
|
||||||
);
|
);
|
||||||
audiences.player(player).sendMessage(message);
|
switch (config.messageType) {
|
||||||
|
case CHAT:
|
||||||
|
audiences.player(player).sendMessage(message);
|
||||||
|
break;
|
||||||
|
case ACTIONBAR:
|
||||||
|
audiences.player(player).sendActionBar(message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -13,12 +13,13 @@ public class TabCompleteBlockerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onCommandTabComplete(TabCompleteEvent event) {
|
public void onCommandTabComplete(TabCompleteEvent event) {
|
||||||
if (!(event.getSender() instanceof Player)) return;
|
if (!(event.getSender() instanceof Player player)) return;
|
||||||
Player player = (Player) event.getSender();
|
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||||
String buffer = event.getBuffer();
|
String buffer = event.getBuffer();
|
||||||
if ((buffer.split(" ").length == 1 && !buffer.endsWith(" ")) || !buffer.startsWith("/")) {
|
int commandEnd = buffer.indexOf(' ');
|
||||||
CommandWhitelistBukkit.getConfigCache().debug("Actively prevented "+event.getSender().getName()+"'s tab completion (sus packet)");
|
if (commandEnd < 0 || buffer.charAt(0) != '/' || !CommandWhitelistBukkit.getCommands(player)
|
||||||
|
.contains(buffer.substring(1, commandEnd).toLowerCase())) {
|
||||||
|
CommandWhitelistBukkit.getConfigCache().debug("Actively prevented " + event.getSender().getName() + "'s tab completion (sus packet)");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.9.0</version>
|
<version>2.12.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>Common</artifactId>
|
<artifactId>Common</artifactId>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<description>You decide what commands players can use or tab complete on your server!</description>
|
<description>You decide what commands players can use or tab complete on your server!</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>21</java.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<url>youhavetrouble.me</url>
|
<url>youhavetrouble.me</url>
|
||||||
@@ -44,6 +44,12 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
<finalName>${project.name}-${project.parent.version}</finalName>
|
<finalName>${project.name}-${project.parent.version}</finalName>
|
||||||
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>net.kyori</pattern>
|
||||||
|
<shadedPattern>eu.endermite.net.kyori</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
@@ -60,7 +66,7 @@
|
|||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>pluginwiki-repo</id>
|
<id>pluginwiki-repo</id>
|
||||||
<url>https://ci.pluginwiki.us/plugin/repository/everything/</url>
|
<url>https://repo.bsdevelopment.org/releases</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>velocitypowered-repo</id>
|
<id>velocitypowered-repo</id>
|
||||||
@@ -68,7 +74,7 @@
|
|||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>papermc</id>
|
<id>papermc</id>
|
||||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
<url>https://repo.papermc.io/repository/maven-public</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
@@ -76,7 +82,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.thatsmusic99</groupId>
|
<groupId>com.github.thatsmusic99</groupId>
|
||||||
<artifactId>ConfigurationMaster-API</artifactId>
|
<artifactId>ConfigurationMaster-API</artifactId>
|
||||||
<version>v2.0.0-BETA-9</version>
|
<version>v2.0.0-rc.3</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -88,7 +94,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-text-minimessage</artifactId>
|
<artifactId>adventure-text-minimessage</artifactId>
|
||||||
<version>4.17.0</version>
|
<version>4.23.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
+13
@@ -17,6 +17,7 @@ public class ConfigCache {
|
|||||||
public String prefix, command_denied, no_permission, no_such_subcommand, config_reloaded, added_to_whitelist,
|
public String prefix, command_denied, no_permission, no_such_subcommand, config_reloaded, added_to_whitelist,
|
||||||
removed_from_whitelist, group_doesnt_exist, subcommand_denied;
|
removed_from_whitelist, group_doesnt_exist, subcommand_denied;
|
||||||
public boolean useProtocolLib = false;
|
public boolean useProtocolLib = false;
|
||||||
|
public MessageType messageType = MessageType.CHAT;
|
||||||
public boolean debug = false;
|
public boolean debug = false;
|
||||||
|
|
||||||
public ConfigCache(File configFile, boolean canDoProtocolLib, Object logger) {
|
public ConfigCache(File configFile, boolean canDoProtocolLib, Object logger) {
|
||||||
@@ -56,6 +57,8 @@ public class ConfigCache {
|
|||||||
if (canDoProtocolLib)
|
if (canDoProtocolLib)
|
||||||
config.addDefault("use_protocollib", false, "Do not enable if you don't have issues with aliased commands.\nThis requires server restart to take effect.");
|
config.addDefault("use_protocollib", false, "Do not enable if you don't have issues with aliased commands.\nThis requires server restart to take effect.");
|
||||||
|
|
||||||
|
config.addDefault("message_type", MessageType.CHAT.toString(), "Valid message types are CHAT and ACTIONBAR. Does nothing on velocity.");
|
||||||
|
|
||||||
if (config.isNew()) {
|
if (config.isNew()) {
|
||||||
List<String> exampleCommands = new ArrayList<>();
|
List<String> exampleCommands = new ArrayList<>();
|
||||||
exampleCommands.add("example");
|
exampleCommands.add("example");
|
||||||
@@ -102,6 +105,16 @@ public class ConfigCache {
|
|||||||
group_doesnt_exist = config.getString("messages.group_doesnt_exist");
|
group_doesnt_exist = config.getString("messages.group_doesnt_exist");
|
||||||
useProtocolLib = config.getBoolean("use_protocollib");
|
useProtocolLib = config.getBoolean("use_protocollib");
|
||||||
debug = config.getBoolean("debug", false);
|
debug = config.getBoolean("debug", false);
|
||||||
|
try {
|
||||||
|
String chatTypeId = config.getString("message_type");
|
||||||
|
if (chatTypeId == null) {
|
||||||
|
warn("Invalid message type. Using CHAT.");
|
||||||
|
} else {
|
||||||
|
messageType = MessageType.valueOf(chatTypeId.toUpperCase(Locale.ENGLISH));
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
warn("Invalid message type. Using CHAT.");
|
||||||
|
}
|
||||||
|
|
||||||
ConfigSection groupSection = config.getConfigSection("groups");
|
ConfigSection groupSection = config.getConfigSection("groups");
|
||||||
for (String key : groupSection.getKeys(false)) {
|
for (String key : groupSection.getKeys(false)) {
|
||||||
|
|||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
package eu.endermite.commandwhitelist.common;
|
||||||
|
|
||||||
|
public enum MessageType {
|
||||||
|
|
||||||
|
CHAT, ACTIONBAR
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.9.0</version>
|
<version>2.12.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>Velocity</artifactId>
|
<artifactId>Velocity</artifactId>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<description>You decide what commands players can use or tab complete on your server!</description>
|
<description>You decide what commands players can use or tab complete on your server!</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>21</java.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<url>youhavetrouble.me</url>
|
<url>youhavetrouble.me</url>
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>papermc</id>
|
<id>papermc</id>
|
||||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
<url>https://repo.papermc.io/repository/maven-public</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>minecraft-libraries</id>
|
<id>minecraft-libraries</id>
|
||||||
|
|||||||
+42
-8
@@ -4,9 +4,11 @@ import com.google.inject.Inject;
|
|||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.mojang.brigadier.Command;
|
import com.mojang.brigadier.Command;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
|
import com.velocitypowered.api.event.PostOrder;
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
||||||
import com.velocitypowered.api.event.command.PlayerAvailableCommandsEvent;
|
import com.velocitypowered.api.event.command.PlayerAvailableCommandsEvent;
|
||||||
|
import com.velocitypowered.api.event.player.TabCompleteEvent;
|
||||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
@@ -22,10 +24,7 @@ import org.bstats.velocity.Metrics;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class CommandWhitelistVelocity {
|
public class CommandWhitelistVelocity {
|
||||||
|
|
||||||
@@ -74,7 +73,7 @@ public class CommandWhitelistVelocity {
|
|||||||
metrics.addCustomChart(new SimplePie("proxy", () -> "Velocity"));
|
metrics.addCustomChart(new SimplePie("proxy", () -> "Velocity"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe(order = PostOrder.LAST)
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
public void onUserCommandSendEvent(PlayerAvailableCommandsEvent event) {
|
public void onUserCommandSendEvent(PlayerAvailableCommandsEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@@ -95,11 +94,45 @@ public class CommandWhitelistVelocity {
|
|||||||
|
|
||||||
// Workaround for velocity executing "/ command" as valid command
|
// Workaround for velocity executing "/ command" as valid command
|
||||||
String command = event.getCommand().trim();
|
String command = event.getCommand().trim();
|
||||||
|
if (command.startsWith("/")) command = command.substring(1);
|
||||||
|
|
||||||
HashSet<String> allowedCommands = getCommands(player);
|
HashSet<String> allowedCommands = getCommands(player);
|
||||||
String label = CommandUtil.getCommandLabel(command);
|
String label = CommandUtil.getCommandLabel(command);
|
||||||
if (server.getCommandManager().hasCommand(label) && !allowedCommands.contains(label))
|
if (server.getCommandManager().hasCommand(label) && !allowedCommands.contains(label)) {
|
||||||
event.setResult(CommandExecuteEvent.CommandResult.forwardToServer());
|
event.setResult(CommandExecuteEvent.CommandResult.forwardToServer());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HashSet<String> bannedSubCommands = getSuggestions(player);
|
||||||
|
|
||||||
|
for (String bannedSubCommand : bannedSubCommands) {
|
||||||
|
if (command.startsWith(bannedSubCommand)) {
|
||||||
|
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||||
|
player.sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.subcommand_denied));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* THIS IS FOR CLIENTS ON 1.12 AND BELOW, NOT GUARANTEED TO WORK, IF IT DOESN'T, PR OF GTFO
|
||||||
|
*/
|
||||||
|
@Subscribe
|
||||||
|
public void onUserTabCompleteEvent(TabCompleteEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||||
|
String buffer = event.getPartialMessage();
|
||||||
|
|
||||||
|
if (event.getSuggestions().isEmpty()) return;
|
||||||
|
|
||||||
|
List<String> newSuggestions = CommandUtil.filterSuggestions(
|
||||||
|
buffer,
|
||||||
|
event.getSuggestions(),
|
||||||
|
getSuggestions(player)
|
||||||
|
);
|
||||||
|
|
||||||
|
event.getSuggestions().clear();
|
||||||
|
event.getSuggestions().addAll(newSuggestions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigCache getConfigCache() {
|
public ConfigCache getConfigCache() {
|
||||||
@@ -127,12 +160,13 @@ public class CommandWhitelistVelocity {
|
|||||||
* @param player Velocity Player
|
* @param player Velocity Player
|
||||||
* @return subcommands unavailable for the player
|
* @return subcommands unavailable for the player
|
||||||
*/
|
*/
|
||||||
public HashSet<String> getSuggestions(Player player, HashMap<String, CWGroup> groups) {
|
public HashSet<String> getSuggestions(Player player) {
|
||||||
HashSet<String> suggestionList = new HashSet<>();
|
HashSet<String> suggestionList = new HashSet<>();
|
||||||
|
HashMap<String, CWGroup> groups = configCache.getGroupList();
|
||||||
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
|
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
|
||||||
if (s.getKey().equalsIgnoreCase("default"))
|
if (s.getKey().equalsIgnoreCase("default"))
|
||||||
suggestionList.addAll(s.getValue().getSubCommands());
|
suggestionList.addAll(s.getValue().getSubCommands());
|
||||||
if (player.hasPermission(s.getValue().getPermission())) continue;
|
if (!player.hasPermission(s.getValue().getPermission())) continue;
|
||||||
suggestionList.addAll(s.getValue().getSubCommands());
|
suggestionList.addAll(s.getValue().getSubCommands());
|
||||||
}
|
}
|
||||||
return suggestionList;
|
return suggestionList;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.9.0</version>
|
<version>2.12.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>Waterfall</artifactId>
|
<artifactId>Waterfall</artifactId>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<description>You decide what commands players can use or tab complete on your server!</description>
|
<description>You decide what commands players can use or tab complete on your server!</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>21</java.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<url>youhavetrouble.me</url>
|
<url>youhavetrouble.me</url>
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>papermc</id>
|
<id>papermc</id>
|
||||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
<url>https://repo.papermc.io/repository/maven-public</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
@@ -94,13 +94,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-platform-bungeecord</artifactId>
|
<artifactId>adventure-platform-bungeecord</artifactId>
|
||||||
<version>4.3.3</version>
|
<version>4.4.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-text-minimessage</artifactId>
|
<artifactId>adventure-text-minimessage</artifactId>
|
||||||
<version>4.17.0</version>
|
<version>4.23.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
+1
-1
@@ -100,7 +100,7 @@ public final class CommandWhitelistWaterfall extends Plugin {
|
|||||||
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
|
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
|
||||||
if (s.getKey().equalsIgnoreCase("default"))
|
if (s.getKey().equalsIgnoreCase("default"))
|
||||||
suggestionList.addAll(s.getValue().getSubCommands());
|
suggestionList.addAll(s.getValue().getSubCommands());
|
||||||
if (player.hasPermission(s.getValue().getPermission())) continue;
|
if (!player.hasPermission(s.getValue().getPermission())) continue;
|
||||||
suggestionList.addAll(s.getValue().getSubCommands());
|
suggestionList.addAll(s.getValue().getSubCommands());
|
||||||
}
|
}
|
||||||
return suggestionList;
|
return suggestionList;
|
||||||
|
|||||||
+8
-1
@@ -38,7 +38,14 @@ public class BungeeChatEventListener implements Listener {
|
|||||||
command,
|
command,
|
||||||
configCache.prefix + CommandWhitelistWaterfall.getCommandDeniedMessage(label)
|
configCache.prefix + CommandWhitelistWaterfall.getCommandDeniedMessage(label)
|
||||||
);
|
);
|
||||||
audiences.player(player).sendMessage(message);
|
switch (configCache.messageType) {
|
||||||
|
case CHAT:
|
||||||
|
audiences.player(player).sendMessage(message);
|
||||||
|
break;
|
||||||
|
case ACTIONBAR:
|
||||||
|
audiences.player(player).sendActionBar(message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
-4
@@ -7,19 +7,35 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class BungeeTabcompleteListener implements Listener {
|
public class BungeeTabcompleteListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onTabcomplete(net.md_5.bungee.api.event.TabCompleteEvent event) {
|
public void onTabcomplete(net.md_5.bungee.api.event.TabCompleteEvent event) {
|
||||||
if (!(event.getReceiver() instanceof ProxiedPlayer)) return;
|
if (!(event.getSender() instanceof ProxiedPlayer)) return;
|
||||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
|
||||||
if (event.getSuggestions().isEmpty()) return;
|
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||||
CommandUtil.filterSuggestions(
|
|
||||||
|
String cursor = event.getCursor();
|
||||||
|
int commandEnd = cursor.indexOf(' ');
|
||||||
|
if (commandEnd >= 0 && cursor.charAt(0) == '/') {
|
||||||
|
String command = cursor.substring(1, commandEnd).toLowerCase();
|
||||||
|
if (CommandWhitelistWaterfall.getPlugin().getProxy().getPluginManager().isExecutableCommand(command, player)
|
||||||
|
&& !CommandWhitelistWaterfall.getCommands(player).contains(command)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (event.getSuggestions().isEmpty()) return;
|
||||||
|
|
||||||
|
List<String> suggestions = CommandUtil.filterSuggestions(
|
||||||
event.getCursor(),
|
event.getCursor(),
|
||||||
event.getSuggestions(),
|
event.getSuggestions(),
|
||||||
CommandWhitelistWaterfall.getSuggestions(player)
|
CommandWhitelistWaterfall.getSuggestions(player)
|
||||||
);
|
);
|
||||||
|
event.getSuggestions().clear();
|
||||||
|
event.getSuggestions().addAll(suggestions);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.9.0</version>
|
<version>2.12.1</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>CommandWhitelistCommon</module>
|
<module>CommandWhitelistCommon</module>
|
||||||
<module>CommandWhitelistBukkit</module>
|
<module>CommandWhitelistBukkit</module>
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<description>Control what commands players can use</description>
|
<description>Control what commands players can use</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>21</java.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@@ -54,6 +54,12 @@
|
|||||||
</manifestEntries>
|
</manifestEntries>
|
||||||
</transformer>
|
</transformer>
|
||||||
</transformers>
|
</transformers>
|
||||||
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>net.kyori</pattern>
|
||||||
|
<shadedPattern>eu.endermite.net.kyori</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
@@ -72,13 +78,17 @@
|
|||||||
<id>sonatype</id>
|
<id>sonatype</id>
|
||||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>papermc</id>
|
||||||
|
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-api</artifactId>
|
<artifactId>adventure-api</artifactId>
|
||||||
<version>4.17.0</version>
|
<version>4.23.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
Reference in New Issue
Block a user