mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-12 06:26:57 +00:00
Compare commits
74 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ede673f52 | |||
| de4124aa73 | |||
| cd3ee4b214 | |||
| ea54ae3175 | |||
| c36ac056d5 | |||
| 7186c4de6c | |||
| dfa254f263 | |||
| e80629d708 | |||
| f41bfa7cd1 | |||
| 5af0cdef84 | |||
| e232953f11 | |||
| e8b284db69 | |||
| ed1024c9e7 | |||
| 153ad5f983 | |||
| 9e5b5b5fc7 | |||
| 67ca2c2458 | |||
| 99f7c245da | |||
| cd4c41f1f2 | |||
| 8a86568ce9 | |||
| b08234d268 | |||
| 2c7a089fae | |||
| 41ff6d9d3e | |||
| 9e13c7b2f1 | |||
| 0716514787 | |||
| 428ee93996 | |||
| 8b45057544 | |||
| 29f7b6438e | |||
| 8de56d2863 | |||
| d8421126e2 | |||
| 0554ef59f7 | |||
| 0567640eea | |||
| fd5bccc985 | |||
| cacc09365b | |||
| ebc8a823f2 | |||
| 3697bc72ce | |||
| 78b1a646f2 | |||
| b0a6fb2144 | |||
| 2fafc31a10 | |||
| bbb2ffb2c9 | |||
| 1a309ffcd3 | |||
| 9f1beac562 | |||
| 5dc67e0122 | |||
| 7538db2a7f | |||
| 568e7a5ca4 | |||
| 7cb94cce4b | |||
| 7f6315b6b5 | |||
| bbc0e44660 | |||
| 9e255076b0 | |||
| a91af744fd | |||
| 930f73d60a | |||
| c5fdaa95f8 | |||
| 87fc3d7da3 | |||
| 0cc2633604 | |||
| d6909b4f25 | |||
| cd3d527119 | |||
| d43bde0750 | |||
| 48fbd59a50 | |||
| 7c3a06e704 | |||
| 5d7cd9d41f | |||
| f101b68ed8 | |||
| 707bcbbf8b | |||
| fec7e3ba07 | |||
| 7139baf2d9 | |||
| f1d10243ce | |||
| 1647605682 | |||
| aff390369f | |||
| c586a8af05 | |||
| 26a408812d | |||
| 727d6c3227 | |||
| 7e6b793ede | |||
| fd893b931d | |||
| 5bcf5bb130 | |||
| 7c33718190 | |||
| ad599092de |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
# These are supported funding model platforms
|
# These are supported funding model platforms
|
||||||
|
|
||||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
github: YouHaveTrouble
|
||||||
patreon: # Replace with a single Patreon username
|
patreon: # Replace with a single Patreon username
|
||||||
open_collective: # Replace with a single Open Collective username
|
open_collective: # Replace with a single Open Collective username
|
||||||
ko_fi: YouHaveTrouble
|
ko_fi: YouHaveTrouble
|
||||||
|
|||||||
@@ -1,113 +0,0 @@
|
|||||||
# User-specific stuff
|
|
||||||
.idea/
|
|
||||||
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
*.iws
|
|
||||||
|
|
||||||
# IntelliJ
|
|
||||||
out/
|
|
||||||
|
|
||||||
# Compiled class file
|
|
||||||
*.class
|
|
||||||
|
|
||||||
# Log file
|
|
||||||
*.log
|
|
||||||
|
|
||||||
# BlueJ files
|
|
||||||
*.ctxt
|
|
||||||
|
|
||||||
# Package Files #
|
|
||||||
*.jar
|
|
||||||
*.war
|
|
||||||
*.nar
|
|
||||||
*.ear
|
|
||||||
*.zip
|
|
||||||
*.tar.gz
|
|
||||||
*.rar
|
|
||||||
|
|
||||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
|
||||||
hs_err_pid*
|
|
||||||
|
|
||||||
*~
|
|
||||||
|
|
||||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
|
||||||
.fuse_hidden*
|
|
||||||
|
|
||||||
# KDE directory preferences
|
|
||||||
.directory
|
|
||||||
|
|
||||||
# Linux trash folder which might appear on any partition or disk
|
|
||||||
.Trash-*
|
|
||||||
|
|
||||||
# .nfs files are created when an open file is removed but is still being accessed
|
|
||||||
.nfs*
|
|
||||||
|
|
||||||
# General
|
|
||||||
.DS_Store
|
|
||||||
.AppleDouble
|
|
||||||
.LSOverride
|
|
||||||
|
|
||||||
# Icon must end with two \r
|
|
||||||
Icon
|
|
||||||
|
|
||||||
# Thumbnails
|
|
||||||
._*
|
|
||||||
|
|
||||||
# Files that might appear in the root of a volume
|
|
||||||
.DocumentRevisions-V100
|
|
||||||
.fseventsd
|
|
||||||
.Spotlight-V100
|
|
||||||
.TemporaryItems
|
|
||||||
.Trashes
|
|
||||||
.VolumeIcon.icns
|
|
||||||
.com.apple.timemachine.donotpresent
|
|
||||||
|
|
||||||
# Directories potentially created on remote AFP share
|
|
||||||
.AppleDB
|
|
||||||
.AppleDesktop
|
|
||||||
Network Trash Folder
|
|
||||||
Temporary Items
|
|
||||||
.apdisk
|
|
||||||
|
|
||||||
# Windows thumbnail cache files
|
|
||||||
Thumbs.db
|
|
||||||
Thumbs.db:encryptable
|
|
||||||
ehthumbs.db
|
|
||||||
ehthumbs_vista.db
|
|
||||||
|
|
||||||
# Dump file
|
|
||||||
*.stackdump
|
|
||||||
|
|
||||||
# Folder config file
|
|
||||||
[Dd]esktop.ini
|
|
||||||
|
|
||||||
# Recycle Bin used on file shares
|
|
||||||
$RECYCLE.BIN/
|
|
||||||
|
|
||||||
# Windows Installer files
|
|
||||||
*.cab
|
|
||||||
*.msi
|
|
||||||
*.msix
|
|
||||||
*.msm
|
|
||||||
*.msp
|
|
||||||
|
|
||||||
# Windows shortcuts
|
|
||||||
*.lnk
|
|
||||||
|
|
||||||
target/
|
|
||||||
|
|
||||||
pom.xml.tag
|
|
||||||
pom.xml.releaseBackup
|
|
||||||
pom.xml.versionsBackup
|
|
||||||
pom.xml.next
|
|
||||||
|
|
||||||
release.properties
|
|
||||||
dependency-reduced-pom.xml
|
|
||||||
buildNumber.properties
|
|
||||||
.mvn/timing.properties
|
|
||||||
.mvn/wrapper/maven-wrapper.jar
|
|
||||||
.flattened-pom.xml
|
|
||||||
|
|
||||||
# Common working directory
|
|
||||||
run/
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>Bukkit</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
<name>CommandWhitelist</name>
|
|
||||||
|
|
||||||
<description>You decide what commands players can use or tab complete on your server!</description>
|
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
<url>youhavetrouble.me</url>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.8.1</version>
|
|
||||||
<configuration>
|
|
||||||
<source>${java.version}</source>
|
|
||||||
<target>${java.version}</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>3.2.4</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<finalName>${project.name}-${project.artifactId}-${project.parent.version}</finalName>
|
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
|
||||||
<relocations>
|
|
||||||
<relocation>
|
|
||||||
<pattern>org.bstats</pattern>
|
|
||||||
<shadedPattern>eu.endermite.bstats</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
</relocations>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>sonatype</id>
|
|
||||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>dmulloy2-repo</id>
|
|
||||||
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.destroystokyo.paper</groupId>
|
|
||||||
<artifactId>paper-api</artifactId>
|
|
||||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.kyori</groupId>
|
|
||||||
<artifactId>adventure-platform-bukkit</artifactId>
|
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
|
||||||
<artifactId>Common</artifactId>
|
|
||||||
<version>${project.parent.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.comphenix.protocol</groupId>
|
|
||||||
<artifactId>ProtocolLib</artifactId>
|
|
||||||
<version>4.6.0</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bstats</groupId>
|
|
||||||
<artifactId>bstats-bukkit</artifactId>
|
|
||||||
<version>2.2.1</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
-126
@@ -1,126 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.bukkit;
|
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.bukkit.command.MainCommandExecutor;
|
|
||||||
import eu.endermite.commandwhitelist.bukkit.listeners.*;
|
|
||||||
import eu.endermite.commandwhitelist.common.CWGroup;
|
|
||||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bstats.bukkit.Metrics;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.PluginCommand;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class CommandWhitelistBukkit extends JavaPlugin {
|
|
||||||
|
|
||||||
private static CommandWhitelistBukkit commandWhitelist;
|
|
||||||
private static ConfigCache configCache;
|
|
||||||
private static BukkitAudiences audiences;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
|
||||||
|
|
||||||
commandWhitelist = this;
|
|
||||||
audiences = BukkitAudiences.create(this);
|
|
||||||
|
|
||||||
reloadPluginConfig();
|
|
||||||
|
|
||||||
Plugin protocollib = getServer().getPluginManager().getPlugin("ProtocolLib");
|
|
||||||
|
|
||||||
if (!getConfigCache().useProtocolLib || protocollib == null || !protocollib.isEnabled()) {
|
|
||||||
getServer().getPluginManager().registerEvents(new PlayerCommandPreProcessListener(), this);
|
|
||||||
getServer().getPluginManager().registerEvents(new PlayerCommandSendListener(), this);
|
|
||||||
} else {
|
|
||||||
PacketCommandPreProcessListener.protocol(this);
|
|
||||||
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 e) {
|
|
||||||
getServer().getPluginManager().registerEvents(new TabCompleteBlockerListener(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
PluginCommand command = getCommand("commandwhitelist");
|
|
||||||
if (command != null) {
|
|
||||||
MainCommandExecutor executor = new MainCommandExecutor();
|
|
||||||
command.setExecutor(executor);
|
|
||||||
command.setTabCompleter(executor);
|
|
||||||
}
|
|
||||||
|
|
||||||
new Metrics(this, 8705);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reloadPluginConfig() {
|
|
||||||
File configFile = new File("plugins/CommandWhitelist/config.yml");
|
|
||||||
if (configCache == null)
|
|
||||||
configCache = new ConfigCache(configFile, true, getSLF4JLogger());
|
|
||||||
else
|
|
||||||
configCache.reloadConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reloadPluginConfig(CommandSender sender) {
|
|
||||||
getServer().getScheduler().runTaskAsynchronously(this, () -> {
|
|
||||||
reloadPluginConfig();
|
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
|
||||||
p.updateCommands();
|
|
||||||
}
|
|
||||||
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.config_reloaded));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CommandWhitelistBukkit getPlugin() {
|
|
||||||
return commandWhitelist;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ConfigCache getConfigCache() {
|
|
||||||
return configCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BukkitAudiences getAudiences() {
|
|
||||||
return audiences;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param player Bukkit Player
|
|
||||||
* @return commands available to the player
|
|
||||||
*/
|
|
||||||
public static HashSet<String> getCommands(org.bukkit.entity.Player player) {
|
|
||||||
HashSet<String> commandList = new HashSet<>();
|
|
||||||
HashMap<String, CWGroup> groups = configCache.getGroupList();
|
|
||||||
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
|
|
||||||
if (s.getKey().equalsIgnoreCase("default"))
|
|
||||||
commandList.addAll(s.getValue().getCommands());
|
|
||||||
else if (player.hasPermission(s.getValue().getPermission()))
|
|
||||||
commandList.addAll(s.getValue().getCommands());
|
|
||||||
}
|
|
||||||
return commandList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param player Bukkit Player
|
|
||||||
* @return subcommands unavailable for the player
|
|
||||||
*/
|
|
||||||
public static HashSet<String> getSuggestions(org.bukkit.entity.Player player) {
|
|
||||||
HashSet<String> suggestionList = new HashSet<>();
|
|
||||||
HashMap<String, CWGroup> groups = configCache.getGroupList();
|
|
||||||
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
|
|
||||||
if (s.getKey().equalsIgnoreCase("default"))
|
|
||||||
suggestionList.addAll(s.getValue().getSubCommands());
|
|
||||||
if (player.hasPermission(s.getValue().getPermission())) continue;
|
|
||||||
suggestionList.addAll(s.getValue().getSubCommands());
|
|
||||||
}
|
|
||||||
return suggestionList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-83
@@ -1,83 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.bukkit.command;
|
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
|
|
||||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
|
||||||
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabExecutor;
|
|
||||||
import org.bukkit.help.HelpTopic;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MainCommandExecutor implements TabExecutor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
|
|
||||||
BukkitAudiences audiences = CommandWhitelistBukkit.getAudiences();
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
|
||||||
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
CWCommand.CommandType commandType = CWCommand.CommandType.valueOf(args[0].toUpperCase());
|
|
||||||
switch (commandType) {
|
|
||||||
case RELOAD:
|
|
||||||
if (!sender.hasPermission(CWPermission.RELOAD.permission())) {
|
|
||||||
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
CommandWhitelistBukkit.getPlugin().reloadPluginConfig(sender);
|
|
||||||
return true;
|
|
||||||
case ADD:
|
|
||||||
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
|
||||||
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 3) {
|
|
||||||
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])));
|
|
||||||
else
|
|
||||||
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().group_doesnt_exist, args[1])));
|
|
||||||
} else
|
|
||||||
audiences.sender(sender).sendMessage(Component.text("/" + label + " add <group> <command>"));
|
|
||||||
return true;
|
|
||||||
case REMOVE:
|
|
||||||
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
|
||||||
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 3) {
|
|
||||||
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])));
|
|
||||||
else
|
|
||||||
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().group_doesnt_exist, args[1])));
|
|
||||||
} else
|
|
||||||
audiences.sender(sender).sendMessage(Component.text("/" + label + " remove <group> <command>"));
|
|
||||||
return true;
|
|
||||||
case HELP:
|
|
||||||
default:
|
|
||||||
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
|
||||||
}
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
|
||||||
List<String> serverCommands = new ArrayList<>();
|
|
||||||
for (HelpTopic topic : Bukkit.getHelpMap().getHelpTopics()) {
|
|
||||||
serverCommands.add(topic.getName());
|
|
||||||
}
|
|
||||||
return CWCommand.commandSuggestions(CommandWhitelistBukkit.getConfigCache(), serverCommands, args, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-29
@@ -1,29 +0,0 @@
|
|||||||
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.NORMAL)
|
|
||||||
public void onCommandTabComplete(AsyncTabCompleteEvent event) {
|
|
||||||
if (!(event.getSender() instanceof Player)) return;
|
|
||||||
Player player = (Player) event.getSender();
|
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
|
||||||
event.setCompletions(
|
|
||||||
CommandUtil.filterSuggestions(
|
|
||||||
event.getBuffer(),
|
|
||||||
event.getCompletions(),
|
|
||||||
CommandWhitelistBukkit.getSuggestions(player)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
event.setHandled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-57
@@ -1,57 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.bukkit.listeners;
|
|
||||||
|
|
||||||
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 eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
|
|
||||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
|
||||||
import eu.endermite.commandwhitelist.common.CommandUtil;
|
|
||||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
public class PacketCommandPreProcessListener {
|
|
||||||
|
|
||||||
public static void protocol(CommandWhitelistBukkit plugin) {
|
|
||||||
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
|
||||||
commandExecListener(protocolManager, plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void commandExecListener(ProtocolManager protocolManager, Plugin plugin) {
|
|
||||||
protocolManager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CHAT) {
|
|
||||||
@Override
|
|
||||||
public void onPacketReceiving(PacketEvent event) {
|
|
||||||
PacketContainer packet = event.getPacket();
|
|
||||||
String string = packet.getStrings().read(0);
|
|
||||||
if (!string.startsWith("/")) return;
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
|
||||||
|
|
||||||
ConfigCache config = CommandWhitelistBukkit.getConfigCache();
|
|
||||||
String label = CommandUtil.getCommandLabel(string.toLowerCase());
|
|
||||||
HashSet<String> commands = CommandWhitelistBukkit.getCommands(player);
|
|
||||||
if (!commands.contains(label)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
CommandWhitelistBukkit.getAudiences().player(player).sendMessage(MiniMessage.markdown().parse(config.prefix + config.command_denied));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HashSet<String> bannedSubCommands = CommandWhitelistBukkit.getSuggestions(player);
|
|
||||||
for (String bannedSubCommand : bannedSubCommands) {
|
|
||||||
if (string.toLowerCase().substring(1).startsWith(bannedSubCommand)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
CommandWhitelistBukkit.getAudiences().player(player).sendMessage(MiniMessage.markdown().parse(config.prefix + config.subcommand_denied));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-42
@@ -1,42 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.bukkit.listeners;
|
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
|
|
||||||
import eu.endermite.commandwhitelist.common.CommandUtil;
|
|
||||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
public class PlayerCommandPreProcessListener implements Listener {
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
|
||||||
public void PlayerCommandSendEvent(org.bukkit.event.player.PlayerCommandPreprocessEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (player.hasPermission("commandwhitelist.bypass")) return;
|
|
||||||
String label = CommandUtil.getCommandLabel(event.getMessage().toLowerCase());
|
|
||||||
BukkitAudiences audiences = CommandWhitelistBukkit.getAudiences();
|
|
||||||
ConfigCache config = CommandWhitelistBukkit.getConfigCache();
|
|
||||||
|
|
||||||
HashSet<String> commands = CommandWhitelistBukkit.getCommands(player);
|
|
||||||
if (!commands.contains(label)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
audiences.player(player).sendMessage(MiniMessage.markdown().parse(config.prefix + config.command_denied));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HashSet<String> bannedSubCommands = CommandWhitelistBukkit.getSuggestions(player);
|
|
||||||
for (String bannedSubCommand : bannedSubCommands) {
|
|
||||||
if (event.getMessage().toLowerCase().substring(1).startsWith(bannedSubCommand)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
audiences.player(player).sendMessage(MiniMessage.markdown().parse(config.prefix + config.subcommand_denied));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.bukkit.listeners;
|
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
|
|
||||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
public class PlayerCommandSendListener implements Listener {
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
|
||||||
public void PlayerCommandSendEvent(org.bukkit.event.player.PlayerCommandSendEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
|
||||||
HashSet<String> commandList = CommandWhitelistBukkit.getCommands(player);
|
|
||||||
event.getCommands().removeIf((cmd) -> !commandList.contains(cmd));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.bukkit.listeners;
|
|
||||||
|
|
||||||
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 TabCompleteBlockerListener implements Listener {
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
|
||||||
public void onCommandTabComplete(org.bukkit.event.server.TabCompleteEvent event) {
|
|
||||||
if (!(event.getSender() instanceof Player)) return;
|
|
||||||
Player player = (Player) event.getSender();
|
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
|
||||||
event.setCompletions(
|
|
||||||
CommandUtil.filterSuggestions(
|
|
||||||
event.getBuffer(),
|
|
||||||
event.getCompletions(),
|
|
||||||
CommandWhitelistBukkit.getSuggestions(player)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>Common</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
<name>CommandWhitelist</name>
|
|
||||||
|
|
||||||
<description>You decide what commands players can use or tab complete on your server!</description>
|
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
<url>youhavetrouble.me</url>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.8.1</version>
|
|
||||||
<configuration>
|
|
||||||
<source>${java.version}</source>
|
|
||||||
<target>${java.version}</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>3.2.4</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
|
||||||
<finalName>${project.name}-${project.artifactId}-${project.parent.version}</finalName>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>pluginwiki-repo</id>
|
|
||||||
<url>https://ci.pluginwiki.us/plugin/repository/everything/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>velocitypowered-repo</id>
|
|
||||||
<url>https://repo.velocitypowered.com/releases/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.thatsmusic99</groupId>
|
|
||||||
<artifactId>ConfigurationMaster-API</artifactId>
|
|
||||||
<version>v2.0.0-BETA-1</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.velocitypowered</groupId>
|
|
||||||
<artifactId>velocity-api</artifactId>
|
|
||||||
<version>1.1.0</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.destroystokyo.paper</groupId>
|
|
||||||
<artifactId>paper-api</artifactId>
|
|
||||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.github.waterfallmc</groupId>
|
|
||||||
<artifactId>waterfall-api</artifactId>
|
|
||||||
<version>1.17-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
-58
@@ -1,58 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.common;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class CWGroup {
|
|
||||||
|
|
||||||
private final String id, permission;
|
|
||||||
private final HashSet<String> commands = new HashSet<>();
|
|
||||||
private final HashSet<String> subCommands = new HashSet<>();
|
|
||||||
|
|
||||||
public CWGroup(String id, Collection<String> commands, Collection<String> subCommands) {
|
|
||||||
this.id = id;
|
|
||||||
this.permission = "commandwhitelist.group."+id;
|
|
||||||
this.commands.addAll(commands);
|
|
||||||
this.subCommands.addAll(subCommands);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPermission() {
|
|
||||||
return permission;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashSet<String> getCommands() {
|
|
||||||
return commands;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addCommand(String command) {
|
|
||||||
commands.add(command);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeCommand(String command) {
|
|
||||||
commands.remove(command);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashSet<String> getSubCommands() {
|
|
||||||
return subCommands;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addSubCommand(String subCommand) {
|
|
||||||
subCommands.add(subCommand);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeSubCommand(String subCommand) {
|
|
||||||
subCommands.remove(subCommand);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<String, Object> serialize() {
|
|
||||||
HashMap<String, Object> serializedGroup = new LinkedHashMap<>();
|
|
||||||
List<String> commands = new ArrayList<>(this.commands);
|
|
||||||
List<String> subCommands = new ArrayList<>(this.subCommands);
|
|
||||||
serializedGroup.put("commands", commands);
|
|
||||||
serializedGroup.put("subcommands", subCommands);
|
|
||||||
return serializedGroup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-108
@@ -1,108 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.common.commands;
|
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.common.CWGroup;
|
|
||||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CWCommand {
|
|
||||||
|
|
||||||
public static boolean addToWhitelist(ConfigCache configCache, String command, String group) {
|
|
||||||
CWGroup cwGroup = configCache.getGroupList().get(group);
|
|
||||||
if (cwGroup == null) return false;
|
|
||||||
cwGroup.addCommand(command);
|
|
||||||
configCache.saveCWGroup(group, cwGroup);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean removeFromWhitelist(ConfigCache configCache, String command, String group) {
|
|
||||||
CWGroup cwGroup = configCache.getGroupList().get(group);
|
|
||||||
if (cwGroup == null)
|
|
||||||
return false;
|
|
||||||
cwGroup.removeCommand(command);
|
|
||||||
configCache.saveCWGroup(group, cwGroup);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Component helpComponent(String baseCommand, boolean showReloadCommand, boolean showAdminCommands) {
|
|
||||||
Component component = MiniMessage.markdown().parse("<rainbow><bold>CommandWhitelist by YouHaveTrouble")
|
|
||||||
.append(Component.newline());
|
|
||||||
component = component.append(Component.text("/" + baseCommand + " help").color(NamedTextColor.AQUA).append(Component.text(" - Displays this message").color(NamedTextColor.BLUE)));
|
|
||||||
if (showReloadCommand) {
|
|
||||||
component = component.append(Component.newline());
|
|
||||||
component = component.append(Component.text("/" + baseCommand + " reload").color(NamedTextColor.AQUA).append(Component.text(" - Reloads plugin configuration").color(NamedTextColor.BLUE)));
|
|
||||||
}
|
|
||||||
if (showAdminCommands) {
|
|
||||||
component = component.append(Component.newline());
|
|
||||||
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.text("/" + baseCommand + " remove <group> <command>").color(NamedTextColor.AQUA).append(Component.text(" - Removes a command from selected permission group").color(NamedTextColor.BLUE)));
|
|
||||||
}
|
|
||||||
return component;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum CommandType {
|
|
||||||
ADD, REMOVE, HELP, RELOAD
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> commandSuggestions(ConfigCache config, Collection<String> serverCommands, String[] args, boolean reloadPerm, boolean adminPerm) {
|
|
||||||
List<String> list = new ArrayList<>();
|
|
||||||
switch (args.length) {
|
|
||||||
default:
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
if ("reload".startsWith(args[0]) && reloadPerm)
|
|
||||||
list.add("reload");
|
|
||||||
if ("add".startsWith(args[0]) && adminPerm)
|
|
||||||
list.add("add");
|
|
||||||
if ("remove".startsWith(args[0]) && adminPerm)
|
|
||||||
list.add("remove");
|
|
||||||
return list;
|
|
||||||
case 2:
|
|
||||||
if (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove")) {
|
|
||||||
if (!adminPerm) return list;
|
|
||||||
for (String s : config.getGroupList().keySet()) {
|
|
||||||
if (s.startsWith(args[1]))
|
|
||||||
list.add(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
case 3:
|
|
||||||
if (args[0].equalsIgnoreCase("remove")) {
|
|
||||||
if (!adminPerm) return list;
|
|
||||||
CWGroup group = config.getGroupList().get(args[1]);
|
|
||||||
if (group == null) return list;
|
|
||||||
for (String s : group.getCommands()) {
|
|
||||||
if (s.startsWith(args[2]))
|
|
||||||
list.add(s);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
if (args[0].equalsIgnoreCase("add")) {
|
|
||||||
if (!adminPerm) return list;
|
|
||||||
CWGroup group = config.getGroupList().get(args[1]);
|
|
||||||
if (group == null) return list;
|
|
||||||
for (String cmd : serverCommands) {
|
|
||||||
if (cmd.startsWith("/"))
|
|
||||||
cmd = cmd.substring(1);
|
|
||||||
if (cmd.contains(":")) {
|
|
||||||
String[] cmdSplit = cmd.split(":");
|
|
||||||
if (cmdSplit.length < 2) continue;
|
|
||||||
cmd = cmdSplit[1];
|
|
||||||
}
|
|
||||||
if (group.getCommands().contains(cmd)) continue;
|
|
||||||
if (cmd.startsWith(args[2]))
|
|
||||||
list.add(cmd);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
# User-specific stuff
|
|
||||||
.idea/
|
|
||||||
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
*.iws
|
|
||||||
|
|
||||||
# IntelliJ
|
|
||||||
out/
|
|
||||||
|
|
||||||
# Compiled class file
|
|
||||||
*.class
|
|
||||||
|
|
||||||
# Log file
|
|
||||||
*.log
|
|
||||||
|
|
||||||
# BlueJ files
|
|
||||||
*.ctxt
|
|
||||||
|
|
||||||
# Package Files #
|
|
||||||
*.jar
|
|
||||||
*.war
|
|
||||||
*.nar
|
|
||||||
*.ear
|
|
||||||
*.zip
|
|
||||||
*.tar.gz
|
|
||||||
*.rar
|
|
||||||
|
|
||||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
|
||||||
hs_err_pid*
|
|
||||||
|
|
||||||
*~
|
|
||||||
|
|
||||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
|
||||||
.fuse_hidden*
|
|
||||||
|
|
||||||
# KDE directory preferences
|
|
||||||
.directory
|
|
||||||
|
|
||||||
# Linux trash folder which might appear on any partition or disk
|
|
||||||
.Trash-*
|
|
||||||
|
|
||||||
# .nfs files are created when an open file is removed but is still being accessed
|
|
||||||
.nfs*
|
|
||||||
|
|
||||||
# General
|
|
||||||
.DS_Store
|
|
||||||
.AppleDouble
|
|
||||||
.LSOverride
|
|
||||||
|
|
||||||
# Icon must end with two \r
|
|
||||||
Icon
|
|
||||||
|
|
||||||
# Thumbnails
|
|
||||||
._*
|
|
||||||
|
|
||||||
# Files that might appear in the root of a volume
|
|
||||||
.DocumentRevisions-V100
|
|
||||||
.fseventsd
|
|
||||||
.Spotlight-V100
|
|
||||||
.TemporaryItems
|
|
||||||
.Trashes
|
|
||||||
.VolumeIcon.icns
|
|
||||||
.com.apple.timemachine.donotpresent
|
|
||||||
|
|
||||||
# Directories potentially created on remote AFP share
|
|
||||||
.AppleDB
|
|
||||||
.AppleDesktop
|
|
||||||
Network Trash Folder
|
|
||||||
Temporary Items
|
|
||||||
.apdisk
|
|
||||||
|
|
||||||
# Windows thumbnail cache files
|
|
||||||
Thumbs.db
|
|
||||||
Thumbs.db:encryptable
|
|
||||||
ehthumbs.db
|
|
||||||
ehthumbs_vista.db
|
|
||||||
|
|
||||||
# Dump file
|
|
||||||
*.stackdump
|
|
||||||
|
|
||||||
# Folder config file
|
|
||||||
[Dd]esktop.ini
|
|
||||||
|
|
||||||
# Recycle Bin used on file shares
|
|
||||||
$RECYCLE.BIN/
|
|
||||||
|
|
||||||
# Windows Installer files
|
|
||||||
*.cab
|
|
||||||
*.msi
|
|
||||||
*.msix
|
|
||||||
*.msm
|
|
||||||
*.msp
|
|
||||||
|
|
||||||
# Windows shortcuts
|
|
||||||
*.lnk
|
|
||||||
|
|
||||||
target/
|
|
||||||
|
|
||||||
pom.xml.tag
|
|
||||||
pom.xml.releaseBackup
|
|
||||||
pom.xml.versionsBackup
|
|
||||||
pom.xml.next
|
|
||||||
|
|
||||||
release.properties
|
|
||||||
dependency-reduced-pom.xml
|
|
||||||
buildNumber.properties
|
|
||||||
.mvn/timing.properties
|
|
||||||
.mvn/wrapper/maven-wrapper.jar
|
|
||||||
.flattened-pom.xml
|
|
||||||
|
|
||||||
# Common working directory
|
|
||||||
run/
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>Velocity</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
<name>CommandWhitelist</name>
|
|
||||||
|
|
||||||
<description>You decide what commands players can use or tab complete on your server!</description>
|
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
<url>youhavetrouble.me</url>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.8.1</version>
|
|
||||||
<configuration>
|
|
||||||
<source>${java.version}</source>
|
|
||||||
<target>${java.version}</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>3.2.4</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
|
||||||
<finalName>${project.name}-${project.artifactId}-${project.parent.version}</finalName>
|
|
||||||
<relocations>
|
|
||||||
<relocation>
|
|
||||||
<pattern>org.bstats</pattern>
|
|
||||||
<shadedPattern>eu.endermite.bstats</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
</relocations>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>velocitypowered-repo</id>
|
|
||||||
<url>https://repo.velocitypowered.com/releases/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>minecraft-libraries</id>
|
|
||||||
<url>https://libraries.minecraft.net/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>spongepowered-repo</id>
|
|
||||||
<url>https://repo.spongepowered.org/maven</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.velocitypowered</groupId>
|
|
||||||
<artifactId>velocity-api</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
|
||||||
<artifactId>Common</artifactId>
|
|
||||||
<version>${project.parent.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bstats</groupId>
|
|
||||||
<artifactId>bstats-velocity</artifactId>
|
|
||||||
<version>2.2.1</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
-132
@@ -1,132 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.velocity;
|
|
||||||
|
|
||||||
import com.velocitypowered.api.command.CommandMeta;
|
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
|
||||||
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
|
||||||
import com.velocitypowered.api.event.command.PlayerAvailableCommandsEvent;
|
|
||||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
|
||||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
|
||||||
import eu.endermite.commandwhitelist.common.CWGroup;
|
|
||||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
|
||||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
|
||||||
import eu.endermite.commandwhitelist.velocity.command.VelocityMainCommand;
|
|
||||||
import net.kyori.adventure.identity.Identity;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bstats.charts.SimplePie;
|
|
||||||
import org.bstats.velocity.Metrics;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class CommandWhitelistVelocity {
|
|
||||||
|
|
||||||
private static CommandWhitelistVelocity plugin;
|
|
||||||
private static ProxyServer server;
|
|
||||||
private static ConfigCache configCache;
|
|
||||||
private static Path folder;
|
|
||||||
private static Logger logger;
|
|
||||||
private final Metrics.Factory metricsFactory;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public CommandWhitelistVelocity(ProxyServer server, Logger logger, @DataDirectory final Path folder, Metrics.Factory metricsFactory) {
|
|
||||||
CommandWhitelistVelocity.server = server;
|
|
||||||
CommandWhitelistVelocity.folder = folder;
|
|
||||||
CommandWhitelistVelocity.plugin = this;
|
|
||||||
CommandWhitelistVelocity.logger = logger;
|
|
||||||
this.metricsFactory = metricsFactory;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void reloadConfig() {
|
|
||||||
if (configCache == null)
|
|
||||||
configCache = new ConfigCache(new File(String.valueOf(folder), "config.yml"), false, logger);
|
|
||||||
else
|
|
||||||
configCache.reloadConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void reloadConfig(CommandSource source) {
|
|
||||||
server.getScheduler().buildTask(plugin, () -> {
|
|
||||||
reloadConfig();
|
|
||||||
source.sendMessage(Identity.nil(), MiniMessage.markdown().parse(getConfigCache().prefix+getConfigCache().config_reloaded));
|
|
||||||
}).schedule();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
|
||||||
reloadConfig();
|
|
||||||
CommandMeta commandMeta = server.getCommandManager().metaBuilder("vcw").build();
|
|
||||||
server.getCommandManager().register(commandMeta, new VelocityMainCommand());
|
|
||||||
Metrics metrics = metricsFactory.make(this, 8704);
|
|
||||||
metrics.addCustomChart(new SimplePie("proxy", ()-> "Velocity"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onUserCommandSendEvent(PlayerAvailableCommandsEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
|
||||||
HashSet<String> allowedCommands = CommandWhitelistVelocity.getCommands(player);
|
|
||||||
event.getRootNode().getChildren().removeIf((commandNode) ->
|
|
||||||
server.getCommandManager().hasCommand(commandNode.getName())
|
|
||||||
&& !allowedCommands.contains(commandNode.getName())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onUserCommandExecuteEvent(com.velocitypowered.api.event.command.CommandExecuteEvent event) {
|
|
||||||
if (!(event.getCommandSource() instanceof Player)) return;
|
|
||||||
Player player = (Player) event.getCommandSource();
|
|
||||||
|
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
|
||||||
|
|
||||||
HashSet<String> allowedCommands = CommandWhitelistVelocity.getCommands(player);
|
|
||||||
String command = event.getCommand().split(" ")[0];
|
|
||||||
if (server.getCommandManager().hasCommand(command)
|
|
||||||
&& !allowedCommands.contains(command))
|
|
||||||
event.setResult(CommandExecuteEvent.CommandResult.forwardToServer());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ConfigCache getConfigCache() {
|
|
||||||
return configCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param player Velocity Player
|
|
||||||
* @return commands available to the player
|
|
||||||
*/
|
|
||||||
public static HashSet<String> getCommands(Player player) {
|
|
||||||
HashMap<String, CWGroup> groups = configCache.getGroupList();
|
|
||||||
HashSet<String> commandList = new HashSet<>();
|
|
||||||
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
|
|
||||||
CWGroup group = s.getValue();
|
|
||||||
if (s.getKey().equalsIgnoreCase("default"))
|
|
||||||
commandList.addAll(group.getCommands());
|
|
||||||
else if (player.hasPermission(group.getPermission()))
|
|
||||||
commandList.addAll(group.getCommands());
|
|
||||||
}
|
|
||||||
return commandList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param player Velocity Player
|
|
||||||
* @return subcommands unavailable for the player
|
|
||||||
*/
|
|
||||||
public static HashSet<String> getSuggestions(Player player, HashMap<String, CWGroup> groups) {
|
|
||||||
HashSet<String> suggestionList = new HashSet<>();
|
|
||||||
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
|
|
||||||
if (s.getKey().equalsIgnoreCase("default"))
|
|
||||||
suggestionList.addAll(s.getValue().getSubCommands());
|
|
||||||
if (player.hasPermission(s.getValue().getPermission())) continue;
|
|
||||||
suggestionList.addAll(s.getValue().getSubCommands());
|
|
||||||
}
|
|
||||||
return suggestionList;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-84
@@ -1,84 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.velocity.command;
|
|
||||||
|
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
|
||||||
import com.velocitypowered.api.command.SimpleCommand;
|
|
||||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
|
||||||
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
|
||||||
import eu.endermite.commandwhitelist.velocity.CommandWhitelistVelocity;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
public class VelocityMainCommand implements SimpleCommand {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(final Invocation invocation) {
|
|
||||||
CommandSource sender = invocation.source();
|
|
||||||
String[] args = invocation.arguments();
|
|
||||||
String label = invocation.alias();
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
|
||||||
sender.sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
CWCommand.CommandType commandType = CWCommand.CommandType.valueOf(args[0].toUpperCase());
|
|
||||||
switch (commandType) {
|
|
||||||
case RELOAD:
|
|
||||||
if (!sender.hasPermission(CWPermission.RELOAD.permission())) {
|
|
||||||
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CommandWhitelistVelocity.reloadConfig(sender);
|
|
||||||
return;
|
|
||||||
case ADD:
|
|
||||||
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
|
||||||
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args.length == 3) {
|
|
||||||
if (CWCommand.addToWhitelist(CommandWhitelistVelocity.getConfigCache(), args[2], args[1]))
|
|
||||||
sender.sendMessage(MiniMessage.markdown().parse(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().added_to_whitelist, args[2], args[1])));
|
|
||||||
else
|
|
||||||
sender.sendMessage(MiniMessage.markdown().parse(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().group_doesnt_exist, args[1])));
|
|
||||||
} else
|
|
||||||
sender.sendMessage(Component.text("/" + label + " add <group> <command>"));
|
|
||||||
return;
|
|
||||||
case REMOVE:
|
|
||||||
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
|
||||||
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args.length == 3) {
|
|
||||||
if (CWCommand.removeFromWhitelist(CommandWhitelistVelocity.getConfigCache(), args[2], args[1]))
|
|
||||||
sender.sendMessage(MiniMessage.markdown().parse(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().removed_from_whitelist, args[2], args[1])));
|
|
||||||
else
|
|
||||||
sender.sendMessage(MiniMessage.markdown().parse(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().group_doesnt_exist, args[1])));
|
|
||||||
} else
|
|
||||||
sender.sendMessage(Component.text("/" + label + " remove <group> <command>"));
|
|
||||||
return;
|
|
||||||
case HELP:
|
|
||||||
default:
|
|
||||||
sender.sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
sender.sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<List<String>> suggestAsync(Invocation invocation) {
|
|
||||||
CommandSource source = invocation.source();
|
|
||||||
String[] args = invocation.arguments();
|
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
|
||||||
List<String> serverCommands = new ArrayList<>();
|
|
||||||
return CWCommand.commandSuggestions(CommandWhitelistVelocity.getConfigCache(), serverCommands, args, source.hasPermission(CWPermission.RELOAD.permission()), source.hasPermission(CWPermission.ADMIN.permission()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"id":"commandwhitelist",
|
|
||||||
"name":"CommandWhitelist",
|
|
||||||
"version":"${project.version}",
|
|
||||||
"description":"You decide what commands players can use or tab complete on your server!",
|
|
||||||
"authors":["YouHaveTrouble"],
|
|
||||||
"dependencies":[],
|
|
||||||
"main":"eu.endermite.commandwhitelist.velocity.CommandWhitelistVelocity"
|
|
||||||
}
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
# User-specific stuff
|
|
||||||
.idea/
|
|
||||||
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
*.iws
|
|
||||||
|
|
||||||
# IntelliJ
|
|
||||||
out/
|
|
||||||
|
|
||||||
# Compiled class file
|
|
||||||
*.class
|
|
||||||
|
|
||||||
# Log file
|
|
||||||
*.log
|
|
||||||
|
|
||||||
# BlueJ files
|
|
||||||
*.ctxt
|
|
||||||
|
|
||||||
# Package Files #
|
|
||||||
*.jar
|
|
||||||
*.war
|
|
||||||
*.nar
|
|
||||||
*.ear
|
|
||||||
*.zip
|
|
||||||
*.tar.gz
|
|
||||||
*.rar
|
|
||||||
|
|
||||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
|
||||||
hs_err_pid*
|
|
||||||
|
|
||||||
*~
|
|
||||||
|
|
||||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
|
||||||
.fuse_hidden*
|
|
||||||
|
|
||||||
# KDE directory preferences
|
|
||||||
.directory
|
|
||||||
|
|
||||||
# Linux trash folder which might appear on any partition or disk
|
|
||||||
.Trash-*
|
|
||||||
|
|
||||||
# .nfs files are created when an open file is removed but is still being accessed
|
|
||||||
.nfs*
|
|
||||||
|
|
||||||
# General
|
|
||||||
.DS_Store
|
|
||||||
.AppleDouble
|
|
||||||
.LSOverride
|
|
||||||
|
|
||||||
# Icon must end with two \r
|
|
||||||
Icon
|
|
||||||
|
|
||||||
# Thumbnails
|
|
||||||
._*
|
|
||||||
|
|
||||||
# Files that might appear in the root of a volume
|
|
||||||
.DocumentRevisions-V100
|
|
||||||
.fseventsd
|
|
||||||
.Spotlight-V100
|
|
||||||
.TemporaryItems
|
|
||||||
.Trashes
|
|
||||||
.VolumeIcon.icns
|
|
||||||
.com.apple.timemachine.donotpresent
|
|
||||||
|
|
||||||
# Directories potentially created on remote AFP share
|
|
||||||
.AppleDB
|
|
||||||
.AppleDesktop
|
|
||||||
Network Trash Folder
|
|
||||||
Temporary Items
|
|
||||||
.apdisk
|
|
||||||
|
|
||||||
# Windows thumbnail cache files
|
|
||||||
Thumbs.db
|
|
||||||
Thumbs.db:encryptable
|
|
||||||
ehthumbs.db
|
|
||||||
ehthumbs_vista.db
|
|
||||||
|
|
||||||
# Dump file
|
|
||||||
*.stackdump
|
|
||||||
|
|
||||||
# Folder config file
|
|
||||||
[Dd]esktop.ini
|
|
||||||
|
|
||||||
# Recycle Bin used on file shares
|
|
||||||
$RECYCLE.BIN/
|
|
||||||
|
|
||||||
# Windows Installer files
|
|
||||||
*.cab
|
|
||||||
*.msi
|
|
||||||
*.msix
|
|
||||||
*.msm
|
|
||||||
*.msp
|
|
||||||
|
|
||||||
# Windows shortcuts
|
|
||||||
*.lnk
|
|
||||||
|
|
||||||
target/
|
|
||||||
|
|
||||||
pom.xml.tag
|
|
||||||
pom.xml.releaseBackup
|
|
||||||
pom.xml.versionsBackup
|
|
||||||
pom.xml.next
|
|
||||||
|
|
||||||
release.properties
|
|
||||||
dependency-reduced-pom.xml
|
|
||||||
buildNumber.properties
|
|
||||||
.mvn/timing.properties
|
|
||||||
.mvn/wrapper/maven-wrapper.jar
|
|
||||||
.flattened-pom.xml
|
|
||||||
|
|
||||||
# Common working directory
|
|
||||||
run/
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>Waterfall</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
<name>CommandWhitelist</name>
|
|
||||||
|
|
||||||
<description>You decide what commands players can use or tab complete on your server!</description>
|
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
<url>youhavetrouble.me</url>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.8.1</version>
|
|
||||||
<configuration>
|
|
||||||
<source>${java.version}</source>
|
|
||||||
<target>${java.version}</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>3.2.4</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
|
||||||
<finalName>${project.name}-${project.artifactId}-${project.parent.version}</finalName>
|
|
||||||
<relocations>
|
|
||||||
<relocation>
|
|
||||||
<pattern>org.bstats</pattern>
|
|
||||||
<shadedPattern>eu.endermite.bstats</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
</relocations>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>sonatype</id>
|
|
||||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>papermc</id>
|
|
||||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.github.waterfallmc</groupId>
|
|
||||||
<artifactId>waterfall-api</artifactId>
|
|
||||||
<version>1.17-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
|
||||||
<artifactId>Common</artifactId>
|
|
||||||
<version>${project.parent.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.kyori</groupId>
|
|
||||||
<artifactId>adventure-platform-bungeecord</artifactId>
|
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bstats</groupId>
|
|
||||||
<artifactId>bstats-bungeecord</artifactId>
|
|
||||||
<version>2.2.1</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
-105
@@ -1,105 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.waterfall;
|
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.common.CWGroup;
|
|
||||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
|
||||||
import eu.endermite.commandwhitelist.waterfall.command.BungeeMainCommand;
|
|
||||||
import eu.endermite.commandwhitelist.waterfall.listeners.BungeeChatEventListener;
|
|
||||||
import eu.endermite.commandwhitelist.waterfall.listeners.BungeeTabcompleteListener;
|
|
||||||
import eu.endermite.commandwhitelist.waterfall.listeners.WaterfallDefineCommandsListener;
|
|
||||||
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.CommandSender;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
|
||||||
import org.bstats.bungeecord.Metrics;
|
|
||||||
import org.bstats.charts.SimplePie;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public final class CommandWhitelistWaterfall extends Plugin {
|
|
||||||
|
|
||||||
private static CommandWhitelistWaterfall plugin;
|
|
||||||
private static ConfigCache configCache;
|
|
||||||
private static BungeeAudiences audiences;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
|
||||||
plugin = this;
|
|
||||||
getLogger().info("Running on "+ ChatColor.DARK_AQUA+getProxy().getName());
|
|
||||||
loadConfig();
|
|
||||||
audiences = BungeeAudiences.create(this);
|
|
||||||
this.getProxy().getPluginManager().registerListener(this, new BungeeChatEventListener());
|
|
||||||
try {
|
|
||||||
Class.forName("io.github.waterfallmc.waterfall.event.ProxyDefineCommandsEvent");
|
|
||||||
this.getProxy().getPluginManager().registerListener(this, new WaterfallDefineCommandsListener());
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
getLogger().severe(ChatColor.DARK_RED+"Bungee command completion blocker requires Waterfall other Waterfall fork.");
|
|
||||||
}
|
|
||||||
this.getProxy().getPluginManager().registerListener(this, new BungeeTabcompleteListener());
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new BungeeMainCommand("bcw"));
|
|
||||||
|
|
||||||
Metrics metrics = new Metrics(this, 8704);
|
|
||||||
metrics.addCustomChart(new SimplePie("proxy", () -> "Bungee/Waterfall"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CommandWhitelistWaterfall getPlugin() {
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
public static ConfigCache getConfigCache() {
|
|
||||||
return configCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BungeeAudiences getAudiences() {
|
|
||||||
return audiences;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadConfig() {
|
|
||||||
if (configCache == null)
|
|
||||||
configCache = new ConfigCache(new File(getDataFolder(), "config.yml"), false, getLogger());
|
|
||||||
else
|
|
||||||
configCache.reloadConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadConfigAsync(CommandSender sender) {
|
|
||||||
getProxy().getScheduler().runAsync(this, () -> {
|
|
||||||
loadConfig();
|
|
||||||
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(CommandWhitelistWaterfall.getConfigCache().prefix + CommandWhitelistWaterfall.getConfigCache().config_reloaded));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param player Bungee Player
|
|
||||||
* @return commands available to the player
|
|
||||||
*/
|
|
||||||
public static HashSet<String> getCommands(ProxiedPlayer player) {
|
|
||||||
HashSet<String> commandList = new HashSet<>();
|
|
||||||
HashMap<String, CWGroup> groups = configCache.getGroupList();
|
|
||||||
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
|
|
||||||
if (s.getKey().equalsIgnoreCase("default"))
|
|
||||||
commandList.addAll(s.getValue().getCommands());
|
|
||||||
else if (player.hasPermission(s.getValue().getPermission()))
|
|
||||||
commandList.addAll(s.getValue().getCommands());
|
|
||||||
}
|
|
||||||
return commandList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param player Bungee Player
|
|
||||||
* @return subcommands unavailable for the player
|
|
||||||
*/
|
|
||||||
public static HashSet<String> getSuggestions(ProxiedPlayer player) {
|
|
||||||
HashMap<String, CWGroup> groups = configCache.getGroupList();
|
|
||||||
HashSet<String> suggestionList = new HashSet<>();
|
|
||||||
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
|
|
||||||
if (s.getKey().equalsIgnoreCase("default"))
|
|
||||||
suggestionList.addAll(s.getValue().getSubCommands());
|
|
||||||
if (player.hasPermission(s.getValue().getPermission())) continue;
|
|
||||||
suggestionList.addAll(s.getValue().getSubCommands());
|
|
||||||
}
|
|
||||||
return suggestionList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-90
@@ -1,90 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.waterfall.command;
|
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
|
||||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
|
||||||
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
|
||||||
import eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall;
|
|
||||||
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
|
|
||||||
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.plugin.Command;
|
|
||||||
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 BungeeMainCommand(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
|
||||||
|
|
||||||
String label = getName();
|
|
||||||
ConfigCache configCache = CommandWhitelistWaterfall.getConfigCache();
|
|
||||||
BungeeAudiences audiences = CommandWhitelistWaterfall.getAudiences();
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
|
||||||
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
CWCommand.CommandType commandType = CWCommand.CommandType.valueOf(args[0].toUpperCase());
|
|
||||||
switch (commandType) {
|
|
||||||
case RELOAD:
|
|
||||||
if (!sender.hasPermission(CWPermission.RELOAD.permission())) {
|
|
||||||
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(CommandWhitelistWaterfall.getConfigCache().prefix + configCache.no_permission));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CommandWhitelistWaterfall.getPlugin().loadConfigAsync(sender);
|
|
||||||
return;
|
|
||||||
case ADD:
|
|
||||||
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
|
||||||
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.no_permission));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args.length == 3) {
|
|
||||||
if (CWCommand.addToWhitelist(configCache, args[2], args[1]))
|
|
||||||
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.added_to_whitelist));
|
|
||||||
else
|
|
||||||
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.group_doesnt_exist));
|
|
||||||
} else
|
|
||||||
audiences.sender(sender).sendMessage(Component.text("/"+label+" add <group> <command>"));
|
|
||||||
return;
|
|
||||||
case REMOVE:
|
|
||||||
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
|
||||||
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.no_permission));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args.length == 3) {
|
|
||||||
if (CWCommand.removeFromWhitelist(configCache, args[2], args[1]))
|
|
||||||
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.removed_from_whitelist));
|
|
||||||
else
|
|
||||||
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.group_doesnt_exist));
|
|
||||||
} else
|
|
||||||
audiences.sender(sender).sendMessage(Component.text("/"+label+" remove <group> <command>"));
|
|
||||||
return;
|
|
||||||
case HELP:
|
|
||||||
default:
|
|
||||||
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-48
@@ -1,48 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.waterfall.listeners;
|
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
|
||||||
import eu.endermite.commandwhitelist.common.CommandUtil;
|
|
||||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
|
||||||
import eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall;
|
|
||||||
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.plugin.Listener;
|
|
||||||
import net.md_5.bungee.event.EventHandler;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
public class BungeeChatEventListener implements Listener {
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onChatEvent(net.md_5.bungee.api.event.ChatEvent event) {
|
|
||||||
if (event.isCancelled()) return;
|
|
||||||
if (!(event.getSender() instanceof ProxiedPlayer)) return;
|
|
||||||
if (!event.isProxyCommand()) return;
|
|
||||||
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
|
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
|
||||||
|
|
||||||
String command = event.getMessage().toLowerCase();
|
|
||||||
if (command.startsWith("/"))
|
|
||||||
command = command.substring(1);
|
|
||||||
ConfigCache configCache = CommandWhitelistWaterfall.getConfigCache();
|
|
||||||
BungeeAudiences audiences = CommandWhitelistWaterfall.getAudiences();
|
|
||||||
|
|
||||||
String label = CommandUtil.getCommandLabel(command);
|
|
||||||
HashSet<String> commands = CommandWhitelistWaterfall.getCommands(player);
|
|
||||||
if (!commands.contains(label)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
CommandWhitelistWaterfall.getAudiences().player(player).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.command_denied));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HashSet<String> bannedSubCommands = CommandWhitelistWaterfall.getSuggestions(player);
|
|
||||||
for (String bannedSubCommand : bannedSubCommands) {
|
|
||||||
if (command.startsWith(bannedSubCommand)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
audiences.player(player).sendMessage(MiniMessage.markdown().parse(configCache.prefix + configCache.subcommand_denied));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-27
@@ -1,27 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.waterfall.listeners;
|
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
|
||||||
import eu.endermite.commandwhitelist.common.CommandUtil;
|
|
||||||
import eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
|
||||||
import net.md_5.bungee.event.EventHandler;
|
|
||||||
|
|
||||||
public class BungeeTabcompleteListener implements Listener {
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onTabcomplete(net.md_5.bungee.api.event.TabCompleteEvent event) {
|
|
||||||
if (!(event.getReceiver() instanceof ProxiedPlayer)) return;
|
|
||||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
|
||||||
|
|
||||||
CommandUtil.filterSuggestions(
|
|
||||||
event.getCursor(),
|
|
||||||
event.getSuggestions(),
|
|
||||||
CommandWhitelistWaterfall.getSuggestions(player)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-29
@@ -1,29 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.waterfall.listeners;
|
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
|
||||||
import eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
import net.md_5.bungee.api.plugin.Command;
|
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
|
||||||
import net.md_5.bungee.event.EventHandler;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class WaterfallDefineCommandsListener implements Listener {
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onProxyDefineCommandsEvent(io.github.waterfallmc.waterfall.event.ProxyDefineCommandsEvent event) {
|
|
||||||
if (event.getReceiver() instanceof ProxiedPlayer) {
|
|
||||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission()))
|
|
||||||
return;
|
|
||||||
HashMap<String, Command> commandHashMap = new HashMap<>();
|
|
||||||
CommandWhitelistWaterfall.getCommands(player).forEach(cmdName ->
|
|
||||||
CommandWhitelistWaterfall.getPlugin().getProxy().getPluginManager().getCommands()
|
|
||||||
.stream()
|
|
||||||
.filter(commandEntry -> cmdName.equalsIgnoreCase(commandEntry.getValue().getName()))
|
|
||||||
.forEach(commandEntry -> commandHashMap.put(commandEntry.getKey(), commandEntry.getValue())));
|
|
||||||
event.getCommands().values().removeIf((cmd) -> !commandHashMap.containsValue(cmd));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
name: CommandWhitelist
|
|
||||||
version: ${project.version}
|
|
||||||
main: eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall
|
|
||||||
description: You decide what commands players can use or tab complete on your server!
|
|
||||||
@@ -0,0 +1,339 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
|
source code as you receive it, in any medium, provided that you
|
||||||
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
|
any particular circumstance, the balance of the section is intended to
|
||||||
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and "any
|
||||||
|
later version", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License.
|
||||||
@@ -6,42 +6,135 @@
|
|||||||
|
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.0</version>
|
<version>3.0.0</version>
|
||||||
<modules>
|
|
||||||
<module>CommandWhitelistCommon</module>
|
|
||||||
<module>CommandWhitelistBukkit</module>
|
|
||||||
<module>CommandWhitelistVelocity</module>
|
|
||||||
<module>CommandWhitelistWaterfall</module>
|
|
||||||
</modules>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
|
|
||||||
<name>CommandWhitelist</name>
|
<name>CommandWhitelist</name>
|
||||||
|
|
||||||
<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>1.8</java.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<website>https://youhavetrouble.me</website>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.4</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
|
<finalName>${project.name}-${project.version}</finalName>
|
||||||
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>net.kyori</pattern>
|
||||||
|
<shadedPattern>me.youhavetrouble</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>com.github.thatsmusic99</pattern>
|
||||||
|
<shadedPattern>me.youhavetrouble</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>pluginwiki-repo</id>
|
||||||
|
<url>https://ci.pluginwiki.us/plugin/repository/everything/</url>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<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>velocitypowered-repo</id>
|
||||||
|
<url>https://repo.velocitypowered.com/releases/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>papermc</id>
|
||||||
|
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>dmulloy2-repo</id>
|
||||||
|
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.thatsmusic99</groupId>
|
||||||
|
<artifactId>ConfigurationMaster-API</artifactId>
|
||||||
|
<version>v2.0.0-BETA-6</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-api</artifactId>
|
<artifactId>adventure-api</artifactId>
|
||||||
<version>4.8.1</version>
|
<version>4.13.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-platform-bukkit</artifactId>
|
||||||
|
<version>4.2.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.1.0-SNAPSHOT</version>
|
<version>4.13.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.velocitypowered</groupId>
|
||||||
|
<artifactId>velocity-api</artifactId>
|
||||||
|
<version>3.1.2-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.papermc.paper</groupId>
|
||||||
|
<artifactId>paper-api</artifactId>
|
||||||
|
<version>1.19-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.github.waterfallmc</groupId>
|
||||||
|
<artifactId>waterfall-api</artifactId>
|
||||||
|
<version>1.19-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
|
<artifactId>ProtocolLib</artifactId>
|
||||||
|
<version>5.0.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
Command Whitelist is a plugin that allows you to control
|
Command Whitelist is a plugin that allows you to control
|
||||||
precisely what commands players can see and use.
|
precisely what commands players can see and use.
|
||||||
|
|
||||||
|
<h1>WARNING: This is an experimental branch, literally everything here is subject to change</h1>
|
||||||
|
|
||||||
[](https://www.codefactor.io/repository/github/youhavetrouble/commandwhitelist)
|
[](https://www.codefactor.io/repository/github/youhavetrouble/commandwhitelist)
|
||||||
[](https://github.com/YouHaveTrouble/CommandWhitelist/releases)
|
[](https://github.com/YouHaveTrouble/CommandWhitelist/releases)
|
||||||
[](https://discord.gg/j8KK5dGBps)
|
[](https://discord.gg/j8KK5dGBps)
|
||||||
@@ -15,7 +17,6 @@ precisely what commands players can see and use.
|
|||||||
<li>Overwrite default "no such command" message with your branding
|
<li>Overwrite default "no such command" message with your branding
|
||||||
<li>Block tab completion</li>
|
<li>Block tab completion</li>
|
||||||
<li>Block command execution</li>
|
<li>Block command execution</li>
|
||||||
<li>Block completion and execution of specified subcommands</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<b>Compatible versions</b>: 1.13+
|
<b>Compatible versions</b>: 1.13+
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package me.youhavetrouble.commandwhitelist.bukkit;
|
||||||
|
|
||||||
|
import me.youhavetrouble.commandwhitelist.bukkit.listeners.CommandExecuteListener;
|
||||||
|
import me.youhavetrouble.commandwhitelist.bukkit.listeners.CommandSendListener;
|
||||||
|
import me.youhavetrouble.commandwhitelist.bukkit.listeners.CommandTabCompleteListener;
|
||||||
|
import me.youhavetrouble.commandwhitelist.common.CWConfig;
|
||||||
|
import me.youhavetrouble.commandwhitelist.common.commands.CWCommand;
|
||||||
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public class CommandWhitelistBukkit extends JavaPlugin {
|
||||||
|
|
||||||
|
private CWConfig CWConfig;
|
||||||
|
private BukkitAudiences audiences;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
reloadPluginConfig();
|
||||||
|
audiences = BukkitAudiences.create(this);
|
||||||
|
getServer().getPluginManager().registerEvents(new CommandSendListener(this), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new CommandExecuteListener(this), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new CommandTabCompleteListener(this), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reloadPluginConfig() {
|
||||||
|
File configFile = new File("plugins/CommandWhitelist/config.yml");
|
||||||
|
if (CWConfig != null) {
|
||||||
|
CWConfig.reloadConfig();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
CWConfig = new CWConfig(configFile, true, getSLF4JLogger());
|
||||||
|
} catch (NoSuchMethodError e) {
|
||||||
|
CWConfig = new CWConfig(configFile, true, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompletableFuture<Void> reloadPluginConfig(CommandSender sender) {
|
||||||
|
return CompletableFuture.runAsync(() -> {
|
||||||
|
reloadPluginConfig();
|
||||||
|
try {
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
|
p.updateCommands();
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(CWConfig.prefix + CWConfig.config_reloaded));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public CWConfig getCWConfig() {
|
||||||
|
return CWConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
package me.youhavetrouble.commandwhitelist.bukkit.listeners;
|
||||||
|
|
||||||
|
import me.youhavetrouble.commandwhitelist.bukkit.CommandWhitelistBukkit;
|
||||||
|
import me.youhavetrouble.commandwhitelist.common.CWCommandEntry;
|
||||||
|
import me.youhavetrouble.commandwhitelist.common.CWPermission;
|
||||||
|
import me.youhavetrouble.commandwhitelist.common.CWPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
public class CommandExecuteListener implements Listener {
|
||||||
|
|
||||||
|
private final CommandWhitelistBukkit plugin;
|
||||||
|
|
||||||
|
public CommandExecuteListener(CommandWhitelistBukkit plugin ) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
|
public void onCommandPreProcess(PlayerCommandPreprocessEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||||
|
CWPlayer cwPlayer = new CWPlayer(player);
|
||||||
|
for (CWCommandEntry entry : cwPlayer.getCommands(plugin.getCWConfig())) {
|
||||||
|
if (entry.matches(event.getMessage())) return;
|
||||||
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
package me.youhavetrouble.commandwhitelist.bukkit.listeners;
|
||||||
|
|
||||||
|
import me.youhavetrouble.commandwhitelist.bukkit.CommandWhitelistBukkit;
|
||||||
|
import me.youhavetrouble.commandwhitelist.common.CWCommandEntry;
|
||||||
|
import me.youhavetrouble.commandwhitelist.common.CWPermission;
|
||||||
|
import me.youhavetrouble.commandwhitelist.common.CWPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
public class CommandSendListener implements Listener {
|
||||||
|
|
||||||
|
private final CommandWhitelistBukkit plugin;
|
||||||
|
|
||||||
|
public CommandSendListener(CommandWhitelistBukkit plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
|
public void onCommandSend(PlayerCommandSendEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||||
|
Iterator<String> iterator = event.getCommands().iterator();
|
||||||
|
CWPlayer cwPlayer = new CWPlayer(player);
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
String command = iterator.next();
|
||||||
|
for (CWCommandEntry entry : cwPlayer.getCommands(plugin.getCWConfig())) {
|
||||||
|
if (entry.argumentMatches(command, 0)) continue;
|
||||||
|
iterator.remove();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
package me.youhavetrouble.commandwhitelist.bukkit.listeners;
|
||||||
|
|
||||||
|
import me.youhavetrouble.commandwhitelist.bukkit.CommandWhitelistBukkit;
|
||||||
|
import me.youhavetrouble.commandwhitelist.common.CWCommandEntry;
|
||||||
|
import me.youhavetrouble.commandwhitelist.common.CWPermission;
|
||||||
|
import me.youhavetrouble.commandwhitelist.common.CWPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.server.TabCompleteEvent;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CommandTabCompleteListener implements Listener {
|
||||||
|
|
||||||
|
private final CommandWhitelistBukkit plugin;
|
||||||
|
|
||||||
|
public CommandTabCompleteListener(CommandWhitelistBukkit plugin ) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
|
public void onCommandTabComplete(TabCompleteEvent 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.split(" ").length == 1 && !buffer.endsWith(" ")) || !buffer.startsWith("/")) {
|
||||||
|
plugin.getCWConfig().debug("Actively prevented "+event.getSender().getName()+"'s tab completion (sus packet)");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getCompletions().isEmpty()) return;
|
||||||
|
|
||||||
|
String[] split = buffer.split(" ");
|
||||||
|
if (split.length == 0) return;
|
||||||
|
String[] splitWithoutLastArg = new String[split.length - 1];
|
||||||
|
System.arraycopy(split, 0, splitWithoutLastArg, 0, splitWithoutLastArg.length);
|
||||||
|
String commandWithoutLastArg = String.join(" ", splitWithoutLastArg);
|
||||||
|
|
||||||
|
CWPlayer cwPlayer = new CWPlayer(player);
|
||||||
|
List<CWCommandEntry> validCompletions = new ArrayList<>();
|
||||||
|
for (CWCommandEntry entry : cwPlayer.getCommands(plugin.getCWConfig())) {
|
||||||
|
if (!entry.partiallyMatches(commandWithoutLastArg)) continue;
|
||||||
|
validCompletions.add(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
int index = split.length - 1;
|
||||||
|
|
||||||
|
List<String> completions = event.getCompletions();
|
||||||
|
Iterator<String> iterator = completions.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
String completion = iterator.next();
|
||||||
|
for (CWCommandEntry entry : validCompletions) {
|
||||||
|
if (entry.argumentMatches(completion, index)) continue;
|
||||||
|
iterator.remove();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCompletions(completions);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package me.youhavetrouble.commandwhitelist.common;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class CWCommandEntry {
|
||||||
|
|
||||||
|
private final String rawEntry;
|
||||||
|
private final List<Pattern> parts;
|
||||||
|
|
||||||
|
protected CWCommandEntry(String command) {
|
||||||
|
this.rawEntry = command;
|
||||||
|
String[] parts = command.split(" ");
|
||||||
|
this.parts = new ArrayList<>(parts.length);
|
||||||
|
for (String part : parts) {
|
||||||
|
Pattern pattern = Pattern.compile(part);
|
||||||
|
this.parts.add(pattern);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the command parts.
|
||||||
|
* @return command parts
|
||||||
|
*/
|
||||||
|
public List<Pattern> getParts() {
|
||||||
|
return Collections.unmodifiableList(parts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the raw command entry as given in the constructor.
|
||||||
|
* @return raw command entry
|
||||||
|
*/
|
||||||
|
public String getRawEntry() {
|
||||||
|
return rawEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a full command input matches this command entry. Input is a match if all entry slices match the
|
||||||
|
* corresponding command slices, even if there are more command slices than entry slices.
|
||||||
|
* @param command full command input
|
||||||
|
* @return true if the command matches this command entry
|
||||||
|
*/
|
||||||
|
public boolean matches(String command) {
|
||||||
|
if (command == null) return false;
|
||||||
|
if (command.startsWith("/")) command = command.substring(1); // Remove leading slash (if present)
|
||||||
|
String[] parts = command.split(" ");
|
||||||
|
if (parts.length < this.parts.size()) return false;
|
||||||
|
for (int i = 0; i < this.parts.size(); i++) {
|
||||||
|
if (!argumentMatches(parts[i], i)) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a command input partially matches this command entry.
|
||||||
|
* @param command command input
|
||||||
|
* @return true if the command partially matches this command entry
|
||||||
|
*/
|
||||||
|
public boolean partiallyMatches(String command) {
|
||||||
|
if (command == null) return false;
|
||||||
|
if (command.startsWith("/")) command = command.substring(1); // Remove leading slash (if present)
|
||||||
|
String[] parts = command.split(" ");
|
||||||
|
for (int i = 0; i < this.parts.size() || i < parts.length; i++) {
|
||||||
|
if (!argumentMatches(parts[i], i)) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a command argument matches this command entry.
|
||||||
|
* @param argument command argument
|
||||||
|
* @param index argument index
|
||||||
|
* @return true if the argument matches this command entry
|
||||||
|
*/
|
||||||
|
public boolean argumentMatches(String argument, int index) {
|
||||||
|
if (index < 0 || index >= parts.size()) return false;
|
||||||
|
return parts.get(index).matcher(argument).matches();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+38
-13
@@ -1,4 +1,4 @@
|
|||||||
package eu.endermite.commandwhitelist.common;
|
package me.youhavetrouble.commandwhitelist.common;
|
||||||
|
|
||||||
import io.github.thatsmusic99.configurationmaster.api.ConfigFile;
|
import io.github.thatsmusic99.configurationmaster.api.ConfigFile;
|
||||||
import io.github.thatsmusic99.configurationmaster.api.ConfigSection;
|
import io.github.thatsmusic99.configurationmaster.api.ConfigSection;
|
||||||
@@ -7,7 +7,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class ConfigCache {
|
public class CWConfig {
|
||||||
|
|
||||||
private final File configFile;
|
private final File configFile;
|
||||||
private ConfigFile config;
|
private ConfigFile config;
|
||||||
@@ -17,8 +17,9 @@ 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 boolean debug = false;
|
||||||
|
|
||||||
public ConfigCache(File configFile, boolean canDoProtocolLib, Object logger) {
|
public CWConfig(File configFile, boolean canDoProtocolLib, Object logger) {
|
||||||
this.configFile = configFile;
|
this.configFile = configFile;
|
||||||
this.canDoProtocolLib = canDoProtocolLib;
|
this.canDoProtocolLib = canDoProtocolLib;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
@@ -29,11 +30,14 @@ public class ConfigCache {
|
|||||||
public boolean reloadConfig() {
|
public boolean reloadConfig() {
|
||||||
|
|
||||||
createFiles();
|
createFiles();
|
||||||
config = ConfigFile.loadConfig(configFile);
|
try {
|
||||||
|
config = ConfigFile.loadConfig(configFile);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
config.addDefault("messages.prefix", "CommandWhitelist > ");
|
config.addDefault("messages.prefix", "CommandWhitelist > ");
|
||||||
config.addDefault("messages.command_denied", "No such command.");
|
config.addDefault("messages.command_denied", "No such command.");
|
||||||
config.addDefault("messages.subcommand_denied", "You cannot use this subcommand");
|
|
||||||
config.addDefault("messages.no_permission", "<red>You don't have permission to do this.");
|
config.addDefault("messages.no_permission", "<red>You don't have permission to do this.");
|
||||||
config.addDefault("messages.no_such_subcommand", "<red>No subcommand by that name.");
|
config.addDefault("messages.no_such_subcommand", "<red>No subcommand by that name.");
|
||||||
config.addDefault("messages.config_reloaded", "<yellow>Configuration reloaded.");
|
config.addDefault("messages.config_reloaded", "<yellow>Configuration reloaded.");
|
||||||
@@ -41,7 +45,7 @@ public class ConfigCache {
|
|||||||
config.addDefault("messages.removed_from_whitelist", "<yellow>Removed command <gold>%s <yellow>from permission <gold>%s");
|
config.addDefault("messages.removed_from_whitelist", "<yellow>Removed command <gold>%s <yellow>from permission <gold>%s");
|
||||||
config.addDefault("messages.group_doesnt_exist", "<red>Group doesn't exist or error occured");
|
config.addDefault("messages.group_doesnt_exist", "<red>Group doesn't exist or error occured");
|
||||||
|
|
||||||
config.addComment("messages", "Messages use MiniMessage formatting (https://docs.adventure.kyori.net/minimessage.html#format)");
|
config.addComment("messages", "Messages use MiniMessage formatting (https://docs.adventure.kyori.net/minimessage/format)");
|
||||||
|
|
||||||
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.");
|
||||||
@@ -51,9 +55,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: []\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,10 +78,8 @@ public class ConfigCache {
|
|||||||
defaultCommands.add("tpaccept");
|
defaultCommands.add("tpaccept");
|
||||||
defaultCommands.add("tpdeny");
|
defaultCommands.add("tpdeny");
|
||||||
defaultCommands.add("warp");
|
defaultCommands.add("warp");
|
||||||
List<String> defaultSubcommands = new ArrayList<>();
|
|
||||||
defaultSubcommands.add("help about");
|
|
||||||
|
|
||||||
config.addDefault("groups.default", new CWGroup("default", defaultCommands, defaultSubcommands).serialize());
|
config.addDefault("groups.default", new CWGroup("default", defaultCommands).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,8 @@ 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");
|
||||||
|
debug = config.getBoolean("debug", false);
|
||||||
|
|
||||||
ConfigSection groupSection = config.getConfigSection("groups");
|
ConfigSection groupSection = config.getConfigSection("groups");
|
||||||
for (String key : groupSection.getKeys(false)) {
|
for (String key : groupSection.getKeys(false)) {
|
||||||
@@ -99,7 +105,7 @@ public class ConfigCache {
|
|||||||
try {
|
try {
|
||||||
config.save();
|
config.save();
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,12 +134,11 @@ public class ConfigCache {
|
|||||||
commands.add(cmd);
|
commands.add(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> subCommands = section.getStringList(id + ".subcommands");
|
return new CWGroup(id, commands);
|
||||||
return new CWGroup(id, commands, subCommands);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +147,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;
|
||||||
@@ -152,4 +161,20 @@ public class ConfigCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void debug(String log) {
|
||||||
|
if (!debug) return;
|
||||||
|
if (logger == null) {
|
||||||
|
System.out.println("DEBUG: "+log);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (logger instanceof org.slf4j.Logger) {
|
||||||
|
((org.slf4j.Logger) logger).info(log);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (logger instanceof java.util.logging.Logger) {
|
||||||
|
((java.util.logging.Logger) logger).info(log);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package me.youhavetrouble.commandwhitelist.common;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class CWGroup {
|
||||||
|
|
||||||
|
private final String id;
|
||||||
|
private final HashSet<CWCommandEntry> commands = new HashSet<>();
|
||||||
|
|
||||||
|
public CWGroup(String id, Collection<String> commands) {
|
||||||
|
this.id = id;
|
||||||
|
for (String command : commands) {
|
||||||
|
this.commands.add(new CWCommandEntry(command));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPermission() {
|
||||||
|
return "commandwhitelist.group." + id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<CWCommandEntry> getCommands() {
|
||||||
|
return commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCommand(String command) {
|
||||||
|
this.commands.add(new CWCommandEntry(command));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeCommand(String command) {
|
||||||
|
commands.removeIf(cwCommandEntry -> cwCommandEntry.getRawEntry().equals(command));
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, Object> serialize() {
|
||||||
|
HashMap<String, Object> serializedGroup = new LinkedHashMap<>();
|
||||||
|
List<String> commands = new ArrayList<>();
|
||||||
|
for (CWCommandEntry command : this.commands) {
|
||||||
|
commands.add(command.getRawEntry());
|
||||||
|
}
|
||||||
|
serializedGroup.put("commands", commands);
|
||||||
|
return serializedGroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-8
@@ -1,4 +1,4 @@
|
|||||||
package eu.endermite.commandwhitelist.common;
|
package me.youhavetrouble.commandwhitelist.common;
|
||||||
|
|
||||||
public enum CWPermission {
|
public enum CWPermission {
|
||||||
|
|
||||||
@@ -18,14 +18,10 @@ public enum CWPermission {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows to check specific group permission
|
* Allows to check specific group permission
|
||||||
* @param configCache
|
*
|
||||||
* @param groupId
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static String getGroupPermission(ConfigCache configCache, String groupId) {
|
public static String getGroupPermission(String groupId) {
|
||||||
if (configCache.getGroupList().containsKey(groupId))
|
return "commandwhitelist.group." + groupId;
|
||||||
return configCache.getGroupList().get(groupId).getPermission();
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package me.youhavetrouble.commandwhitelist.common;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a player on any supported platform.
|
||||||
|
*/
|
||||||
|
public class CWPlayer {
|
||||||
|
|
||||||
|
private org.bukkit.entity.Player bukkitPlayer;
|
||||||
|
private com.velocitypowered.api.proxy.Player velocityPlayer;
|
||||||
|
private net.md_5.bungee.api.connection.ProxiedPlayer waterfallPlayer;
|
||||||
|
|
||||||
|
public CWPlayer(org.bukkit.entity.Player player) {
|
||||||
|
this.bukkitPlayer = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CWPlayer(com.velocitypowered.api.proxy.Player player) {
|
||||||
|
this.velocityPlayer = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CWPlayer(net.md_5.bungee.api.connection.ProxiedPlayer player) {
|
||||||
|
this.waterfallPlayer = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this player has a permission.
|
||||||
|
* @param permission Permission to check
|
||||||
|
* @return Whether this player has the permission
|
||||||
|
*/
|
||||||
|
public boolean hasPermission(String permission) {
|
||||||
|
if (bukkitPlayer != null) return bukkitPlayer.hasPermission(permission);
|
||||||
|
if (velocityPlayer != null) return velocityPlayer.hasPermission(permission);
|
||||||
|
if (waterfallPlayer != null) return waterfallPlayer.hasPermission(permission);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the commands that this player can use.
|
||||||
|
* @param CWConfig Current configuration cache
|
||||||
|
* @return Set of commands that this player can use
|
||||||
|
*/
|
||||||
|
public Set<CWCommandEntry> getCommands(CWConfig CWConfig) {
|
||||||
|
HashSet<CWCommandEntry> commands = new HashSet<>();
|
||||||
|
Map<String, CWGroup> groups = CWConfig.getGroupList();
|
||||||
|
for (Map.Entry<String, CWGroup> groupEntry : groups.entrySet()) {
|
||||||
|
CWGroup group = groupEntry.getValue();
|
||||||
|
String groupId = groupEntry.getKey();
|
||||||
|
if (groupId.equalsIgnoreCase("default")) commands.addAll(group.getCommands());
|
||||||
|
else if (hasPermission(group.getPermission())) commands.addAll(group.getCommands());
|
||||||
|
}
|
||||||
|
return commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+34
-21
@@ -1,31 +1,22 @@
|
|||||||
package eu.endermite.commandwhitelist.common;
|
package me.youhavetrouble.commandwhitelist.common;
|
||||||
|
|
||||||
|
import io.github.thatsmusic99.configurationmaster.api.ConfigFile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CommandUtil {
|
public class CommandUtil {
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters blocked command suggestions from provided collection of strings
|
public static List<String> filterCommandList(Collection<String> allCommands, Collection<String> allowedCommands) {
|
||||||
*
|
List<String> filteredCommands = new ArrayList<>();
|
||||||
* @param buffer Command buffer
|
|
||||||
* @param suggestions Full suggestions list
|
|
||||||
* @param blockedSubCommands Subcommands to filter out
|
|
||||||
* @return Filtered list of suggestions
|
return filteredCommands;
|
||||||
*/
|
|
||||||
public static List<String> filterSuggestions(String buffer, Collection<String> suggestions, Collection<String> blockedSubCommands) {
|
|
||||||
if (buffer.startsWith("/"))
|
|
||||||
buffer = buffer.substring(1);
|
|
||||||
for (String s : blockedSubCommands) {
|
|
||||||
String slast = getLastArgument(s);
|
|
||||||
String scommand = cutLastArgument(s);
|
|
||||||
if (buffer.startsWith(scommand)) {
|
|
||||||
while (suggestions.contains(slast))
|
|
||||||
suggestions.remove(slast);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new ArrayList<>(suggestions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,4 +52,26 @@ public class CommandUtil {
|
|||||||
return parts[0];
|
return parts[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps command list to a file
|
||||||
|
*
|
||||||
|
* @param serverCommands Commands to dump
|
||||||
|
* @return True on successful file save
|
||||||
|
*/
|
||||||
|
public static boolean dumpAllBukkitCommands(ArrayList<String> serverCommands, File file) {
|
||||||
|
try {
|
||||||
|
File parent = new File(file.getParent());
|
||||||
|
if (!parent.exists())
|
||||||
|
parent.mkdir();
|
||||||
|
if (!file.exists())
|
||||||
|
file.createNewFile();
|
||||||
|
ConfigFile dumpFile = ConfigFile.loadConfig(file);
|
||||||
|
dumpFile.set("commands", serverCommands);
|
||||||
|
dumpFile.save();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
package me.youhavetrouble.commandwhitelist.common.commands;
|
||||||
|
|
||||||
|
import me.youhavetrouble.commandwhitelist.common.CWGroup;
|
||||||
|
import me.youhavetrouble.commandwhitelist.common.CWConfig;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CWCommand {
|
||||||
|
|
||||||
|
public static MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||||
|
|
||||||
|
public static boolean addToWhitelist(CWConfig CWConfig, String command, String group) {
|
||||||
|
CWGroup cwGroup = CWConfig.getGroupList().get(group);
|
||||||
|
if (cwGroup == null) return false;
|
||||||
|
cwGroup.addCommand(command);
|
||||||
|
CWConfig.saveCWGroup(group, cwGroup);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean removeFromWhitelist(CWConfig CWConfig, String command, String group) {
|
||||||
|
CWGroup cwGroup = CWConfig.getGroupList().get(group);
|
||||||
|
if (cwGroup == null)
|
||||||
|
return false;
|
||||||
|
cwGroup.removeCommand(command);
|
||||||
|
CWConfig.saveCWGroup(group, cwGroup);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Component helpComponent(String baseCommand, boolean showReloadCommand, boolean showAdminCommands) {
|
||||||
|
final TextComponent.Builder builder = Component.text();
|
||||||
|
builder.append(miniMessage.deserialize("<rainbow><bold>CommandWhitelist by YouHaveTrouble</bold>"), Component.newline());
|
||||||
|
builder.append(Component.text(baseCommand + " help", NamedTextColor.AQUA), Component.text(" - Displays this message", NamedTextColor.BLUE));
|
||||||
|
if (showReloadCommand) {
|
||||||
|
builder.append(Component.newline());
|
||||||
|
builder.append(Component.text(baseCommand + " reload", NamedTextColor.AQUA), Component.text(" - Reloads plugin configuration", NamedTextColor.BLUE));
|
||||||
|
}
|
||||||
|
if (showAdminCommands) {
|
||||||
|
builder.append(Component.newline());
|
||||||
|
builder.append(Component.text(baseCommand + " add <group> <command>", NamedTextColor.AQUA), Component.text(" - Add a command to selected permission group", NamedTextColor.BLUE));
|
||||||
|
builder.append(Component.newline());
|
||||||
|
builder.append(Component.text(baseCommand + " remove <group> <command>", NamedTextColor.AQUA), Component.text(" - Removes a command from selected permission group", NamedTextColor.BLUE));
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CommandType {
|
||||||
|
ADD, REMOVE, HELP, RELOAD, DUMP
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ImplementationType {
|
||||||
|
BUKKIT, WATERFALL, VELOCITY
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> commandSuggestions(
|
||||||
|
CWConfig config,
|
||||||
|
Collection<String> serverCommands,
|
||||||
|
String[] args, boolean reloadPerm,
|
||||||
|
boolean adminPerm,
|
||||||
|
ImplementationType implementationType
|
||||||
|
) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
// thanks velocity for handling completions entirely different from everything else
|
||||||
|
if (implementationType.equals(ImplementationType.VELOCITY)) {
|
||||||
|
list.add("help");
|
||||||
|
if (reloadPerm)
|
||||||
|
list.add("reload");
|
||||||
|
if (adminPerm) {
|
||||||
|
list.add("add");
|
||||||
|
list.add("remove");
|
||||||
|
list.add("dump");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
case 1:
|
||||||
|
if ("help".startsWith(args[0]))
|
||||||
|
list.add("help");
|
||||||
|
if ("reload".startsWith(args[0]) && reloadPerm)
|
||||||
|
list.add("reload");
|
||||||
|
if ("add".startsWith(args[0]) && adminPerm)
|
||||||
|
list.add("add");
|
||||||
|
if ("remove".startsWith(args[0]) && adminPerm)
|
||||||
|
list.add("remove");
|
||||||
|
if ("dump".startsWith(args[0]) && adminPerm)
|
||||||
|
list.add("dump");
|
||||||
|
return list;
|
||||||
|
case 2:
|
||||||
|
if (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove")) {
|
||||||
|
if (!adminPerm) return list;
|
||||||
|
for (String s : config.getGroupList().keySet()) {
|
||||||
|
if (s.startsWith(args[1]))
|
||||||
|
list.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
case 3:
|
||||||
|
if (args[0].equalsIgnoreCase("remove")) {
|
||||||
|
if (!adminPerm) return list;
|
||||||
|
CWGroup group = config.getGroupList().get(args[1]);
|
||||||
|
if (group == null) return list;
|
||||||
|
// TODO
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("add")) {
|
||||||
|
if (!adminPerm) return list;
|
||||||
|
CWGroup group = config.getGroupList().get(args[1]);
|
||||||
|
if (group == null) return list;
|
||||||
|
for (String cmd : serverCommands) {
|
||||||
|
if (cmd.startsWith("/"))
|
||||||
|
cmd = cmd.substring(1);
|
||||||
|
if (cmd.contains(":")) {
|
||||||
|
String[] cmdSplit = cmd.split(":");
|
||||||
|
if (cmdSplit.length < 2) continue;
|
||||||
|
cmd = cmdSplit[1];
|
||||||
|
}
|
||||||
|
if (group.getCommands().contains(cmd)) continue;
|
||||||
|
if (cmd.startsWith(args[2]))
|
||||||
|
list.add(cmd);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
package me.youhavetrouble.commandwhitelist.common.commands;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public interface CWCommandInterface {
|
||||||
|
|
||||||
|
void execute(String[] args);
|
||||||
|
|
||||||
|
Collection<String> tabComplete(String[] args);
|
||||||
|
|
||||||
|
String getPermission();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
groups:
|
||||||
|
default:
|
||||||
|
commands:
|
||||||
|
- "spawn"
|
||||||
|
- "help version"
|
||||||
+10
-8
@@ -1,12 +1,14 @@
|
|||||||
name: CommandWhitelist
|
name: "${project.name}"
|
||||||
prefix: CommandWhitelist
|
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
main: eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit
|
main: "${project.groupId}.bukkit.CommandWhitelistBukkit"
|
||||||
authors: [YouHaveTrouble]
|
authors:
|
||||||
|
- "YouHaveTrouble"
|
||||||
|
website: "${project.url}"
|
||||||
|
folia-supported: true
|
||||||
softdepend:
|
softdepend:
|
||||||
- ProtocolLib
|
- ProtocolLib
|
||||||
description: Control what commands players can use
|
description: "${project.description}"
|
||||||
commands:
|
commands:
|
||||||
commandwhitelist:
|
commandwhitelist:
|
||||||
aliases:
|
aliases:
|
||||||
@@ -14,8 +16,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
|
||||||
Reference in New Issue
Block a user