Compare commits

...

37 Commits

Author SHA1 Message Date
YouHaveTrouble 7f6315b6b5 bump version 2021-11-25 02:06:48 +01:00
YouHaveTrouble bbc0e44660 fix errors with spigot specifically.
use paper folks.
2021-11-25 02:03:20 +01:00
YouHaveTrouble 9e255076b0 Merge pull request #43 from kforbro/master
custom command denied messages for groups & cleanup code
2021-10-26 15:48:22 +02:00
kforbro a91af744fd use isEmpty() instead of equals("") 2021-10-26 16:42:59 +03:00
kforbro 930f73d60a add an additional condition 2021-10-26 15:54:39 +03:00
YouHaveTrouble c5fdaa95f8 waterfall impl 2021-10-26 14:06:36 +02:00
YouHaveTrouble 87fc3d7da3 default message in the method itself
so we don't have to check for empty string every time we want to use it
2021-10-26 14:05:59 +02:00
YouHaveTrouble 0cc2633604 this can be null 2021-10-26 14:04:21 +02:00
YouHaveTrouble d6909b4f25 no touchy maven pls 2021-10-26 14:03:51 +02:00
kforbro cd3d527119 cleanup code 2021-10-26 12:52:40 +03:00
kforbro d43bde0750 Custom command denied message for the group 2021-10-26 12:48:59 +03:00
YouHaveTrouble 48fbd59a50 do not parse markdown for messages 2021-10-24 19:51:22 +02:00
YouHaveTrouble 7c3a06e704 version bump 2021-10-10 20:56:07 +02:00
YouHaveTrouble 5d7cd9d41f implemented packet version of commands declare 2021-10-10 20:54:17 +02:00
YouHaveTrouble f101b68ed8 relocate adventure to avoit version conflicts 2021-10-10 19:09:15 +02:00
YouHaveTrouble 707bcbbf8b Merge pull request #41 from kforbro/master
fix tab complete with useProtocolLib
2021-10-10 18:45:24 +02:00
kforbro fec7e3ba07 fix tab complete with useProtocolLib 2021-10-10 19:43:07 +03:00
YouHaveTrouble 7139baf2d9 Merge pull request #40 from kforbro/master
fix useProtocolLib
2021-10-10 18:37:35 +02:00
kforbro f1d10243ce removed debug 2021-10-10 19:36:00 +03:00
kforbro 1647605682 initializing the useProtocolLib boolean to false 2021-10-10 19:33:17 +03:00
kforbro aff390369f fix useProtocolLib 2021-10-10 19:15:23 +03:00
YouHaveTrouble c586a8af05 bstats shenanigans for proxy name 2021-09-13 22:49:49 +02:00
YouHaveTrouble 26a408812d rename modules
hopefully fix depends
2021-09-13 22:48:22 +02:00
YouHaveTrouble 727d6c3227 fix default placement 2021-09-02 03:17:36 +02:00
YouHaveTrouble 7e6b793ede bump version 2021-09-02 03:14:16 +02:00
YouHaveTrouble fd893b931d that's one dot too many 2021-09-02 03:12:42 +02:00
YouHaveTrouble 5bcf5bb130 confuse plugin snoopers 2021-09-01 17:59:55 +02:00
YouHaveTrouble 7c33718190 fail early if async suggestions empty 2021-09-01 17:51:45 +02:00
YouHaveTrouble ad599092de fix subcommand completing issues 2021-09-01 17:49:23 +02:00
YouHaveTrouble 1bb2c7ea6a remove workflows, update readme, added missing default in switch 2021-08-30 01:59:48 +02:00
YouHaveTrouble a935503239 bump version 2021-08-30 01:32:26 +02:00
YouHaveTrouble 2a6be9829c update depends and change help component 2021-08-30 01:25:19 +02:00
YouHaveTrouble 097b541a1f revert that I guess 2021-07-17 17:49:45 +02:00
YouHaveTrouble 5f447e07b6 comments and version bump 2021-07-17 17:46:20 +02:00
YouHaveTrouble b5e12655f9 now blocking utility mod .plugins 2021-07-17 17:42:04 +02:00
YouHaveTrouble 14f15aa754 cleanup&fixup 2021-07-17 17:41:44 +02:00
YouHaveTrouble 017011fad0 work on command completions 2021-07-06 21:31:51 +02:00
25 changed files with 335 additions and 191 deletions
-36
View File
@@ -1,36 +0,0 @@
name: Build CommandWhitelist Jar
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Git repo
uses: actions/checkout@v1
- name: Restore Maven cache
uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn package --file pom.xml
- name: Copy artifacts
uses: actions/upload-artifact@master
with:
name: CommandWhitelist
path: target/CommandWhitelist*.jar
+20 -6
View File
@@ -6,12 +6,12 @@
<parent> <parent>
<groupId>eu.endermite.commandwhitelist</groupId> <groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId> <artifactId>CommandWhitelist</artifactId>
<version>2.0-ALPHA-2</version> <version>2.2.2</version>
</parent> </parent>
<artifactId>Bukkit</artifactId> <artifactId>Bukkit</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>CommandWhitelist</name> <name>CommandWhitelist-Bukkit</name>
<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>
@@ -34,7 +34,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version> <version>3.3.0-SNAPSHOT</version>
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>
@@ -42,13 +42,17 @@
<goal>shade</goal> <goal>shade</goal>
</goals> </goals>
<configuration> <configuration>
<finalName>${project.name}-${project.artifactId}-${project.parent.version}</finalName> <finalName>${project.name}-${project.parent.version}</finalName>
<createDependencyReducedPom>false</createDependencyReducedPom> <createDependencyReducedPom>false</createDependencyReducedPom>
<relocations> <relocations>
<relocation> <relocation>
<pattern>org.bstats</pattern> <pattern>org.bstats</pattern>
<shadedPattern>eu.endermite.bstats</shadedPattern> <shadedPattern>eu.endermite.bstats</shadedPattern>
</relocation> </relocation>
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>eu.endermite</shadedPattern>
</relocation>
</relocations> </relocations>
</configuration> </configuration>
</execution> </execution>
@@ -72,13 +76,17 @@
<id>dmulloy2-repo</id> <id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/nexus/repository/public/</url> <url>https://repo.dmulloy2.net/nexus/repository/public/</url>
</repository> </repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.destroystokyo.paper</groupId> <groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId> <artifactId>paper-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version> <version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@@ -105,5 +113,11 @@
<version>2.2.1</version> <version>2.2.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>brigadier</artifactId>
<version>1.0.17</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>
@@ -1,14 +1,16 @@
package eu.endermite.commandwhitelist.bukkit; package eu.endermite.commandwhitelist.bukkit;
import eu.endermite.commandwhitelist.bukkit.command.MainCommandExecutor; import eu.endermite.commandwhitelist.bukkit.command.MainCommandExecutor;
import eu.endermite.commandwhitelist.bukkit.listeners.PacketCommandPreProcessListener; import eu.endermite.commandwhitelist.bukkit.listeners.AsyncTabCompleteBlockerListener;
import eu.endermite.commandwhitelist.bukkit.listeners.PlayerCommandPreProcessListener; import eu.endermite.commandwhitelist.bukkit.listeners.PlayerCommandPreProcessListener;
import eu.endermite.commandwhitelist.bukkit.listeners.PlayerCommandSendListener; import eu.endermite.commandwhitelist.bukkit.listeners.PlayerCommandSendListener;
import eu.endermite.commandwhitelist.bukkit.listeners.TabCompleteBlockerListener; import eu.endermite.commandwhitelist.bukkit.listeners.TabCompleteBlockerListener;
import eu.endermite.commandwhitelist.bukkit.listeners.protocollib.PacketCommandPreProcessListener;
import eu.endermite.commandwhitelist.bukkit.listeners.protocollib.PacketCommandSendListener;
import eu.endermite.commandwhitelist.common.CWGroup; import eu.endermite.commandwhitelist.common.CWGroup;
import eu.endermite.commandwhitelist.common.ConfigCache; import eu.endermite.commandwhitelist.common.ConfigCache;
import eu.endermite.commandwhitelist.common.commands.CWCommand;
import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@@ -44,8 +46,15 @@ public class CommandWhitelistBukkit extends JavaPlugin {
getServer().getPluginManager().registerEvents(new PlayerCommandSendListener(), this); getServer().getPluginManager().registerEvents(new PlayerCommandSendListener(), this);
} else { } else {
PacketCommandPreProcessListener.protocol(this); PacketCommandPreProcessListener.protocol(this);
PacketCommandSendListener.protocol(this);
getLogger().info(ChatColor.AQUA + "Using ProtocolLib for command filter!"); getLogger().info(ChatColor.AQUA + "Using ProtocolLib for command filter!");
} }
try {
// Use paper's async tab completions if possible
Class.forName("com.destroystokyo.paper.event.server.AsyncTabCompleteEvent");
getServer().getPluginManager().registerEvents(new AsyncTabCompleteBlockerListener(), this);
} catch (ClassNotFoundException ignored) {
}
getServer().getPluginManager().registerEvents(new TabCompleteBlockerListener(), this); getServer().getPluginManager().registerEvents(new TabCompleteBlockerListener(), this);
PluginCommand command = getCommand("commandwhitelist"); PluginCommand command = getCommand("commandwhitelist");
@@ -60,8 +69,13 @@ public class CommandWhitelistBukkit extends JavaPlugin {
private void reloadPluginConfig() { private void reloadPluginConfig() {
File configFile = new File("plugins/CommandWhitelist/config.yml"); File configFile = new File("plugins/CommandWhitelist/config.yml");
if (configCache == null) if (configCache == null) {
try {
configCache = new ConfigCache(configFile, true, getSLF4JLogger()); configCache = new ConfigCache(configFile, true, getSLF4JLogger());
} catch (NoSuchMethodError e) {
configCache = new ConfigCache(configFile, true, null);
}
}
else else
configCache.reloadConfig(); configCache.reloadConfig();
} }
@@ -69,10 +83,12 @@ public class CommandWhitelistBukkit extends JavaPlugin {
public void reloadPluginConfig(CommandSender sender) { public void reloadPluginConfig(CommandSender sender) {
getServer().getScheduler().runTaskAsynchronously(this, () -> { getServer().getScheduler().runTaskAsynchronously(this, () -> {
reloadPluginConfig(); reloadPluginConfig();
try {
for (Player p : Bukkit.getOnlinePlayers()) { for (Player p : Bukkit.getOnlinePlayers()) {
p.updateCommands(); p.updateCommands();
} }
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.config_reloaded)); } catch (Exception ignored) {}
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.config_reloaded));
}); });
} }
@@ -119,4 +135,20 @@ public class CommandWhitelistBukkit extends JavaPlugin {
} }
return suggestionList; return suggestionList;
} }
/**
* @return Command denied message. Will use custom if command exists in any group.
*/
public static String getCommandDeniedMessage(String command) {
String commandDeniedMessage = configCache.command_denied;
HashMap<String, CWGroup> groups = configCache.getGroupList();
for (CWGroup group : groups.values()) {
if (group.getCommands().contains(command)) {
if (group.getCommandDeniedMessage() == null || group.getCommandDeniedMessage().isEmpty()) continue;
commandDeniedMessage = group.getCommandDeniedMessage();
break; // get first message we find
}
}
return commandDeniedMessage;
}
} }
@@ -5,7 +5,6 @@ import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.common.commands.CWCommand; import eu.endermite.commandwhitelist.common.commands.CWCommand;
import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@@ -26,40 +25,39 @@ public class MainCommandExecutor implements TabExecutor {
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission()))); audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
return true; return true;
} }
try { try {
CWCommand.CommandType commandType = CWCommand.CommandType.valueOf(args[0].toUpperCase()); CWCommand.CommandType commandType = CWCommand.CommandType.valueOf(args[0].toUpperCase());
switch (commandType) { switch (commandType) {
case RELOAD: case RELOAD:
if (!sender.hasPermission(CWPermission.RELOAD.permission())) { if (!sender.hasPermission(CWPermission.RELOAD.permission())) {
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission)); audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission));
return true; return true;
} }
CommandWhitelistBukkit.getPlugin().reloadPluginConfig(sender); CommandWhitelistBukkit.getPlugin().reloadPluginConfig(sender);
return true; return true;
case ADD: case ADD:
if (!sender.hasPermission(CWPermission.ADMIN.permission())) { if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission)); audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission));
return true; return true;
} }
if (args.length == 3) { if (args.length == 3) {
if (CWCommand.addToWhitelist(CommandWhitelistBukkit.getConfigCache(), args[2], args[1])) if (CWCommand.addToWhitelist(CommandWhitelistBukkit.getConfigCache(), args[2], args[1]))
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().added_to_whitelist, args[2], args[1]))); audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().added_to_whitelist, args[2], args[1])));
else else
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().group_doesnt_exist, args[1]))); audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().group_doesnt_exist, args[1])));
} else } else
audiences.sender(sender).sendMessage(Component.text("/" + label + " add <group> <command>")); audiences.sender(sender).sendMessage(Component.text("/" + label + " add <group> <command>"));
return true; return true;
case REMOVE: case REMOVE:
if (!sender.hasPermission(CWPermission.ADMIN.permission())) { if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission)); audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission));
return true; return true;
} }
if (args.length == 3) { if (args.length == 3) {
if (CWCommand.removeFromWhitelist(CommandWhitelistBukkit.getConfigCache(), args[2], args[1])) if (CWCommand.removeFromWhitelist(CommandWhitelistBukkit.getConfigCache(), args[2], args[1]))
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().removed_from_whitelist, args[2], args[1]))); audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().removed_from_whitelist, args[2], args[1])));
else else
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().group_doesnt_exist, args[1]))); audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().group_doesnt_exist, args[1])));
} else } else
audiences.sender(sender).sendMessage(Component.text("/" + label + " remove <group> <command>")); audiences.sender(sender).sendMessage(Component.text("/" + label + " remove <group> <command>"));
return true; return true;
@@ -0,0 +1,26 @@
package eu.endermite.commandwhitelist.bukkit.listeners;
import com.destroystokyo.paper.event.server.AsyncTabCompleteEvent;
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.common.CommandUtil;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public class AsyncTabCompleteBlockerListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onCommandTabComplete(AsyncTabCompleteEvent event) {
if (!(event.getSender() instanceof Player)) return;
Player player = (Player) event.getSender();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
String buffer = event.getBuffer();
if (!buffer.endsWith(" ") && buffer.split(" ").length == 1) event.setCancelled(true);
if (event.getCompletions().isEmpty()) return;
event.setCompletions(CommandUtil.filterSuggestions(buffer, event.getCompletions(), CommandWhitelistBukkit.getSuggestions(player)));
}
}
@@ -3,8 +3,8 @@ package eu.endermite.commandwhitelist.bukkit.listeners;
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit; import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
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 net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.entity.Player; 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;
@@ -24,7 +24,7 @@ public class PlayerCommandPreProcessListener implements Listener {
HashSet<String> commands = CommandWhitelistBukkit.getCommands(player); HashSet<String> commands = CommandWhitelistBukkit.getCommands(player);
if (!commands.contains(label)) { if (!commands.contains(label)) {
event.setCancelled(true); event.setCancelled(true);
audiences.player(player).sendMessage(MiniMessage.markdown().parse(config.prefix + config.command_denied)); audiences.player(player).sendMessage(CWCommand.miniMessage.parse(config.prefix + CommandWhitelistBukkit.getCommandDeniedMessage(label)));
return; return;
} }
@@ -32,7 +32,7 @@ public class PlayerCommandPreProcessListener implements Listener {
for (String bannedSubCommand : bannedSubCommands) { for (String bannedSubCommand : bannedSubCommands) {
if (event.getMessage().toLowerCase().substring(1).startsWith(bannedSubCommand)) { if (event.getMessage().toLowerCase().substring(1).startsWith(bannedSubCommand)) {
event.setCancelled(true); event.setCancelled(true);
audiences.player(player).sendMessage(MiniMessage.markdown().parse(config.prefix + config.subcommand_denied)); audiences.player(player).sendMessage(CWCommand.miniMessage.parse(config.prefix + config.subcommand_denied));
return; return;
} }
} }
@@ -7,16 +7,21 @@ 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.server.TabCompleteEvent;
public class TabCompleteBlockerListener implements Listener { public class TabCompleteBlockerListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onCommandTabComplete(org.bukkit.event.server.TabCompleteEvent event) { public void onCommandTabComplete(TabCompleteEvent event) {
if (!(event.getSender() instanceof Player)) return; if (!(event.getSender() instanceof Player)) return;
Player player = (Player) event.getSender(); Player player = (Player) event.getSender();
if (player.hasPermission(CWPermission.BYPASS.permission())) return; if (player.hasPermission(CWPermission.BYPASS.permission())) return;
String buffer = event.getBuffer();
if (!buffer.endsWith(" ") && buffer.split(" ").length == 1) event.setCancelled(true);
if (event.getCompletions().isEmpty()) return;
event.setCompletions( event.setCompletions(
CommandUtil.filterSuggestions( CommandUtil.filterSuggestions(
event.getBuffer(), buffer,
event.getCompletions(), event.getCompletions(),
CommandWhitelistBukkit.getSuggestions(player) CommandWhitelistBukkit.getSuggestions(player)
) )
@@ -1,4 +1,4 @@
package eu.endermite.commandwhitelist.bukkit.listeners; package eu.endermite.commandwhitelist.bukkit.listeners.protocollib;
import com.comphenix.protocol.PacketType; import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolLibrary;
@@ -11,7 +11,8 @@ import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
import eu.endermite.commandwhitelist.common.CWPermission; 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 net.kyori.adventure.text.minimessage.MiniMessage; import eu.endermite.commandwhitelist.common.commands.CWCommand;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@@ -37,17 +38,17 @@ public class PacketCommandPreProcessListener {
ConfigCache config = CommandWhitelistBukkit.getConfigCache(); ConfigCache config = CommandWhitelistBukkit.getConfigCache();
String label = CommandUtil.getCommandLabel(string.toLowerCase()); String label = CommandUtil.getCommandLabel(string.toLowerCase());
HashSet<String> commands = CommandWhitelistBukkit.getCommands(player); HashSet<String> commands = CommandWhitelistBukkit.getCommands(player);
BukkitAudiences audiences = CommandWhitelistBukkit.getAudiences();
if (!commands.contains(label)) { if (!commands.contains(label)) {
event.setCancelled(true); event.setCancelled(true);
CommandWhitelistBukkit.getAudiences().player(player).sendMessage(MiniMessage.markdown().parse(config.prefix + config.command_denied)); audiences.player(player).sendMessage(CWCommand.miniMessage.parse(config.prefix + CommandWhitelistBukkit.getCommandDeniedMessage(label)));
return; return;
} }
HashSet<String> bannedSubCommands = CommandWhitelistBukkit.getSuggestions(player); HashSet<String> bannedSubCommands = CommandWhitelistBukkit.getSuggestions(player);
for (String bannedSubCommand : bannedSubCommands) { for (String bannedSubCommand : bannedSubCommands) {
if (string.toLowerCase().substring(1).startsWith(bannedSubCommand)) { if (string.toLowerCase().substring(1).startsWith(bannedSubCommand)) {
event.setCancelled(true); event.setCancelled(true);
CommandWhitelistBukkit.getAudiences().player(player).sendMessage(MiniMessage.markdown().parse(config.prefix + config.subcommand_denied)); CommandWhitelistBukkit.getAudiences().player(player).sendMessage(CWCommand.miniMessage.parse(config.prefix + config.subcommand_denied));
return; return;
} }
} }
@@ -0,0 +1,40 @@
package eu.endermite.commandwhitelist.bukkit.listeners.protocollib;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.mojang.brigadier.tree.RootCommandNode;
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
import eu.endermite.commandwhitelist.common.CWPermission;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.util.HashSet;
public class PacketCommandSendListener {
public static void protocol(CommandWhitelistBukkit plugin) {
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
commandSendListener(protocolManager, plugin);
}
public static void commandSendListener(ProtocolManager protocolManager, Plugin plugin) {
protocolManager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.HIGHEST, PacketType.Play.Server.COMMANDS) {
@Override
public void onPacketSending(PacketEvent event) {
Player player = event.getPlayer();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
HashSet<String> commandList = CommandWhitelistBukkit.getCommands(player);
PacketContainer packet = event.getPacket();
RootCommandNode<?> node = (RootCommandNode<?>) packet.getModifier().getValues().get(0);
node.getChildren().removeIf((cmd) -> !commandList.contains(cmd.getName()));
}
});
}
}
@@ -4,6 +4,7 @@ version: ${project.version}
api-version: 1.13 api-version: 1.13
main: eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit main: eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit
authors: [YouHaveTrouble] authors: [YouHaveTrouble]
website: youhavetrouble.me
softdepend: softdepend:
- ProtocolLib - ProtocolLib
description: Control what commands players can use description: Control what commands players can use
@@ -14,8 +15,8 @@ commands:
usage: /commandwhitelist [args] usage: /commandwhitelist [args]
permissions: permissions:
commandwhitelist.reload: commandwhitelist.reload:
default: OP default: op
commandwhitelist.admin: commandwhitelist.admin:
default: OP default: op
commandwhitelist.bypass: commandwhitelist.bypass:
default: OP default: op
+15 -11
View File
@@ -6,12 +6,12 @@
<parent> <parent>
<groupId>eu.endermite.commandwhitelist</groupId> <groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId> <artifactId>CommandWhitelist</artifactId>
<version>2.0-ALPHA-2</version> <version>2.2.2</version>
</parent> </parent>
<artifactId>Common</artifactId> <artifactId>Common</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>CommandWhitelist</name> <name>CommandWhitelist-Common</name>
<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>
@@ -43,7 +43,7 @@
</goals> </goals>
<configuration> <configuration>
<createDependencyReducedPom>false</createDependencyReducedPom> <createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>${project.name}-${project.artifactId}-${project.parent.version}</finalName> <finalName>${project.name}-${project.parent.version}</finalName>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
@@ -59,20 +59,24 @@
<repositories> <repositories>
<repository> <repository>
<id>jitpack.io</id> <id>pluginwiki-repo</id>
<url>https://jitpack.io</url> <url>https://ci.pluginwiki.us/plugin/repository/everything/</url>
</repository> </repository>
<repository> <repository>
<id>velocitypowered-repo</id> <id>velocitypowered-repo</id>
<url>https://repo.velocitypowered.com/releases/</url> <url>https://repo.velocitypowered.com/releases/</url>
</repository> </repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.github.Thatsmusic99</groupId> <groupId>com.github.thatsmusic99</groupId>
<artifactId>ConfigurationMaster</artifactId> <artifactId>ConfigurationMaster-API</artifactId>
<version>v2.0.0-ALPHA-3</version> <version>v2.0.0-BETA-1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
@@ -82,15 +86,15 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.destroystokyo.paper</groupId> <groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId> <artifactId>paper-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version> <version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.github.waterfallmc</groupId> <groupId>io.github.waterfallmc</groupId>
<artifactId>waterfall-api</artifactId> <artifactId>waterfall-api</artifactId>
<version>1.16-R0.5-SNAPSHOT</version> <version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
@@ -1,17 +1,20 @@
package eu.endermite.commandwhitelist.common; package eu.endermite.commandwhitelist.common;
import org.jetbrains.annotations.Nullable;
import java.util.*; import java.util.*;
public class CWGroup { public class CWGroup {
private final String id, permission; private final String id, permission, commandDeniedMessage;
private final HashSet<String> commands = new HashSet<>(); private final HashSet<String> commands = new HashSet<>();
private final HashSet<String> subCommands = new HashSet<>(); private final HashSet<String> subCommands = new HashSet<>();
public CWGroup(String id, Collection<String> commands, Collection<String> subCommands) { public CWGroup(String id, Collection<String> commands, Collection<String> subCommands, String custom_command_denied_message) {
this.id = id; this.id = id;
this.permission = "commandwhitelist.group."+id; this.permission = "commandwhitelist.group." + id;
this.commands.addAll(commands); this.commands.addAll(commands);
this.commandDeniedMessage = custom_command_denied_message;
this.subCommands.addAll(subCommands); this.subCommands.addAll(subCommands);
} }
@@ -27,6 +30,10 @@ public class CWGroup {
return commands; return commands;
} }
public @Nullable String getCommandDeniedMessage() {
return commandDeniedMessage;
}
public void addCommand(String command) { public void addCommand(String command) {
commands.add(command); commands.add(command);
} }
@@ -18,6 +18,7 @@ public enum CWPermission {
/** /**
* Allows to check specific group permission * Allows to check specific group permission
*
* @param configCache * @param configCache
* @param groupId * @param groupId
* @return * @return
@@ -51,9 +51,11 @@ public class ConfigCache {
exampleCommands.add("example"); exampleCommands.add("example");
List<String> exampleSubCommands = new ArrayList<>(); List<String> exampleSubCommands = new ArrayList<>();
exampleSubCommands.add("example of"); exampleSubCommands.add("example of");
String exampleCustomCommandDeniedMessage = "You don't have commandwhitelist.group.example permission.";
config.addExample("groups.example.commands", exampleCommands, "This is the WHITELIST of commands that players will be able to see/use in the group \"example\""); config.addExample("groups.example.commands", exampleCommands, "This is the WHITELIST of commands that players will be able to see/use in the group \"example\"");
config.addExample("groups.example.subcommands", exampleSubCommands, "This is the BLACKLIST of subcommands that players will NOT be able to see/use in the group \"example\""); config.addExample("groups.example.subcommands", exampleSubCommands, "This is the BLACKLIST of subcommands that players will NOT be able to see/use in the group \"example\"");
config.addExample("groups.example.custom_command_denied_message", exampleCustomCommandDeniedMessage, "This is a custom message that players will see if they do not have commandwhitelist.group.<group_name> permission.\ncommandwhitelist.group.example in this case\nIf you don't want to use a custom message, set custom_command_denid_message: \"\"");
config.addComment("groups.example", "All groups except from default require commandwhitelist.group.<group_name> permission\ncommandwhitelist.group.example in this case\n If you wish to leave the list empty, put \"commands: []\" or \"subcommands: []\""); config.addComment("groups.example", "All groups except from default require commandwhitelist.group.<group_name> permission\ncommandwhitelist.group.example in this case\n If you wish to leave the list empty, put \"commands: []\" or \"subcommands: []\"");
} }
@@ -75,7 +77,9 @@ public class ConfigCache {
List<String> defaultSubcommands = new ArrayList<>(); List<String> defaultSubcommands = new ArrayList<>();
defaultSubcommands.add("help about"); defaultSubcommands.add("help about");
config.addDefault("groups.default", new CWGroup("default", defaultCommands, defaultSubcommands).serialize()); String defaultCustomCommandDeniedMessage = "";
config.addDefault("groups.default", new CWGroup("default", defaultCommands, defaultSubcommands, defaultCustomCommandDeniedMessage).serialize());
prefix = config.getString("messages.prefix"); prefix = config.getString("messages.prefix");
command_denied = config.getString("messages.command_denied"); command_denied = config.getString("messages.command_denied");
@@ -86,6 +90,7 @@ public class ConfigCache {
added_to_whitelist = config.getString("messages.added_to_whitelist"); added_to_whitelist = config.getString("messages.added_to_whitelist");
removed_from_whitelist = config.getString("messages.removed_from_whitelist"); removed_from_whitelist = config.getString("messages.removed_from_whitelist");
group_doesnt_exist = config.getString("messages.group_doesnt_exist"); group_doesnt_exist = config.getString("messages.group_doesnt_exist");
useProtocolLib = config.getBoolean("use_protocollib");
ConfigSection groupSection = config.getConfigSection("groups"); ConfigSection groupSection = config.getConfigSection("groups");
for (String key : groupSection.getKeys(false)) { for (String key : groupSection.getKeys(false)) {
@@ -127,13 +132,16 @@ public class ConfigCache {
if (commands.contains(cmd)) continue; if (commands.contains(cmd)) continue;
commands.add(cmd); commands.add(cmd);
} }
List<String> subCommands = new ArrayList<>();
List<String> subCommands = section.getStringList(id + ".subcommands"); for (String subCmd : section.getStringList(id + ".subcommands")) {
return new CWGroup(id, commands, subCommands); subCommands.add(String.valueOf(subCmd));
}
String customCommandDeniedMessage = section.getString(id + ".custom_command_denied_message");
return new CWGroup(id, commands, subCommands, customCommandDeniedMessage);
} }
public void saveCWGroup(String id, CWGroup group) { public void saveCWGroup(String id, CWGroup group) {
config.set("groups." + id + ".", group.serialize()); config.set("groups." + id, group.serialize());
saveConfig(); saveConfig();
} }
@@ -142,6 +150,10 @@ public class ConfigCache {
} }
private void warn(String log) { private void warn(String log) {
if (logger == null) {
System.out.println("WARNING: "+log);
return;
}
if (logger instanceof org.slf4j.Logger) { if (logger instanceof org.slf4j.Logger) {
((org.slf4j.Logger) logger).warn(log); ((org.slf4j.Logger) logger).warn(log);
return; return;
@@ -3,10 +3,9 @@ package eu.endermite.commandwhitelist.common.commands;
import eu.endermite.commandwhitelist.common.CWGroup; import eu.endermite.commandwhitelist.common.CWGroup;
import eu.endermite.commandwhitelist.common.ConfigCache; import eu.endermite.commandwhitelist.common.ConfigCache;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.transformation.TransformationType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -14,10 +13,19 @@ import java.util.List;
public class CWCommand { public class CWCommand {
public static MiniMessage miniMessage = MiniMessage.builder()
.removeDefaultTransformations()
.transformation(TransformationType.COLOR)
.transformation(TransformationType.DECORATION)
.transformation(TransformationType.GRADIENT)
.transformation(TransformationType.RESET)
.transformation(TransformationType.RAINBOW)
.transformation(TransformationType.PRE)
.build();
public static boolean addToWhitelist(ConfigCache configCache, String command, String group) { public static boolean addToWhitelist(ConfigCache configCache, String command, String group) {
CWGroup cwGroup = configCache.getGroupList().get(group); CWGroup cwGroup = configCache.getGroupList().get(group);
if (cwGroup == null) if (cwGroup == null) return false;
return false;
cwGroup.addCommand(command); cwGroup.addCommand(command);
configCache.saveCWGroup(group, cwGroup); configCache.saveCWGroup(group, cwGroup);
return true; return true;
@@ -33,19 +41,18 @@ public class CWCommand {
} }
public static Component helpComponent(String baseCommand, boolean showReloadCommand, boolean showAdminCommands) { public static Component helpComponent(String baseCommand, boolean showReloadCommand, boolean showAdminCommands) {
Component component = MiniMessage.markdown().parse("<rainbow><bold>CommandWhitelist by YouHaveTrouble") Component component = miniMessage.parse("<rainbow><bold>CommandWhitelist by YouHaveTrouble")
.append(Component.newline()); .append(Component.newline());
component = component.append(Component.text("Hover over the command to see what it does!").color(NamedTextColor.AQUA)).decoration(TextDecoration.BOLD, false).append(Component.newline()); component = component.append(Component.text("/" + baseCommand + " help").color(NamedTextColor.AQUA).append(Component.text(" - Displays this message").color(NamedTextColor.BLUE)));
component = component.append(Component.text("/"+baseCommand+" help").color(NamedTextColor.AQUA).hoverEvent(HoverEvent.showText(Component.text("Displays this message"))));
if (showReloadCommand) { if (showReloadCommand) {
component = component.append(Component.newline()); component = component.append(Component.newline());
component = component.append(Component.text("/"+baseCommand+" reload").color(NamedTextColor.AQUA).hoverEvent(HoverEvent.showText(Component.text("Reloads plugin configuration")))); component = component.append(Component.text("/" + baseCommand + " reload").color(NamedTextColor.AQUA).append(Component.text(" - Reloads plugin configuration").color(NamedTextColor.BLUE)));
} }
if (showAdminCommands) { if (showAdminCommands) {
component = component.append(Component.newline()); component = component.append(Component.newline());
component = component.append(Component.text("/"+baseCommand+" add <group> <command>").color(NamedTextColor.AQUA).hoverEvent(HoverEvent.showText(Component.text("Add a command to selected permission group")))); component = component.append(Component.text("/" + baseCommand + " add <group> <command>").color(NamedTextColor.AQUA).append(Component.text(" - Add a command to selected permission group").color(NamedTextColor.BLUE)));
component = component.append(Component.newline()); component = component.append(Component.newline());
component = component.append(Component.text("/"+baseCommand+" remove <group> <command>").color(NamedTextColor.AQUA).hoverEvent(HoverEvent.showText(Component.text("Removes a command from selected permission group")))); component = component.append(Component.text("/" + baseCommand + " remove <group> <command>").color(NamedTextColor.AQUA).append(Component.text(" - Removes a command from selected permission group").color(NamedTextColor.BLUE)));
} }
return component; return component;
} }
@@ -57,6 +64,7 @@ public class CWCommand {
public static List<String> commandSuggestions(ConfigCache config, Collection<String> serverCommands, String[] args, boolean reloadPerm, boolean adminPerm) { public static List<String> commandSuggestions(ConfigCache config, Collection<String> serverCommands, String[] args, boolean reloadPerm, boolean adminPerm) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
switch (args.length) { switch (args.length) {
case 0:
case 1: case 1:
if ("reload".startsWith(args[0]) && reloadPerm) if ("reload".startsWith(args[0]) && reloadPerm)
list.add("reload"); list.add("reload");
@@ -77,34 +85,35 @@ public class CWCommand {
case 3: case 3:
if (args[0].equalsIgnoreCase("remove")) { if (args[0].equalsIgnoreCase("remove")) {
if (!adminPerm) return list; if (!adminPerm) return list;
try { CWGroup group = config.getGroupList().get(args[1]);
for (String s : config.getGroupList().get(args[1]).getCommands()) { if (group == null) return list;
for (String s : group.getCommands()) {
if (s.startsWith(args[2])) if (s.startsWith(args[2]))
list.add(s); list.add(s);
} }
} catch (NullPointerException ignored) {
}
return list; return list;
} }
if (args[0].equalsIgnoreCase("add")) { if (args[0].equalsIgnoreCase("add")) {
if (!adminPerm) return list; if (!adminPerm) return list;
CWGroup group = config.getGroupList().get(args[1]);
if (group == null) return list;
for (String cmd : serverCommands) { for (String cmd : serverCommands) {
if (!cmd.startsWith("/")) continue; if (cmd.startsWith("/"))
cmd = cmd.substring(1);
if (cmd.contains(":")) { if (cmd.contains(":")) {
String[] cmdSplit = cmd.split(":"); String[] cmdSplit = cmd.split(":");
if (cmdSplit.length < 2) continue; if (cmdSplit.length < 2) continue;
cmd = cmd.split(":")[1]; cmd = cmdSplit[1];
} }
cmd = cmd.replace("/", ""); if (group.getCommands().contains(cmd)) continue;
if (config.getGroupList().get(args[1]) == null) continue;
if (config.getGroupList().get(args[1]).getCommands().contains(cmd)) continue;
if (cmd.startsWith(args[2])) if (cmd.startsWith(args[2]))
list.add(cmd); list.add(cmd);
} }
return list; return list;
} }
} default:
return list; return list;
} }
}
} }
+4 -4
View File
@@ -6,12 +6,12 @@
<parent> <parent>
<groupId>eu.endermite.commandwhitelist</groupId> <groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId> <artifactId>CommandWhitelist</artifactId>
<version>2.0-ALPHA-2</version> <version>2.2.2</version>
</parent> </parent>
<artifactId>Velocity</artifactId> <artifactId>Velocity</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>CommandWhitelist</name> <name>CommandWhitelist-Velocity</name>
<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>
@@ -43,7 +43,7 @@
</goals> </goals>
<configuration> <configuration>
<createDependencyReducedPom>false</createDependencyReducedPom> <createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>${project.name}-${project.artifactId}-${project.parent.version}</finalName> <finalName>${project.name}-${project.parent.version}</finalName>
<relocations> <relocations>
<relocation> <relocation>
<pattern>org.bstats</pattern> <pattern>org.bstats</pattern>
@@ -82,7 +82,7 @@
<dependency> <dependency>
<groupId>com.velocitypowered</groupId> <groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId> <artifactId>velocity-api</artifactId>
<version>1.1.0</version> <version>3.0.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@@ -12,9 +12,9 @@ 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.ConfigCache; import eu.endermite.commandwhitelist.common.ConfigCache;
import eu.endermite.commandwhitelist.common.commands.CWCommand;
import eu.endermite.commandwhitelist.velocity.command.VelocityMainCommand; import eu.endermite.commandwhitelist.velocity.command.VelocityMainCommand;
import net.kyori.adventure.identity.Identity; import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bstats.charts.SimplePie; import org.bstats.charts.SimplePie;
import org.bstats.velocity.Metrics; import org.bstats.velocity.Metrics;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -55,7 +55,7 @@ public class CommandWhitelistVelocity {
public static void reloadConfig(CommandSource source) { public static void reloadConfig(CommandSource source) {
server.getScheduler().buildTask(plugin, () -> { server.getScheduler().buildTask(plugin, () -> {
reloadConfig(); reloadConfig();
source.sendMessage(Identity.nil(), MiniMessage.markdown().parse(getConfigCache().prefix+getConfigCache().config_reloaded)); source.sendMessage(Identity.nil(), CWCommand.miniMessage.parse(getConfigCache().prefix + getConfigCache().config_reloaded));
}).schedule(); }).schedule();
} }
@@ -65,7 +65,7 @@ public class CommandWhitelistVelocity {
CommandMeta commandMeta = server.getCommandManager().metaBuilder("vcw").build(); CommandMeta commandMeta = server.getCommandManager().metaBuilder("vcw").build();
server.getCommandManager().register(commandMeta, new VelocityMainCommand()); server.getCommandManager().register(commandMeta, new VelocityMainCommand());
Metrics metrics = metricsFactory.make(this, 8704); Metrics metrics = metricsFactory.make(this, 8704);
metrics.addCustomChart(new SimplePie("proxy", ()-> "Velocity")); metrics.addCustomChart(new SimplePie("proxy", () -> "Velocity"));
} }
@Subscribe @Subscribe
@@ -105,10 +105,11 @@ public class CommandWhitelistVelocity {
HashMap<String, CWGroup> groups = configCache.getGroupList(); HashMap<String, CWGroup> groups = configCache.getGroupList();
HashSet<String> commandList = new HashSet<>(); HashSet<String> commandList = new HashSet<>();
for (Map.Entry<String, CWGroup> s : groups.entrySet()) { for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
CWGroup group = s.getValue();
if (s.getKey().equalsIgnoreCase("default")) if (s.getKey().equalsIgnoreCase("default"))
commandList.addAll(s.getValue().getCommands()); commandList.addAll(group.getCommands());
else if (player.hasPermission(s.getValue().getPermission())) else if (player.hasPermission(group.getPermission()))
commandList.addAll(s.getValue().getCommands()); commandList.addAll(group.getCommands());
} }
return commandList; return commandList;
} }
@@ -6,7 +6,6 @@ import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.common.commands.CWCommand; import eu.endermite.commandwhitelist.common.commands.CWCommand;
import eu.endermite.commandwhitelist.velocity.CommandWhitelistVelocity; import eu.endermite.commandwhitelist.velocity.CommandWhitelistVelocity;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -30,36 +29,36 @@ public class VelocityMainCommand implements SimpleCommand {
switch (commandType) { switch (commandType) {
case RELOAD: case RELOAD:
if (!sender.hasPermission(CWPermission.RELOAD.permission())) { if (!sender.hasPermission(CWPermission.RELOAD.permission())) {
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission)); sender.sendMessage(CWCommand.miniMessage.parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
return; return;
} }
CommandWhitelistVelocity.reloadConfig(sender); CommandWhitelistVelocity.reloadConfig(sender);
return; return;
case ADD: case ADD:
if (!sender.hasPermission(CWPermission.ADMIN.permission())) { if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission)); sender.sendMessage(CWCommand.miniMessage.parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
return; return;
} }
if (args.length == 3) { if (args.length == 3) {
if (CWCommand.addToWhitelist(CommandWhitelistVelocity.getConfigCache(), args[2], args[1])) if (CWCommand.addToWhitelist(CommandWhitelistVelocity.getConfigCache(), args[2], args[1]))
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().added_to_whitelist)); sender.sendMessage(CWCommand.miniMessage.parse(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().added_to_whitelist, args[2], args[1])));
else else
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().group_doesnt_exist)); sender.sendMessage(CWCommand.miniMessage.parse(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().group_doesnt_exist, args[1])));
} else } else
sender.sendMessage(Component.text("/"+label+" add <group> <command>")); sender.sendMessage(Component.text("/" + label + " add <group> <command>"));
return; return;
case REMOVE: case REMOVE:
if (!sender.hasPermission(CWPermission.ADMIN.permission())) { if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission)); sender.sendMessage(CWCommand.miniMessage.parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
return; return;
} }
if (args.length == 3) { if (args.length == 3) {
if (CWCommand.removeFromWhitelist(CommandWhitelistVelocity.getConfigCache(), args[2], args[1])) if (CWCommand.removeFromWhitelist(CommandWhitelistVelocity.getConfigCache(), args[2], args[1]))
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().removed_from_whitelist)); sender.sendMessage(CWCommand.miniMessage.parse(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().removed_from_whitelist, args[2], args[1])));
else else
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().group_doesnt_exist)); sender.sendMessage(CWCommand.miniMessage.parse(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().group_doesnt_exist, args[1])));
} else } else
sender.sendMessage(Component.text("/"+label+" remove <group> <command>")); sender.sendMessage(Component.text("/" + label + " remove <group> <command>"));
return; return;
case HELP: case HELP:
default: default:
@@ -77,12 +76,8 @@ public class VelocityMainCommand implements SimpleCommand {
CommandSource source = invocation.source(); CommandSource source = invocation.source();
String[] args = invocation.arguments(); String[] args = invocation.arguments();
return CompletableFuture.supplyAsync(() -> { return CompletableFuture.supplyAsync(() -> {
List<String> suggestions = new ArrayList<>(); List<String> serverCommands = new ArrayList<>();
if (args.length == 1) { return CWCommand.commandSuggestions(CommandWhitelistVelocity.getConfigCache(), serverCommands, args, source.hasPermission(CWPermission.RELOAD.permission()), source.hasPermission(CWPermission.ADMIN.permission()));
if (source.hasPermission(CWPermission.RELOAD.permission()) && "reload".startsWith(args[0]))
suggestions.add("reload");
}
return suggestions;
}); });
} }
} }
@@ -1,9 +1,9 @@
{ {
"id":"commandwhitelist", "id": "commandwhitelist",
"name":"CommandWhitelist", "name": "CommandWhitelist",
"version":"${project.version}", "version": "${project.version}",
"description":"You decide what commands players can use or tab complete on your server!", "description": "You decide what commands players can use or tab complete on your server!",
"authors":["YouHaveTrouble"], "authors": ["YouHaveTrouble"],
"dependencies":[], "dependencies": [],
"main":"eu.endermite.commandwhitelist.velocity.CommandWhitelistVelocity" "main": "eu.endermite.commandwhitelist.velocity.CommandWhitelistVelocity"
} }
+14 -13
View File
@@ -6,12 +6,12 @@
<parent> <parent>
<groupId>eu.endermite.commandwhitelist</groupId> <groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId> <artifactId>CommandWhitelist</artifactId>
<version>2.0-ALPHA-2</version> <version>2.2.2</version>
</parent> </parent>
<artifactId>Waterfall</artifactId> <artifactId>Waterfall</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>CommandWhitelist</name> <name>CommandWhitelist-Waterfall</name>
<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>
@@ -43,12 +43,16 @@
</goals> </goals>
<configuration> <configuration>
<createDependencyReducedPom>false</createDependencyReducedPom> <createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>${project.name}-${project.artifactId}-${project.parent.version}</finalName> <finalName>${project.name}-${project.parent.version}</finalName>
<relocations> <relocations>
<relocation> <relocation>
<pattern>org.bstats</pattern> <pattern>org.bstats</pattern>
<shadedPattern>eu.endermite.bstats</shadedPattern> <shadedPattern>eu.endermite.bstats</shadedPattern>
</relocation> </relocation>
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>eu.endermite</shadedPattern>
</relocation>
</relocations> </relocations>
</configuration> </configuration>
</execution> </execution>
@@ -68,10 +72,6 @@
<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>destroystokyo-repo</id>
<url>https://repo.destroystokyo.com/repository/maven-public/</url>
</repository>
<repository> <repository>
<id>papermc</id> <id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url> <url>https://papermc.io/repo/repository/maven-public/</url>
@@ -79,22 +79,23 @@
</repositories> </repositories>
<dependencies> <dependencies>
<dependency>
<groupId>io.github.waterfallmc</groupId>
<artifactId>waterfall-api</artifactId>
<version>1.16-R0.5-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>eu.endermite.commandwhitelist</groupId> <groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>Common</artifactId> <artifactId>Common</artifactId>
<version>${project.parent.version}</version> <version>${project.parent.version}</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>io.github.waterfallmc</groupId>
<artifactId>waterfall-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>net.kyori</groupId> <groupId>net.kyori</groupId>
<artifactId>adventure-platform-bungeecord</artifactId> <artifactId>adventure-platform-bungeecord</artifactId>
<version>4.0.0-SNAPSHOT</version> <version>4.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.bstats</groupId> <groupId>org.bstats</groupId>
@@ -2,12 +2,12 @@ package eu.endermite.commandwhitelist.waterfall;
import eu.endermite.commandwhitelist.common.CWGroup; import eu.endermite.commandwhitelist.common.CWGroup;
import eu.endermite.commandwhitelist.common.ConfigCache; import eu.endermite.commandwhitelist.common.ConfigCache;
import eu.endermite.commandwhitelist.common.commands.CWCommand;
import eu.endermite.commandwhitelist.waterfall.command.BungeeMainCommand; import eu.endermite.commandwhitelist.waterfall.command.BungeeMainCommand;
import eu.endermite.commandwhitelist.waterfall.listeners.BungeeChatEventListener; import eu.endermite.commandwhitelist.waterfall.listeners.BungeeChatEventListener;
import eu.endermite.commandwhitelist.waterfall.listeners.BungeeTabcompleteListener; import eu.endermite.commandwhitelist.waterfall.listeners.BungeeTabcompleteListener;
import eu.endermite.commandwhitelist.waterfall.listeners.WaterfallDefineCommandsListener; import eu.endermite.commandwhitelist.waterfall.listeners.WaterfallDefineCommandsListener;
import net.kyori.adventure.platform.bungeecord.BungeeAudiences; import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
@@ -29,26 +29,30 @@ public final class CommandWhitelistWaterfall extends Plugin {
@Override @Override
public void onEnable() { public void onEnable() {
plugin = this; plugin = this;
getLogger().info("Running on "+ ChatColor.DARK_AQUA+getProxy().getName()); getLogger().info("Running on " + ChatColor.DARK_AQUA + getProxy().getName());
loadConfig(); loadConfig();
audiences = BungeeAudiences.create(this); audiences = BungeeAudiences.create(this);
Metrics metrics = new Metrics(this, 8704);
this.getProxy().getPluginManager().registerListener(this, new BungeeChatEventListener()); this.getProxy().getPluginManager().registerListener(this, new BungeeChatEventListener());
try { try {
Class.forName("io.github.waterfallmc.waterfall.event.ProxyDefineCommandsEvent"); Class.forName("io.github.waterfallmc.waterfall.event.ProxyDefineCommandsEvent");
metrics.addCustomChart(new SimplePie("proxy", () -> "Waterfall"));
this.getProxy().getPluginManager().registerListener(this, new WaterfallDefineCommandsListener()); this.getProxy().getPluginManager().registerListener(this, new WaterfallDefineCommandsListener());
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
getLogger().severe(ChatColor.DARK_RED+"Bungee command completion blocker requires Waterfall other Waterfall fork."); metrics.addCustomChart(new SimplePie("proxy", () -> "Bungee"));
getLogger().severe("Bungee command completion blocker requires Waterfall other Waterfall fork.");
} }
this.getProxy().getPluginManager().registerListener(this, new BungeeTabcompleteListener()); this.getProxy().getPluginManager().registerListener(this, new BungeeTabcompleteListener());
getProxy().getPluginManager().registerCommand(this, new BungeeMainCommand("bcw")); getProxy().getPluginManager().registerCommand(this, new BungeeMainCommand("bcw"));
Metrics metrics = new Metrics(this, 8704);
metrics.addCustomChart(new SimplePie("proxy", () -> "Bungee/Waterfall"));
} }
public static CommandWhitelistWaterfall getPlugin() { public static CommandWhitelistWaterfall getPlugin() {
return plugin; return plugin;
} }
public static ConfigCache getConfigCache() { public static ConfigCache getConfigCache() {
return configCache; return configCache;
} }
@@ -67,7 +71,7 @@ public final class CommandWhitelistWaterfall extends Plugin {
public void loadConfigAsync(CommandSender sender) { public void loadConfigAsync(CommandSender sender) {
getProxy().getScheduler().runAsync(this, () -> { getProxy().getScheduler().runAsync(this, () -> {
loadConfig(); loadConfig();
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(CommandWhitelistWaterfall.getConfigCache().prefix + CommandWhitelistWaterfall.getConfigCache().config_reloaded)); audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(CommandWhitelistWaterfall.getConfigCache().prefix + CommandWhitelistWaterfall.getConfigCache().config_reloaded));
}); });
} }
@@ -102,4 +106,20 @@ public final class CommandWhitelistWaterfall extends Plugin {
} }
return suggestionList; return suggestionList;
} }
/**
* @return Command denied message. Will use custom if command exists in any group.
*/
public static String getCommandDeniedMessage(String command) {
String commandDeniedMessage = configCache.command_denied;
HashMap<String, CWGroup> groups = configCache.getGroupList();
for (CWGroup group : groups.values()) {
if (group.getCommands().contains(command)) {
if (group.getCommandDeniedMessage() == null || group.getCommandDeniedMessage().isEmpty()) continue;
commandDeniedMessage = group.getCommandDeniedMessage();
break; // get first message we find
}
}
return commandDeniedMessage;
}
} }
@@ -6,11 +6,14 @@ import eu.endermite.commandwhitelist.common.commands.CWCommand;
import eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall; import eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall;
import net.kyori.adventure.platform.bungeecord.BungeeAudiences; import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Command; import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.TabExecutor; import net.md_5.bungee.api.plugin.TabExecutor;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class BungeeMainCommand extends Command implements TabExecutor { public class BungeeMainCommand extends Command implements TabExecutor {
public BungeeMainCommand(String name) { public BungeeMainCommand(String name) {
@@ -33,36 +36,36 @@ public class BungeeMainCommand extends Command implements TabExecutor {
switch (commandType) { switch (commandType) {
case RELOAD: case RELOAD:
if (!sender.hasPermission(CWPermission.RELOAD.permission())) { if (!sender.hasPermission(CWPermission.RELOAD.permission())) {
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(CommandWhitelistWaterfall.getConfigCache().prefix + configCache.no_permission)); audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(CommandWhitelistWaterfall.getConfigCache().prefix + configCache.no_permission));
return; return;
} }
CommandWhitelistWaterfall.getPlugin().loadConfigAsync(sender); CommandWhitelistWaterfall.getPlugin().loadConfigAsync(sender);
return; return;
case ADD: case ADD:
if (!sender.hasPermission(CWPermission.ADMIN.permission())) { if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.no_permission)); audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.no_permission));
return; return;
} }
if (args.length == 3) { if (args.length == 3) {
if (CWCommand.addToWhitelist(configCache, args[2], args[1])) if (CWCommand.addToWhitelist(configCache, args[2], args[1]))
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.added_to_whitelist)); audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.added_to_whitelist));
else else
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.group_doesnt_exist)); audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.group_doesnt_exist));
} else } else
audiences.sender(sender).sendMessage(Component.text("/"+label+" add <group> <command>")); audiences.sender(sender).sendMessage(Component.text("/" + label + " add <group> <command>"));
return; return;
case REMOVE: case REMOVE:
if (!sender.hasPermission(CWPermission.ADMIN.permission())) { if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.no_permission)); audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.no_permission));
return; return;
} }
if (args.length == 3) { if (args.length == 3) {
if (CWCommand.removeFromWhitelist(configCache, args[2], args[1])) if (CWCommand.removeFromWhitelist(configCache, args[2], args[1]))
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.removed_from_whitelist)); audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.removed_from_whitelist));
else else
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.group_doesnt_exist)); audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.group_doesnt_exist));
} else } else
audiences.sender(sender).sendMessage(Component.text("/"+label+" remove <group> <command>")); audiences.sender(sender).sendMessage(Component.text("/" + label + " remove <group> <command>"));
return; return;
case HELP: case HELP:
default: default:
@@ -77,6 +80,10 @@ public class BungeeMainCommand extends Command implements TabExecutor {
@Override @Override
public Iterable<String> onTabComplete(CommandSender sender, String[] args) { public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
return null; List<String> serverCommands = new ArrayList<>();
for (Map.Entry<String, Command> command : CommandWhitelistWaterfall.getPlugin().getProxy().getPluginManager().getCommands()) {
serverCommands.add(command.getValue().getName());
}
return CWCommand.commandSuggestions(CommandWhitelistWaterfall.getConfigCache(), serverCommands, args, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission()));
} }
} }
@@ -3,9 +3,9 @@ package eu.endermite.commandwhitelist.waterfall.listeners;
import eu.endermite.commandwhitelist.common.CWPermission; 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.waterfall.CommandWhitelistWaterfall; import eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall;
import net.kyori.adventure.platform.bungeecord.BungeeAudiences; import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.md_5.bungee.api.connection.ProxiedPlayer; 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;
@@ -32,7 +32,7 @@ public class BungeeChatEventListener implements Listener {
HashSet<String> commands = CommandWhitelistWaterfall.getCommands(player); HashSet<String> commands = CommandWhitelistWaterfall.getCommands(player);
if (!commands.contains(label)) { if (!commands.contains(label)) {
event.setCancelled(true); event.setCancelled(true);
CommandWhitelistWaterfall.getAudiences().player(player).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.command_denied)); CommandWhitelistWaterfall.getAudiences().player(player).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + CommandWhitelistWaterfall.getCommandDeniedMessage(label)));
return; return;
} }
@@ -40,7 +40,7 @@ public class BungeeChatEventListener implements Listener {
for (String bannedSubCommand : bannedSubCommands) { for (String bannedSubCommand : bannedSubCommands) {
if (command.startsWith(bannedSubCommand)) { if (command.startsWith(bannedSubCommand)) {
event.setCancelled(true); event.setCancelled(true);
audiences.player(player).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.subcommand_denied)); audiences.player(player).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.subcommand_denied));
return; return;
} }
} }
+2 -2
View File
@@ -6,7 +6,7 @@
<groupId>eu.endermite.commandwhitelist</groupId> <groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId> <artifactId>CommandWhitelist</artifactId>
<version>2.0-ALPHA-2</version> <version>2.2.2</version>
<modules> <modules>
<module>CommandWhitelistCommon</module> <module>CommandWhitelistCommon</module>
<module>CommandWhitelistBukkit</module> <module>CommandWhitelistBukkit</module>
@@ -34,7 +34,7 @@
<dependency> <dependency>
<groupId>net.kyori</groupId> <groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId> <artifactId>adventure-api</artifactId>
<version>4.8.0</version> <version>4.9.2</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
+13 -7
View File
@@ -10,16 +10,22 @@ precisely what commands players can see and use.
![bStats Servers](https://img.shields.io/bstats/servers/8704?label=Proxy%20servers%20using%20CW&style=flat-square) ![bStats Servers](https://img.shields.io/bstats/servers/8704?label=Proxy%20servers%20using%20CW&style=flat-square)
<h3>Plugin Features</h3> <h3>Plugin Features</h3>
<ul> <ul>
<li>You can lock certain commands behind permission <li>Lock selected commands behind permission
<li>Overwrites default "no such command" message with your branding <li>Overwrite default "no such command" message with your branding
<li>Blocks tab completion on spigot and bungeecord*</li> <li>Block tab completion</li>
<li>Blocks command execution on spigot and bungeecord</li> <li>Block command execution</li>
<li>Blocks completion and execution of specific subcommands (spigot only)</li> <li>Block completion and execution of specified subcommands</li>
</ul> </ul>
\*This only works on Waterfall and its forks <b>Compatible versions</b>: 1.13+
<b>Compatible software</b>:
- Bukkit-based servers (Spigot, Paper, Airplane, Purpur, etc)
- Waterfall (NOT Bungeecord!)
- Velocity
[Download latest release](https://github.com/YouHaveTrouble/CommandWhitelist/releases/latest)
Having some issues? Make sure to check out <a href="https://github.com/YouHaveTrouble/CommandWhitelist/wiki">Plugin Wiki</a>. Having some issues? Make sure to check out <a href="https://github.com/YouHaveTrouble/CommandWhitelist/wiki">Plugin Wiki</a>.