mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-15 13:26:00 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b524ff0701 | ||
|
|
b5bffb6731 | ||
|
|
cf84c608a6 | ||
|
|
e61ea7c8b3 | ||
|
|
a63df948d7 | ||
|
|
509bad85c2 | ||
|
|
ef48117ab4 | ||
|
|
08724d4fa8 | ||
|
|
59e5c15c0f | ||
|
|
e96572b62b | ||
|
|
441eb3f439 | ||
|
|
479beb17de | ||
|
|
92939ba2fd | ||
|
|
4b4ba32191 | ||
|
|
2ba002d508 | ||
|
|
594f8a25da | ||
|
|
3ad852e1c8 | ||
|
|
b3a66eebee | ||
|
|
5baad90145 | ||
|
|
2ceb0b6219 |
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>de.rayzs.pat</groupId>
|
||||
<artifactId>ProAntiTab</artifactId>
|
||||
<version>2.0.19</version>
|
||||
<version>2.0.21</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
||||
@@ -10,11 +10,13 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
|
||||
import com.mojang.brigadier.tree.RootCommandNode;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.utils.node.CommandNodeHelper;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
@@ -41,8 +43,6 @@ public class BungeePacketAnalyzer {
|
||||
private static final HashMap<ProxiedPlayer, Boolean> PLAYER_MODIFIED = new HashMap<>();
|
||||
private static final HashMap<ProxiedPlayer, String> PLAYER_INPUT_CACHE = new HashMap<>();
|
||||
|
||||
private static final com.mojang.brigadier.Command DUMMY_COMMAND = (context) -> 0;
|
||||
|
||||
private static final List<String> PLUGIN_COMMANDS = new ArrayList<>();
|
||||
|
||||
private static Class<?> channelWrapperClass, serverConnectionClass;
|
||||
@@ -50,6 +50,7 @@ public class BungeePacketAnalyzer {
|
||||
private static List<String> PROXY_COMMANDS;
|
||||
|
||||
static {
|
||||
CommandNodeHelper.setDefaultSuggestionProvider(Commands.SuggestionRegistry.ASK_SERVER);
|
||||
loadProxyCommands();
|
||||
}
|
||||
|
||||
@@ -156,9 +157,18 @@ public class BungeePacketAnalyzer {
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
|
||||
boolean bypassPermissions = PermissionUtil.hasBypassPermission(player.getUniqueId());
|
||||
|
||||
helper.removeIf(str -> !playerCommands.contains(str));
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.ALWAYS_TAB_COMPLETABLE && !bypassPermissions) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.ALWAYS_TAB_COMPLETABLE && !bypassPermissions) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Command> command : ProxyServer.getInstance().getPluginManager().getCommands()) {
|
||||
|
||||
if (ProxyServer.getInstance().getDisabledCommands().contains(command.getKey()))
|
||||
@@ -174,28 +184,30 @@ public class BungeePacketAnalyzer {
|
||||
String commandName = command.getKey();
|
||||
commandName = commandName.startsWith("/") ? commandName.substring(1) : commandName;
|
||||
|
||||
if (!playerCommands.contains(commandName)) {
|
||||
boolean tabablePluginCommand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(commandName);
|
||||
boolean tabableVersionCommand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(commandName);
|
||||
|
||||
if (!tabablePluginCommand && !tabableVersionCommand && !playerCommands.contains(commandName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CommandNode dummy = createDummyCommandNode(command.getKey());
|
||||
CommandNode dummy = CommandNodeHelper.createDummyCommandNode(command.getKey());
|
||||
commands.getRoot().addChild(dummy);
|
||||
}
|
||||
|
||||
// Disabled temporarily
|
||||
// PROXY_COMMANDS.stream().filter(playerCommands::contains).forEach(helper::add);
|
||||
// SubArgsModule.handleCommandNode(player.getUniqueId(), helper);
|
||||
|
||||
PROXY_COMMANDS.stream().filter(playerCommands::contains).forEach(input -> helper.add(input, true));
|
||||
SubArgsModule.handleCommandNode(player.getUniqueId(), helper);
|
||||
}
|
||||
|
||||
private static CommandNode createDummyCommandNode(String command) {
|
||||
return LiteralArgumentBuilder
|
||||
.literal(command)
|
||||
.executes(DUMMY_COMMAND)
|
||||
.then(RequiredArgumentBuilder
|
||||
.argument("args", (ArgumentType) StringArgumentType.greedyString())
|
||||
.suggests(Commands.SuggestionRegistry.ASK_SERVER)
|
||||
.executes(DUMMY_COMMAND))
|
||||
.build();
|
||||
public static void sendCommandsPacket() {
|
||||
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
|
||||
RootCommandNode root = new RootCommandNode();
|
||||
Commands packet = new Commands(root);
|
||||
|
||||
modifyCommands(player, packet);
|
||||
player.unsafe().sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
private static class PacketDecoder extends MessageToMessageDecoder<PacketWrapper> {
|
||||
@@ -247,7 +259,7 @@ public class BungeePacketAnalyzer {
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(player, StringUtils.replaceFirst(playerInput, "/", ""), server);
|
||||
|
||||
if (!cancelsBeforeHand)
|
||||
cancelsBeforeHand = !Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
cancelsBeforeHand = !Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
}
|
||||
|
||||
final String cursor = playerInput;
|
||||
|
||||
@@ -222,6 +222,10 @@ public class VelocityPacketAnalyzer {
|
||||
String command = offer.getText();
|
||||
if (command.startsWith("/")) command = StringUtils.replaceFirst(command, "/", "");
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !Storage.Blacklist.canPlayerAccessTab(player, command, player.getCurrentServer().get().getServerInfo().getName());
|
||||
});
|
||||
} else {
|
||||
@@ -237,6 +241,7 @@ public class VelocityPacketAnalyzer {
|
||||
}
|
||||
|
||||
response.getOffers().removeIf(offer -> !filteredTabCompletionEvent.getCompletion().contains(offer.getText()));
|
||||
|
||||
if (response.getOffers().isEmpty()) return;
|
||||
}
|
||||
}
|
||||
@@ -280,6 +285,10 @@ public class VelocityPacketAnalyzer {
|
||||
if (command.getName().equals("args"))
|
||||
return false;
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command.getName()) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command.getName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !playerCommands.contains(command.getName());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.api.storage.config.settings.*;
|
||||
import de.rayzs.pat.plugin.listeners.bukkit.BukkitAntiTabListener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
@@ -212,9 +213,15 @@ public class Storage {
|
||||
|
||||
Storage.getLoader().updateCommandCache();
|
||||
Communicator.sendPermissionReset();
|
||||
|
||||
if (!Reflection.isVelocityServer()) {
|
||||
BungeePacketAnalyzer.sendCommandsPacket();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
getLoader().handleReload();
|
||||
PermissionUtil.reloadPermissions();
|
||||
|
||||
if (Reflection.getMinor() < 13) {
|
||||
|
||||
@@ -421,13 +421,8 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
List<String> allowedCommands = new ArrayList<>(result).stream().filter(command -> {
|
||||
|
||||
if (turn) {
|
||||
return Storage.Blacklist.getBlacklist().isListed(command);
|
||||
} else {
|
||||
return !Storage.Blacklist.getBlacklist().isListed(command);
|
||||
}
|
||||
|
||||
boolean contains = Storage.Blacklist.getBlacklist().getCommands().contains(command);
|
||||
return turn == contains;
|
||||
}).toList();
|
||||
|
||||
lastCommandsLoad = System.currentTimeMillis();
|
||||
|
||||
@@ -37,7 +37,7 @@ import java.util.*;
|
||||
|
||||
@Plugin(name = "ProAntiTab",
|
||||
id = "proantitab",
|
||||
version = "2.0.19",
|
||||
version = "2.0.21",
|
||||
authors = "Rayzs_YT",
|
||||
description = "Hide more than just your plugins. Hide almost everything!",
|
||||
url = "https://www.rayzs.de/products/proantitab/page",
|
||||
|
||||
@@ -16,14 +16,26 @@ import java.util.*;
|
||||
public class BukkitAntiTabListener implements Listener {
|
||||
|
||||
private static final CommandsCache COMMANDS_CACHE = new CommandsCache();
|
||||
private static final List<UUID> knownOperators = new ArrayList<>();
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandSend(PlayerCommandSendEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
UUID uuid = player.getUniqueId();
|
||||
String uuidSubstring = uuid.toString().substring(uuid.toString().length() - 5);
|
||||
final Player player = event.getPlayer();
|
||||
final UUID uuid = player.getUniqueId();
|
||||
|
||||
final boolean noPermissionsPlugin = !Storage.USE_LUCKPERMS && !Storage.USE_GROUPMANAGER;
|
||||
|
||||
|
||||
if (Storage.USE_VELOCITY) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.isOp()) {
|
||||
|
||||
if (noPermissionsPlugin && !knownOperators.contains(uuid)) {
|
||||
knownOperators.add(uuid);
|
||||
}
|
||||
|
||||
if (Storage.USE_VELOCITY || player.isOp()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,7 +55,14 @@ public class BukkitAntiTabListener implements Listener {
|
||||
COMMANDS_CACHE.handleCommands(allCommands);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player)) {
|
||||
return;
|
||||
|
||||
if (noPermissionsPlugin && knownOperators.contains(uuid)) {
|
||||
PermissionUtil.reloadPermissions(uuid);
|
||||
knownOperators.remove(uuid);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final List<String> playerCommands = COMMANDS_CACHE.getPlayerCommands(new ArrayList<>(event.getCommands()), player, player.getUniqueId());
|
||||
@@ -51,10 +70,19 @@ public class BukkitAntiTabListener implements Listener {
|
||||
|
||||
event.getCommands().clear();
|
||||
|
||||
if (filteredSuggestionEvent.isCancelled())
|
||||
if (filteredSuggestionEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.getCommands().addAll(filteredSuggestionEvent.getSuggestions());
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.ALWAYS_TAB_COMPLETABLE) {
|
||||
event.getCommands().addAll(Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines());
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.ALWAYS_TAB_COMPLETABLE) {
|
||||
event.getCommands().addAll(Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines());
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getCommands() {
|
||||
|
||||
@@ -36,32 +36,13 @@ public class BungeeAntiTabListener implements Listener {
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player, cursor, event.getSuggestions());
|
||||
List<String> suggestions = filteredTabCompletionEvent.getCompletion();
|
||||
|
||||
event.getSuggestions().removeIf(suggestion -> !suggestions.contains(suggestion));
|
||||
}
|
||||
event.getSuggestions().removeIf(suggestion -> {
|
||||
|
||||
@EventHandler
|
||||
public void onTabComplete(TabCompleteResponseEvent event) {
|
||||
// Ignoring this at first, due to transfer to the packet-based solution only. Hehe
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(suggestion) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(suggestion)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
if (!(event.getSender() instanceof ProxiedPlayer))
|
||||
return;
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
|
||||
|
||||
ServerInfo serverInfo = player.getServer().getInfo();
|
||||
String serverName = serverInfo.getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName))
|
||||
return;
|
||||
|
||||
if(PermissionUtil.hasBypassPermission(player))
|
||||
return;
|
||||
|
||||
event.getSuggestions().removeIf(command -> !Storage.Blacklist.canPlayerAccessTab(player, command, serverName));
|
||||
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, event.getSuggestions());
|
||||
if (filteredSuggestionEvent.isCancelled()) event.getSuggestions().clear();
|
||||
*/
|
||||
return !suggestions.contains(suggestion);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -21,9 +21,6 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onProxyDefineCommands(ProxyDefineCommandsEvent event) {
|
||||
|
||||
System.out.println("CALL");
|
||||
|
||||
if(!(event.getReceiver() instanceof ProxiedPlayer) || event.getCommands().isEmpty()) return;
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
@@ -44,13 +41,20 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
event.getCommands().forEach((key, value) -> commandsAsString.add(key));
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
if(PermissionUtil.hasBypassPermission(player)) return;
|
||||
if (PermissionUtil.hasBypassPermission(player)) return;
|
||||
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
|
||||
event.getCommands().entrySet().removeIf(command -> playerCommands.contains(command.getKey()));
|
||||
event.getCommands().entrySet().removeIf(command -> {
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command.getKey()) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command.getKey())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return playerCommands.contains(command.getKey());
|
||||
});
|
||||
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, new ArrayList<>(event.getCommands().keySet()));
|
||||
if(filteredSuggestionEvent.isCancelled()) event.getCommands().clear();
|
||||
if (filteredSuggestionEvent.isCancelled()) event.getCommands().clear();
|
||||
|
||||
for (String commandName : filteredSuggestionEvent.getSuggestions()) {
|
||||
|
||||
|
||||
@@ -36,7 +36,14 @@ public class VelocityAntiTabListener {
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player) || event.getSuggestions().isEmpty() || !player.getCurrentServer().isPresent()) return;
|
||||
|
||||
event.getSuggestions().removeIf(command -> !Storage.Blacklist.canPlayerAccessTab(player, command, serverName));
|
||||
event.getSuggestions().removeIf(command -> {
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !Storage.Blacklist.canPlayerAccessTab(player, command, serverName);
|
||||
});
|
||||
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, event.getSuggestions());
|
||||
if(filteredSuggestionEvent.isCancelled()) event.getSuggestions().clear();
|
||||
}
|
||||
@@ -88,6 +95,10 @@ public class VelocityAntiTabListener {
|
||||
if (command.getName().equals("args"))
|
||||
return false;
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command.getName()) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command.getName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !playerCommands.contains(command.getName());
|
||||
});
|
||||
} catch (Exception exception) {
|
||||
|
||||
@@ -108,6 +108,12 @@ public class Logger {
|
||||
.append(Storage.USE_LUCKPERMS)
|
||||
.append("\n");
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
builder.append(" GroupManager: ")
|
||||
.append(Storage.USE_GROUPMANAGER)
|
||||
.append("\n");
|
||||
}
|
||||
|
||||
builder.append(" PlaceholderAPI: ")
|
||||
.append(Storage.USE_PLACEHOLDERAPI)
|
||||
.append("\n");
|
||||
|
||||
@@ -72,11 +72,11 @@ public class SubArgsModule {
|
||||
ArgumentSource source = arguments.TAB_ARGUMENTS;
|
||||
if (source == null) return;
|
||||
|
||||
List<String> inputs = source.getAllInputs().stream().filter(str -> !str.contains("%")).toList();
|
||||
List<String> inputs = source.getAllInputs();
|
||||
List<String> allEntries = inputs.stream().map(StringUtils::getFirstArg).toList();
|
||||
|
||||
helper.removeIf(allEntries::contains);
|
||||
inputs.forEach(helper::add);
|
||||
inputs.forEach(input -> helper.add(input, true));
|
||||
}
|
||||
|
||||
public static List<String> getServerCommands(UUID uuid) {
|
||||
|
||||
@@ -85,7 +85,7 @@ public class CommandsCache {
|
||||
String command = filteredCommands.get(i);
|
||||
filteredCommands.add(command);
|
||||
} catch (ArrayIndexOutOfBoundsException outOfBoundsException) {
|
||||
System.out.println("Array is out of bounds " + i + "/" + max + "! " + outOfBoundsException.getMessage());
|
||||
Logger.warning("Array is out of bounds " + i + "/" + max + "! " + outOfBoundsException.getMessage());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,48 @@
|
||||
package de.rayzs.pat.utils.node;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
import com.mojang.brigadier.suggestion.SuggestionProvider;
|
||||
import com.mojang.brigadier.tree.*;
|
||||
import net.md_5.bungee.protocol.packet.Commands;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandNodeHelper<T> {
|
||||
|
||||
private static final Command DUMMY_COMMAND = (context) -> 0;
|
||||
private static SuggestionProvider DEFAULT_SUGGESTION_PROVIDER;
|
||||
|
||||
public static void setDefaultSuggestionProvider(SuggestionProvider<?> suggestionProvider) {
|
||||
DEFAULT_SUGGESTION_PROVIDER = suggestionProvider;
|
||||
}
|
||||
|
||||
public static CommandNode createDummyCommandNode(String command) {
|
||||
return LiteralArgumentBuilder
|
||||
.literal(command)
|
||||
.executes(DUMMY_COMMAND)
|
||||
.then(RequiredArgumentBuilder
|
||||
.argument("args", (ArgumentType) StringArgumentType.greedyString())
|
||||
.suggests(DEFAULT_SUGGESTION_PROVIDER)
|
||||
.executes(DUMMY_COMMAND))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandNode createEmptyDummyCommandNode(String command) {
|
||||
return LiteralArgumentBuilder
|
||||
.literal(command)
|
||||
.executes(DUMMY_COMMAND)
|
||||
.then(RequiredArgumentBuilder
|
||||
.argument("args", (ArgumentType) StringArgumentType.greedyString())
|
||||
.executes(DUMMY_COMMAND))
|
||||
.build();
|
||||
}
|
||||
|
||||
private final RootCommandNode<T> rootNode;
|
||||
|
||||
public CommandNodeHelper(RootCommandNode<T> rootNode) {
|
||||
@@ -76,27 +111,52 @@ public class CommandNodeHelper<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandNodeHelper<T> add(String commandPath) {
|
||||
if (commandPath.endsWith("_-"))
|
||||
commandPath = commandPath.substring(0, commandPath.length() - 3);
|
||||
|
||||
public CommandNodeHelper<T> add(String commandPath, boolean autoSuggestions) {
|
||||
String[] args = commandPath.split(" ");
|
||||
add(rootNode, args, 0);
|
||||
add(rootNode, args, 0, autoSuggestions);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void add(CommandNode<T> parent, String[] args, int index) {
|
||||
private void add(CommandNode<T> parent, String[] args, int index, boolean autoSuggestions) {
|
||||
if (index >= args.length) return;
|
||||
|
||||
String part = args[index];
|
||||
String next = index + 1 >= args.length ? null : args[index + 1];
|
||||
CommandNode<T> childNode = parent.getChild(part);
|
||||
|
||||
if (childNode == null) {
|
||||
LiteralCommandNode<T> newNode = LiteralArgumentBuilder.<T>literal(part).build();
|
||||
LiteralCommandNode newNode;
|
||||
|
||||
boolean cancel = next != null && (next.equals("_-"));
|
||||
boolean stop = next != null && next.startsWith("%") && next.endsWith("%");
|
||||
boolean skip = part.equals("-_");
|
||||
|
||||
if (skip) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!autoSuggestions || cancel || !stop && index != args.length - 1) {
|
||||
newNode = LiteralArgumentBuilder.literal(part)
|
||||
.then(RequiredArgumentBuilder
|
||||
.argument("args", StringArgumentType.string()))
|
||||
.build();
|
||||
} else {
|
||||
newNode = LiteralArgumentBuilder.literal(part)
|
||||
.then(RequiredArgumentBuilder
|
||||
.argument("args", (ArgumentType) StringArgumentType.greedyString())
|
||||
.suggests(Commands.SuggestionRegistry.ASK_SERVER))
|
||||
.build();
|
||||
}
|
||||
|
||||
parent.addChild(newNode);
|
||||
|
||||
if (stop || cancel) {
|
||||
return;
|
||||
}
|
||||
|
||||
childNode = newNode;
|
||||
}
|
||||
|
||||
add(childNode, args, index + 1);
|
||||
add(childNode, args, index + 1, autoSuggestions);
|
||||
}
|
||||
}
|
||||
@@ -25,50 +25,56 @@ public class ResponseHandler {
|
||||
}
|
||||
|
||||
public static String replaceArgsVariables(String input, String command) {
|
||||
if (!input.contains(" "))
|
||||
return input;
|
||||
final String[] commandSplit = command.contains(" ") ? command.split(" ") : new String[] { command };
|
||||
final String[] inputSplit = input.contains(" ") ? input.split(" ") : new String[] { input };
|
||||
|
||||
String[] commandSplit = command.contains(" ") ? command.split(" ") : new String[]{command};
|
||||
String[] split = input.split(" ");
|
||||
final StringBuilder output = new StringBuilder();
|
||||
final int commandLength = commandSplit.length;
|
||||
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
String part = split[i];
|
||||
for (int i = 0; i < inputSplit.length; i++) {
|
||||
String part = inputSplit[i];
|
||||
|
||||
if (! (part.startsWith("%args[") && part.endsWith("]%")))
|
||||
if (i > 0) {
|
||||
output.append(" ");
|
||||
}
|
||||
|
||||
if (! (part.startsWith("%args[") && part.endsWith("]%"))) {
|
||||
output.append(part);
|
||||
continue;
|
||||
}
|
||||
|
||||
part = part.substring(part.indexOf('[') + 1, part.lastIndexOf(']'));
|
||||
|
||||
int length = commandSplit.length, fromIndex, toIndex;
|
||||
int fromIndex, toIndex;
|
||||
|
||||
if (part.contains("-")) {
|
||||
String[] indexSplit = part.split("-");
|
||||
try {
|
||||
if (part.contains("-")) {
|
||||
final String[] partSplit = part.split("-");
|
||||
fromIndex = Integer.parseInt(partSplit[0]);
|
||||
toIndex = Integer.parseInt(partSplit[1]);
|
||||
} else if (part.startsWith("_")) {
|
||||
final String[] partSplit = part.split("_");
|
||||
fromIndex = 0;
|
||||
toIndex = Integer.parseInt(partSplit[1]);
|
||||
} else if (part.endsWith("_")) {
|
||||
final String[] partSplit = part.split("_");
|
||||
fromIndex = Integer.parseInt(partSplit[0]);
|
||||
toIndex = commandLength + 1;
|
||||
} else {
|
||||
fromIndex = Integer.parseInt(part);
|
||||
toIndex = fromIndex;
|
||||
}
|
||||
|
||||
fromIndex = Integer.parseInt(indexSplit[0]) - 1;
|
||||
toIndex = Integer.parseInt(indexSplit[1]);
|
||||
} else {
|
||||
fromIndex = Integer.parseInt(part);
|
||||
toIndex = fromIndex;
|
||||
fromIndex = Math.max(0, fromIndex - 1);
|
||||
toIndex = Math.min(commandLength, toIndex);
|
||||
|
||||
output.append(String.join(" ", Arrays.copyOfRange(commandSplit, fromIndex, toIndex)));
|
||||
} catch (NumberFormatException exception) {
|
||||
Logger.warning("Failed to convert number! (" + part + ")");
|
||||
}
|
||||
|
||||
if (fromIndex < 0 || toIndex > length) {
|
||||
Logger.warning("Custom response contains an error! (" + input + ")");
|
||||
Logger.warning("Out of bounds! (Input: " + input + ", Possible: " + (length > 1 ? "1-" : "") + length + ")");
|
||||
continue;
|
||||
}
|
||||
|
||||
String replacement;
|
||||
|
||||
if (fromIndex == toIndex) {
|
||||
replacement = commandSplit[fromIndex - 1];
|
||||
} else {
|
||||
replacement = String.join(" ", Arrays.copyOfRange(commandSplit, fromIndex, toIndex));;
|
||||
}
|
||||
|
||||
split[i] = replacement;
|
||||
}
|
||||
|
||||
return String.join(" ", split);
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
public static List<String> getResponse(UUID uuid, String input) {
|
||||
|
||||
@@ -3,7 +3,7 @@ description: Hide more than just your plugins. Hide almost everything!
|
||||
website: https://www.rayzs.de/products/proantitab/page
|
||||
|
||||
author: Rayzs_YT
|
||||
version: 2.0.19
|
||||
version: 2.0.21
|
||||
main: de.rayzs.pat.plugin.BungeeLoader
|
||||
|
||||
softDepends: [LuckPerms, PAPIProxyBridge]
|
||||
@@ -35,11 +35,21 @@
|
||||
# Possible variable:
|
||||
# %args[from-to]% to get the command arguments
|
||||
# Example if you've typed: /shop open gui user
|
||||
# A:
|
||||
# %args[1]% = shop
|
||||
# %args[2]% = open
|
||||
# A-B:
|
||||
# %args[1-2]% = shop open
|
||||
# %args[1-3]% = shop open gui
|
||||
# %args[2-4]% = open gui user
|
||||
# A_:
|
||||
# %args[1_]% = shop open gui user
|
||||
# %args[2_]% = open gui user
|
||||
# %args[3_]% = gui user
|
||||
# _B:
|
||||
# %args[_1]% = shop
|
||||
# %args[_2]% = shop open
|
||||
# %args[_3]% = shop open gui
|
||||
|
||||
# Here are a few examples:
|
||||
|
||||
|
||||
@@ -29,11 +29,21 @@
|
||||
# Possible variable:
|
||||
# %args[from-to]% to get the command arguments
|
||||
# Example if you've typed: /shop open gui user
|
||||
# A:
|
||||
# %args[1]% = shop
|
||||
# %args[2]% = open
|
||||
# A-B:
|
||||
# %args[1-2]% = shop open
|
||||
# %args[1-3]% = shop open gui
|
||||
# %args[2-4]% = open gui user
|
||||
# A_:
|
||||
# %args[1_]% = shop open gui user
|
||||
# %args[2_]% = open gui user
|
||||
# %args[3_]% = gui user
|
||||
# _B:
|
||||
# %args[_1]% = shop
|
||||
# %args[_2]% = shop open
|
||||
# %args[_3]% = shop open gui
|
||||
|
||||
# Here are a few examples:
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ description: Hide more than just your plugins. Hide almost everything!
|
||||
website: https://www.rayzs.de/products/proantitab/page
|
||||
|
||||
author: Rayzs_YT
|
||||
version: 2.0.19
|
||||
version: 2.0.21
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
main: de.rayzs.pat.plugin.BukkitLoader
|
||||
|
||||
Reference in new issue
Block a user