forked from upstream/ProAntiTab
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fc23712e4 | ||
|
|
6b9c717ec4 | ||
|
|
0c3e82c01e | ||
|
|
8e6e544b60 | ||
|
|
a4196fc118 | ||
|
|
d5a9b99a7a | ||
|
|
6d850f9f07 | ||
|
|
c4987b7c5e | ||
|
|
3880738ed9 | ||
|
|
68c00b843b | ||
|
|
dc352275b6 | ||
|
|
b3362987e5 | ||
|
|
fb3ec45059 | ||
|
|
5100b4a852 | ||
|
|
e9ec801dc5 | ||
|
|
70c31b8597 | ||
|
|
a078de1fc3 | ||
|
|
a1d759451c | ||
|
|
8a9373963c | ||
|
|
d964d5b859 | ||
|
|
b468865041 | ||
|
|
d6fec721ad | ||
|
|
9256398fa2 | ||
|
|
4fed08a8f9 | ||
|
|
b650156e57 | ||
|
|
4737d15be5 | ||
|
|
aca6dd7e1d | ||
|
|
5aa0d000dd | ||
|
|
e2b238fb81 | ||
|
|
ebdb3edbc1 | ||
|
|
b9f4e46d65 | ||
|
|
287ebd4e9c | ||
|
|
befdc3de6a | ||
|
|
55d00876a7 | ||
|
|
be0ee15448 | ||
|
|
7f91b85d6e | ||
|
|
80beacaef9 | ||
|
|
9f0521f9de | ||
|
|
3e1fffcfbb | ||
|
|
c0e77efad6 | ||
|
|
490f6f420b | ||
|
|
228185291d | ||
|
|
ab17861e7c | ||
|
|
567ca5192c | ||
|
|
442a0797a2 | ||
|
|
c1be977abd | ||
|
|
a6f670dcfb | ||
|
|
1d3e72aae2 | ||
|
|
513fce2059 | ||
|
|
6247aee871 | ||
|
|
fc0e230ca5 | ||
|
|
d2972f602f | ||
|
|
0f3b858a75 | ||
|
|
70b449e83d | ||
|
|
2a58b6644e | ||
|
|
96f4386f7a | ||
|
|
3e9de4e859 | ||
|
|
dad2db500c | ||
|
|
9bd33477b1 | ||
|
|
01c680b69a | ||
|
|
d20c3c2820 | ||
|
|
dcb73b1672 | ||
|
|
389f006d02 | ||
|
|
0266a6c5f9 | ||
|
|
9b53123e92 | ||
|
|
9e21110011 | ||
|
|
5377c67614 | ||
|
|
32f8c61d43 | ||
|
|
2a16db32ba |
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>de.rayzs.pat</groupId>
|
||||
<artifactId>ProAntiTab</artifactId>
|
||||
<version>2.1.0</version>
|
||||
<version>2.2.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
@@ -291,6 +291,16 @@
|
||||
|
||||
<build>
|
||||
<finalName>IgnoreThisJar</finalName>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<excludes>
|
||||
<exclude>*.txt</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
||||
@@ -42,7 +42,7 @@ public class BukkitPacketAnalyzer {
|
||||
}
|
||||
|
||||
public static boolean inject(Player player) {
|
||||
if (Storage.USE_VELOCITY)
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
return true;
|
||||
|
||||
try {
|
||||
@@ -81,7 +81,7 @@ public class BukkitPacketAnalyzer {
|
||||
}
|
||||
|
||||
public static void uninject(UUID uuid) {
|
||||
if (Storage.USE_VELOCITY)
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
return;
|
||||
|
||||
if (BukkitPacketAnalyzer.INJECTED_PLAYERS.containsKey(uuid)) {
|
||||
@@ -91,7 +91,7 @@ public class BukkitPacketAnalyzer {
|
||||
}
|
||||
|
||||
public static void uninject(Channel channel) {
|
||||
if (Storage.USE_VELOCITY)
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
return;
|
||||
|
||||
if (channel != null) {
|
||||
@@ -124,22 +124,25 @@ public class BukkitPacketAnalyzer {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext channel, Object packetObj) {
|
||||
try {
|
||||
if (packetObj.getClass() != null) {
|
||||
String packetName = packetObj.getClass().getSimpleName();
|
||||
|
||||
if (!packetName.equals("PacketPlayInTabComplete") && !packetName.equals("ServerboundCommandSuggestionPacket")) {
|
||||
super.channelRead(channel, packetObj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
|
||||
if (!PACKET_HANDLER.handleIncomingPacket(player, packetObj))
|
||||
return;
|
||||
|
||||
}
|
||||
if (packetObj.getClass() == null || Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
super.channelRead(channel, packetObj);
|
||||
return;
|
||||
}
|
||||
|
||||
String packetName = packetObj.getClass().getSimpleName();
|
||||
|
||||
if (!packetName.equals("PacketPlayInTabComplete") && !packetName.equals("ServerboundCommandSuggestionPacket")) {
|
||||
super.channelRead(channel, packetObj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
|
||||
if (!PACKET_HANDLER.handleIncomingPacket(player, packetObj))
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
super.channelRead(channel, packetObj);
|
||||
} catch (Throwable exception) { exception.printStackTrace(); }
|
||||
}
|
||||
@@ -148,30 +151,33 @@ public class BukkitPacketAnalyzer {
|
||||
public void write(ChannelHandlerContext channel, Object packetObj, ChannelPromise promise) {
|
||||
try {
|
||||
|
||||
if(packetObj.getClass() != null) {
|
||||
String packetName = packetObj.getClass().getSimpleName();
|
||||
if(packetObj.getClass() == null || Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
super.write(channel, packetObj, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!packetName.equals("PacketPlayOutTabComplete") && !packetName.equals("ClientboundCommandSuggestionsPacket")) {
|
||||
super.write(channel, packetObj, promise);
|
||||
return;
|
||||
}
|
||||
String packetName = packetObj.getClass().getSimpleName();
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
if (!packetName.equals("PacketPlayOutTabComplete") && !packetName.equals("ClientboundCommandSuggestionsPacket")) {
|
||||
super.write(channel, packetObj, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
Object sentPacketObj = SENT_PACKET.get(uuid);
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
|
||||
if (sentPacketObj != null) {
|
||||
if (sentPacketObj == packetObj) {
|
||||
SENT_PACKET.remove(uuid);
|
||||
super.write(channel, sentPacketObj, promise);
|
||||
return;
|
||||
}
|
||||
}
|
||||
UUID uuid = player.getUniqueId();
|
||||
Object sentPacketObj = SENT_PACKET.get(uuid);
|
||||
|
||||
if (!PACKET_HANDLER.handleOutgoingPacket(player, packetObj))
|
||||
if (sentPacketObj != null) {
|
||||
if (sentPacketObj == packetObj) {
|
||||
SENT_PACKET.remove(uuid);
|
||||
super.write(channel, sentPacketObj, promise);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!PACKET_HANDLER.handleOutgoingPacket(player, packetObj))
|
||||
return;
|
||||
}
|
||||
|
||||
super.write(channel, packetObj, promise);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
}
|
||||
|
||||
if (!cancelsBeforeHand) {
|
||||
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(input) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(input);
|
||||
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(input) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input);
|
||||
}
|
||||
|
||||
for (Field field : Reflection.getFields(packetObj)) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package de.rayzs.pat.api.netty.proxy;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
@@ -18,6 +19,7 @@ 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.ExpireCache;
|
||||
import de.rayzs.pat.utils.node.CommandNodeHelper;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
@@ -33,6 +35,7 @@ import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import net.md_5.bungee.protocol.packet.Commands;
|
||||
import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
||||
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||
|
||||
public class BungeePacketAnalyzer {
|
||||
@@ -41,7 +44,7 @@ public class BungeePacketAnalyzer {
|
||||
|
||||
private static final String HANDLER_NAME = "pat-bungee-handler", PIPELINE_NAME = "packet-decoder";
|
||||
private static final HashMap<ProxiedPlayer, Boolean> PLAYER_MODIFIED = new HashMap<>();
|
||||
private static final HashMap<ProxiedPlayer, String> PLAYER_INPUT_CACHE = new HashMap<>();
|
||||
private static final ExpireCache<UUID, String> PLAYER_INPUT_CACHE = new ExpireCache<>(5, TimeUnit.SECONDS);
|
||||
|
||||
private static final List<String> PLUGIN_COMMANDS = new ArrayList<>();
|
||||
|
||||
@@ -115,7 +118,7 @@ public class BungeePacketAnalyzer {
|
||||
}
|
||||
|
||||
public static void uninject(ProxiedPlayer player) {
|
||||
BungeePacketAnalyzer.PLAYER_INPUT_CACHE.remove(player);
|
||||
BungeePacketAnalyzer.PLAYER_INPUT_CACHE.remove(player.getUniqueId());
|
||||
BungeePacketAnalyzer.PLAYER_MODIFIED.remove(player);
|
||||
|
||||
if(BungeePacketAnalyzer.INJECTED_PLAYERS.containsKey(player)) {
|
||||
@@ -132,43 +135,51 @@ public class BungeePacketAnalyzer {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setPlayerInput(ProxiedPlayer player, String input) {
|
||||
PLAYER_INPUT_CACHE.putIgnoreIfContains(player.getUniqueId(), input);
|
||||
}
|
||||
|
||||
public static String getPlayerInput(ProxiedPlayer player) {
|
||||
String input = PLAYER_INPUT_CACHE.get(player);
|
||||
PLAYER_INPUT_CACHE.remove(player);
|
||||
String input = PLAYER_INPUT_CACHE.get(player.getUniqueId());
|
||||
PLAYER_INPUT_CACHE.remove(player.getUniqueId());
|
||||
return input;
|
||||
}
|
||||
|
||||
private static void modifyCommands(ProxiedPlayer player, Commands commands) {
|
||||
if (PermissionUtil.hasBypassPermission(player))
|
||||
return;
|
||||
|
||||
ServerInfo serverInfo = player.getServer().getInfo();
|
||||
String serverName = serverInfo.getName();
|
||||
|
||||
final boolean ignore = PermissionUtil.hasBypassPermission(player) || Storage.Blacklist.isDisabledServer(serverName);
|
||||
|
||||
CommandNodeHelper helper = new CommandNodeHelper<CommandNode>(commands.getRoot());
|
||||
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
|
||||
if (!cache.containsKey(serverName))
|
||||
cache.put(serverName, new CommandsCache());
|
||||
|
||||
CommandsCache commandsCache = cache.get(serverName);
|
||||
|
||||
List<String> commandsAsString = new ArrayList<>(PROXY_COMMANDS);
|
||||
commandsAsString.addAll(helper.getChildrenNames());
|
||||
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
List<String> playerCommands = new ArrayList<>();
|
||||
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, serverName);
|
||||
if (!ignore) {
|
||||
|
||||
helper.removeIf(str -> !playerCommands.contains(str));
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
if (!cache.containsKey(serverName)) {
|
||||
cache.put(serverName, new CommandsCache());
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
CommandsCache commandsCache = cache.get(serverName);
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
List<String> tmpPlayerCommands = commandsCache.getPlayerCommands(commandsAsString, player, serverName);
|
||||
helper.removeIf(str -> !tmpPlayerCommands.contains(str));
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
|
||||
playerCommands = tmpPlayerCommands;
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Command> command : ProxyServer.getInstance().getPluginManager().getCommands()) {
|
||||
@@ -186,11 +197,13 @@ public class BungeePacketAnalyzer {
|
||||
String commandName = command.getKey();
|
||||
commandName = commandName.startsWith("/") ? commandName.substring(1) : commandName;
|
||||
|
||||
boolean tabablePluginCommand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(commandName);
|
||||
boolean tabableVersionCommand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(commandName);
|
||||
if (!ignore) {
|
||||
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;
|
||||
if (!tabablePluginCommand && !tabableVersionCommand && !playerCommands.contains(commandName)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
CommandNode dummy = CommandNodeHelper.createDummyCommandNode(command.getKey());
|
||||
@@ -198,12 +211,22 @@ public class BungeePacketAnalyzer {
|
||||
}
|
||||
|
||||
|
||||
PROXY_COMMANDS.stream().filter(playerCommands::contains).forEach(input -> helper.add(input, true));
|
||||
SubArgsModule.handleCommandNode(player.getUniqueId(), helper);
|
||||
for (String command : PROXY_COMMANDS) {
|
||||
if (ignore || playerCommands.contains(command)) {
|
||||
helper.add(command, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ignore) {
|
||||
SubArgsModule.handleCommandNode(player.getUniqueId(), helper);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendCommandsPacket() {
|
||||
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
|
||||
if (player.getPendingConnection().getVersion() < 754)
|
||||
continue;
|
||||
|
||||
RootCommandNode root = new RootCommandNode();
|
||||
Commands packet = new Commands(root);
|
||||
|
||||
@@ -227,7 +250,7 @@ public class BungeePacketAnalyzer {
|
||||
return;
|
||||
}
|
||||
|
||||
if(wrapper.packet instanceof PluginMessage) {
|
||||
if (wrapper.packet instanceof PluginMessage) {
|
||||
PluginMessage pluginMessage = (PluginMessage) wrapper.packet;
|
||||
if(CustomServerBrand.isEnabled() && CustomServerBrand.isBrandTag(pluginMessage.getTag()))
|
||||
return;
|
||||
@@ -239,24 +262,32 @@ public class BungeePacketAnalyzer {
|
||||
player.unsafe().sendPacket(response);
|
||||
return;
|
||||
|
||||
/*
|
||||
} else if (wrapper.packet instanceof TabCompleteResponse) {
|
||||
TabCompleteResponse response = (TabCompleteResponse) wrapper.packet;
|
||||
String serverName = player.getServer().getInfo().getName();
|
||||
|
||||
if(player.getPendingConnection().getVersion() < 754) {
|
||||
if(!PermissionUtil.hasBypassPermission(player)) {
|
||||
System.out.println("damn");
|
||||
|
||||
ClientInfo clientInfo = Communicator.getClientByName(player.getServer().getInfo().getName());
|
||||
if (clientInfo == null || !PLAYER_INPUT_CACHE.containsKey(player))
|
||||
if (!Storage.Blacklist.isDisabledServer(serverName) && player.getPendingConnection().getVersion() < 754) {
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
|
||||
System.out.println("Further!");
|
||||
System.out.println("Got: " + PLAYER_INPUT_CACHE.get(player.getUniqueId()));
|
||||
|
||||
if (!PLAYER_INPUT_CACHE.contains(player.getUniqueId()))
|
||||
return;
|
||||
|
||||
boolean cancelsBeforeHand = false;
|
||||
|
||||
String rawPlayerInput = getPlayerInput(player);
|
||||
String rawPlayerInput = PLAYER_INPUT_CACHE.get(player.getUniqueId());
|
||||
int spaces = rawPlayerInput.contains(" ") ? rawPlayerInput.split(" ").length : 0;
|
||||
|
||||
String playerInput = StringUtils.getFirstArg(rawPlayerInput),
|
||||
server = player.getServer().getInfo().getName();
|
||||
|
||||
System.out.println("NETTY -> " + playerInput);
|
||||
|
||||
if (!playerInput.equals("/")) {
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(player, StringUtils.replaceFirst(playerInput, "/", ""), server);
|
||||
|
||||
@@ -314,7 +345,7 @@ public class BungeePacketAnalyzer {
|
||||
player.unsafe().sendPacket(new TabCompleteResponse(response.getCommands()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
list.add(wrapper);
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package de.rayzs.pat.api.netty.proxy;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
@@ -73,20 +70,27 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
channel = (Channel) Reflection.getMethodsByName(minecraftConnectionClass, "getChannel").get(0).invoke(minecraftConnectionObj);
|
||||
|
||||
if(channel == null) {
|
||||
if (channel == null) {
|
||||
Logger.warning("Failed to inject " + player.getUsername() + "! Channel is null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(channel.pipeline().names().contains(VelocityPacketAnalyzer.PIPELINE_NAME))
|
||||
if (channel.pipeline().names().contains(VelocityPacketAnalyzer.PIPELINE_NAME))
|
||||
uninject(player);
|
||||
|
||||
channel.pipeline().addBefore(VelocityPacketAnalyzer.HANDLER_NAME, VelocityPacketAnalyzer.PIPELINE_NAME, new PacketDecoder(player));
|
||||
VelocityPacketAnalyzer.INJECTED_PLAYERS.put(player, channel);
|
||||
|
||||
} catch (NoSuchElementException e) {
|
||||
Logger.warning("Failed to find 'handler' inside player pipeline! (name=" + player.getUsername() + ", uuid=" + player.getUniqueId() + ", version=" + player.getProtocolVersion() + ", brand=" + player.getClientBrand() + " )");
|
||||
return false;
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
return false;
|
||||
} return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void uninject(Player player) {
|
||||
@@ -190,6 +194,13 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
} else if (packet instanceof TabCompleteResponsePacket) {
|
||||
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName)) {
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player) && player.getCurrentServer().isPresent()) {
|
||||
TabCompleteResponsePacket response = (TabCompleteResponsePacket) packet;
|
||||
|
||||
@@ -250,10 +261,17 @@ public class VelocityPacketAnalyzer {
|
||||
} else if (packet instanceof AvailableCommandsPacket) {
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player) && player.getCurrentServer().isPresent()) {
|
||||
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName)) {
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
AvailableCommandsPacket commands = (AvailableCommandsPacket) packet;
|
||||
|
||||
if(!commands.getRootNode().getChildren().isEmpty()) {
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
|
||||
if (!cache.containsKey(serverName))
|
||||
|
||||
@@ -3,12 +3,16 @@ package de.rayzs.pat.api.storage;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.api.storage.config.messages.*;
|
||||
import de.rayzs.pat.api.storage.config.settings.*;
|
||||
import de.rayzs.pat.plugin.listeners.bukkit.BukkitAntiTabListener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.utils.permission.PermissionPlugin;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -16,21 +20,6 @@ import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.blacklist.BlacklistCreator;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralIgnoredServers;
|
||||
import de.rayzs.pat.api.storage.config.messages.BlacklistSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.CommandFailedSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.GroupSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.HelpSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.InfoSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.NoPermissionSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.NotificationSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.OnlyForProxySection;
|
||||
import de.rayzs.pat.api.storage.config.messages.PermsCheckSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.PostDebugSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.PrefixSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.ReloadSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.ServerListSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.StatsSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.UpdatePermissionsSection;
|
||||
import de.rayzs.pat.api.storage.placeholders.commands.general.ListCommandsPlaceholder;
|
||||
import de.rayzs.pat.api.storage.placeholders.commands.general.ListReversedCommandsPlaceholder;
|
||||
import de.rayzs.pat.api.storage.placeholders.commands.general.ListSizeCommandsPlaceholder;
|
||||
@@ -119,6 +108,7 @@ public class Storage {
|
||||
}
|
||||
|
||||
public static void loadToken() {
|
||||
Files.TOKEN.reload();
|
||||
|
||||
boolean invalidEnv = false;
|
||||
|
||||
@@ -174,6 +164,30 @@ public class Storage {
|
||||
ConfigSections.PLACEHOLDERS.forEach(PlaceholderStorage::load);
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
boolean proxy = Reflection.isProxyServer();
|
||||
boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !proxy;
|
||||
|
||||
ConfigUpdater.initialize();
|
||||
Storage.loadAll(Reflection.isProxyServer() || !backend);
|
||||
|
||||
CustomServerBrand.initialize();
|
||||
GroupManager.clearAllGroups();
|
||||
GroupManager.initialize();
|
||||
|
||||
if (!proxy) {
|
||||
BackendUpdater.stop();
|
||||
BackendUpdater.start();
|
||||
}
|
||||
|
||||
if (!backend) {
|
||||
Storage.handleChange();
|
||||
}
|
||||
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
Storage.getLoader().handleReload();
|
||||
}
|
||||
|
||||
public static void handleChange() {
|
||||
handleChange(null);
|
||||
}
|
||||
@@ -327,6 +341,7 @@ public class Storage {
|
||||
|
||||
public static class Settings {
|
||||
|
||||
public static AllowGroupOverrulingSection ALLOW_GROUP_OVERRULING = new AllowGroupOverrulingSection();
|
||||
public static AutoLowercaseCommandsSection AUTO_LOWERCASE_COMMANDS = new AutoLowercaseCommandsSection();
|
||||
public static BlockNamespaceCommandsSection BLOCK_NAMESPACE_COMMANDS = new BlockNamespaceCommandsSection();
|
||||
public static HandleThroughProxySection HANDLE_THROUGH_PROXY = new HandleThroughProxySection();
|
||||
@@ -353,6 +368,8 @@ public class Storage {
|
||||
public static PrefixSection PREFIX = new PrefixSection();
|
||||
public static BlacklistSection BLACKLIST = new BlacklistSection();
|
||||
public static CommandFailedSection COMMAND_FAILED = new CommandFailedSection();
|
||||
public static ConvertSection CONVERT = new ConvertSection();
|
||||
public static ExtractSection EXTRACT = new ExtractSection();
|
||||
public static GroupSection GROUP = new GroupSection();
|
||||
public static HelpSection HELP = new HelpSection();
|
||||
public static InfoSection INFO = new InfoSection();
|
||||
@@ -562,7 +579,28 @@ public class Storage {
|
||||
}
|
||||
|
||||
public static boolean canPlayerAccess(Object player, String command, BlockType type, String server) {
|
||||
boolean blocked = isBlocked(command, type, server);
|
||||
final boolean allowGroupOverruling = ConfigSections.Settings.ALLOW_GROUP_OVERRULING.ENABLED;
|
||||
final boolean blocked = isBlocked(command, type, server);
|
||||
|
||||
if (allowGroupOverruling) {
|
||||
GroupManager.AccessResult groupResult = GroupManager.canAccessCommand(player, command, type, server);
|
||||
if (groupResult == GroupManager.AccessResult.NEGATED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!blocked) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Storage.getPermissionPlugin() != PermissionPlugin.NONE) {
|
||||
if (PermissionUtil.hasBypassPermission(player, command)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return groupResult.asBoolean();
|
||||
}
|
||||
|
||||
|
||||
if (!blocked) {
|
||||
return true;
|
||||
@@ -574,9 +612,37 @@ public class Storage {
|
||||
}
|
||||
}
|
||||
|
||||
return GroupManager.canAccessCommand(player, command, type, server);
|
||||
return GroupManager.canAccessCommand(player, command, type, server).asBoolean();
|
||||
}
|
||||
|
||||
/*
|
||||
Experimental:
|
||||
|
||||
It allows to negate commands inside a PAT group to block them off,
|
||||
even though it is allowed inside the global section.
|
||||
|
||||
public static boolean canPlayerAccess(Object player, String command, BlockType type, String server) {
|
||||
boolean blocked = isBlocked(command, type, server);
|
||||
GroupManager.AccessResult groupResult = GroupManager.canAccessCommand(player, command, type, server);
|
||||
|
||||
if (groupResult == GroupManager.AccessResult.NEGATED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!blocked) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Storage.getPermissionPlugin() != PermissionPlugin.NONE) {
|
||||
if (PermissionUtil.hasBypassPermission(player, command)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return groupResult.asBoolean();
|
||||
}
|
||||
*/
|
||||
|
||||
public static boolean isBlockedChat(String command) {
|
||||
return isBlocked(command, BlockType.CHAT, null);
|
||||
}
|
||||
@@ -602,34 +668,45 @@ public class Storage {
|
||||
BlockType negation = BlockType.NEGATE;
|
||||
String negatedCommand = negation + command;
|
||||
|
||||
boolean listed = isListed(command, type, server),
|
||||
boolean all = isListed("*", type, server),
|
||||
listed = isListed(command, type, server),
|
||||
negatedListed = isListed(negatedCommand, type, server),
|
||||
turn = ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
|
||||
if (all) {
|
||||
// Only listens to negated commands
|
||||
if (negatedListed) {
|
||||
return turn;
|
||||
}
|
||||
|
||||
if (!turn && negatedListed) {
|
||||
listed = !listed;
|
||||
return !turn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if (turn) {
|
||||
return !listed;
|
||||
} else {
|
||||
return listed;
|
||||
}
|
||||
*/
|
||||
|
||||
return turn != listed; // Shorter version of above's code
|
||||
|
||||
}
|
||||
|
||||
private static boolean isListed(String unmodifiedCommand, BlockType type, String server) {
|
||||
if (server != null && isDisabledServer(server))
|
||||
if (server != null && isDisabledServer(server)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
boolean listed = false;
|
||||
|
||||
String command = type.toString() + unmodifiedCommand;
|
||||
|
||||
if (server == null || !isIgnoredServer(server)) {
|
||||
listed = BLACKLIST.isListed(command, !turn);
|
||||
listed = BLACKLIST.isListed(command, false);
|
||||
}
|
||||
|
||||
if (server == null) {
|
||||
@@ -646,11 +723,11 @@ public class Storage {
|
||||
blacklists.add(BLACKLIST);
|
||||
|
||||
for (GeneralBlacklist blacklist : blacklists) {
|
||||
if (listed/* && turn*/) {
|
||||
if (listed) {
|
||||
break;
|
||||
}
|
||||
|
||||
listed = blacklist.isListed(command, turn);
|
||||
listed = blacklist.isListed(command, false);
|
||||
}
|
||||
|
||||
if (!listed && type != BlockType.BOTH) {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package de.rayzs.pat.api.storage.config.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper;
|
||||
|
||||
public class ConvertSection extends ConfigStorage {
|
||||
|
||||
public MultipleMessagesHelper MESSAGE;
|
||||
|
||||
public ConvertSection() {
|
||||
super("convert");
|
||||
}
|
||||
|
||||
public String INVALID_CONVERTER, SUCCESS;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
INVALID_CONVERTER = new ConfigSectionHelper<String>(this, "converter-not-found", "&cConverter or necessary files could not be found!").getOrSet();
|
||||
SUCCESS = new ConfigSectionHelper<String>(this, "success", "&aSuccessfully converted &e%converter% &ainto the PAT storage.yml!").getOrSet();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package de.rayzs.pat.api.storage.config.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper;
|
||||
|
||||
public class ExtractSection extends ConfigStorage {
|
||||
|
||||
public MultipleMessagesHelper MESSAGE;
|
||||
|
||||
public ExtractSection() {
|
||||
super("extract");
|
||||
}
|
||||
|
||||
public String USAGE, PLUGIN_NOT_FOUND, SUCCESS;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
USAGE = new ConfigSectionHelper<String>(this, "usage", "&7Usage: &f/pat extract [plugin] <use-colon> &7or &f<group> <use-colon>").getOrSet();
|
||||
PLUGIN_NOT_FOUND = new ConfigSectionHelper<String>(this, "plugin-not-found", "&cPlugin %plugin% not found!").getOrSet();
|
||||
SUCCESS = new ConfigSectionHelper<String>(this, "success", "&aSuccessfully extracted &e%amount% &anew commands from %plugin%!").getOrSet();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public class HelpSection extends ConfigStorage {
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
MESSAGE = new MultipleMessagesHelper(this, null, Reflection.isProxyServer() ?
|
||||
Arrays.asList(
|
||||
"&7Available commands are: &f/%label%&7..."
|
||||
@@ -26,6 +27,8 @@ public class HelpSection extends ConfigStorage {
|
||||
, "&f postdebug &7to post the PAT logs"
|
||||
, "&f update <player> &7to update player(s) permissions"
|
||||
, "&f perms <player> &7to check a player's permissions"
|
||||
, "&f extract (plugin) &7to extract all plugin commands"
|
||||
, "&f convert (plugin) &7converts into a PAT storage.yml"
|
||||
, "&f creategroup (group) &7Create a group"
|
||||
, "&f deletegroup (group) &7Delete a group"
|
||||
, "&f setpriority (group) (priority) &7to set the priority"
|
||||
@@ -44,6 +47,7 @@ public class HelpSection extends ConfigStorage {
|
||||
, "&f postdebug &7to post the PAT logs"
|
||||
, "&f update <player> &7to update player(s) permissions"
|
||||
, "&f perms <player> &7to check a player's permissions"
|
||||
, "&f extract (plugin) &7to extract all plugin commands"
|
||||
, "&f creategroup (group) &7Create a group"
|
||||
, "&f deletegroup (group) &7Delete a group"
|
||||
, "&f setpriority (group) (priority) &7to set the priority"
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
|
||||
public class AllowGroupOverrulingSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
|
||||
public AllowGroupOverrulingSection() {
|
||||
super("allow-group-overruling");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
}
|
||||
}
|
||||
+10
-4
@@ -1,6 +1,5 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
@@ -8,7 +7,7 @@ import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
|
||||
public class BlockNamespaceCommandsSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
public boolean ENABLED, ALWAYS_BLOCK_COMMAND;
|
||||
|
||||
public BlockNamespaceCommandsSection() {
|
||||
super("block-namespace-commands");
|
||||
@@ -18,15 +17,22 @@ public class BlockNamespaceCommandsSection extends ConfigStorage {
|
||||
public void load() {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
ALWAYS_BLOCK_COMMAND = new ConfigSectionHelper<Boolean>(this, "always-block-command", true).getOrSet();
|
||||
}
|
||||
|
||||
public boolean doesAlwaysBlock(String command) {
|
||||
return ALWAYS_BLOCK_COMMAND && isCommand(command);
|
||||
}
|
||||
|
||||
public boolean isCommand(String command) {
|
||||
if(!ENABLED || Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) return false;
|
||||
if (!ENABLED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return StringUtils.getFirstArg(command).contains(":");
|
||||
}
|
||||
|
||||
public boolean doesBypass(Object targetObj) {
|
||||
|
||||
return !ENABLED || PermissionUtil.hasPermission(targetObj, "namespace");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.*;
|
||||
import java.util.*;
|
||||
|
||||
@@ -31,13 +32,8 @@ public class CustomPluginsSection extends ConfigStorage {
|
||||
|
||||
public boolean isCommand(String command) {
|
||||
if(!ENABLED) return false;
|
||||
command = StringUtils.getFirstArg(command);
|
||||
|
||||
if (command.contains(" ")) {
|
||||
String[] split = command.split(" ");
|
||||
if (split.length > 0)
|
||||
command = split[0];
|
||||
command = command.split(" ")[0];
|
||||
}
|
||||
for (String currentCommand : COMMANDS.getLines()) {
|
||||
if (currentCommand.equalsIgnoreCase(command))
|
||||
return true;
|
||||
|
||||
+1
-1
@@ -26,6 +26,6 @@ public class HandleThroughProxySection extends ConfigStorage {
|
||||
TOKEN = new ConfigSectionHelper<String>(this, "token", "insert-token-of-proxy-here").getOrSet();
|
||||
|
||||
LOAD_FROM_ENV = new ConfigSectionHelper<Boolean>(this, "load-from-env.enabled", false).getOrSet();
|
||||
ENV_NAME = new ConfigSectionHelper<String>(this, "load-from-env.name", false).getOrSet();
|
||||
ENV_NAME = new ConfigSectionHelper<String>(this, "load-from-env.name", "PAT_TOKEN").getOrSet();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package de.rayzs.pat.api.storage.storages;
|
||||
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.api.storage.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -11,13 +9,14 @@ import java.util.*;
|
||||
public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
|
||||
private List<String> commands = new ArrayList<>();
|
||||
private List<String> hiddenCommands = new ArrayList<>();
|
||||
|
||||
public BlacklistStorage(String navigatePath) {
|
||||
super(Storage.Files.STORAGE, navigatePath);
|
||||
}
|
||||
|
||||
public boolean isListed(String command) {
|
||||
return isListed(command, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
|
||||
return isListed(command, false);
|
||||
}
|
||||
|
||||
public boolean isListed(String command, boolean ignoreColons) {
|
||||
@@ -27,11 +26,19 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
if (!isNegated(command) && commands.contains("*")) {
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
for (String listedCommand : commands) {
|
||||
boolean isNegated = isNegated(command);
|
||||
|
||||
if (!isNegated) {
|
||||
command = StringUtils.getFirstArg(command);
|
||||
}
|
||||
|
||||
for (String listedCommand : hiddenCommands) {
|
||||
if (listedCommand == null)
|
||||
continue;
|
||||
|
||||
@@ -42,14 +49,14 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
command = command.substring(command.indexOf(':'));
|
||||
}
|
||||
|
||||
if (caseSensitive) {
|
||||
if (StringUtils.getFirstArg(listedCommand).equals(StringUtils.getFirstArg(command))) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (StringUtils.getFirstArg(listedCommand).equalsIgnoreCase(StringUtils.getFirstArg(command))) {
|
||||
return true;
|
||||
}
|
||||
if (!isNegated) {
|
||||
listedCommand = StringUtils.getFirstArg(listedCommand);
|
||||
}
|
||||
|
||||
if (caseSensitive && listedCommand.equals(command)) {
|
||||
return true;
|
||||
} else if (!caseSensitive && listedCommand.equalsIgnoreCase(command)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,14 +68,17 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
}
|
||||
|
||||
public BlacklistStorage add(String command) {
|
||||
if (!commands.contains(command))
|
||||
if (!commands.contains(command)) {
|
||||
commands.add(command);
|
||||
hiddenCommands.add(command);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public BlacklistStorage remove(String command) {
|
||||
commands.remove(command);
|
||||
hiddenCommands.remove(command);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -81,6 +91,10 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
return commands;
|
||||
}
|
||||
|
||||
public List<String> getHiddenCommands() {
|
||||
return hiddenCommands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
getConfig().setAndSave(getNavigatePath(), commands);
|
||||
@@ -89,7 +103,35 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
@Override
|
||||
public void load() {
|
||||
getConfig().reload();
|
||||
|
||||
commands = (ArrayList<String>) getConfig().getOrSet(getNavigatePath(), commands);
|
||||
|
||||
List<String> tmpCommands = commands != null ? new ArrayList<>(commands) : new ArrayList<>();
|
||||
Set<String> pluginListCommands = new HashSet<>();
|
||||
|
||||
final String pluginCommandPrefix = "plugin=";
|
||||
|
||||
for (String command : tmpCommands) {
|
||||
if (command.startsWith(pluginCommandPrefix)) {
|
||||
pluginListCommands.add(command);
|
||||
}
|
||||
}
|
||||
|
||||
tmpCommands.removeAll(pluginListCommands);
|
||||
|
||||
for (String pluginListCommand : pluginListCommands) {
|
||||
pluginListCommand = pluginListCommand.substring(pluginCommandPrefix.length());
|
||||
|
||||
List<String> pluginCommands = Storage.getLoader().getPluginCommands(pluginListCommand, false);
|
||||
|
||||
for (String pluginCommand : pluginCommands) {
|
||||
if (!commands.contains(Storage.Blacklist.BlockType.NEGATE + pluginCommand)) {
|
||||
tmpCommands.add(pluginCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hiddenCommands = tmpCommands;
|
||||
}
|
||||
|
||||
private boolean isNegated(String command) {
|
||||
|
||||
@@ -17,8 +17,11 @@ public class DisabledServersStorage extends StorageTemplate {
|
||||
|
||||
public DisabledServersStorage add(String server) {
|
||||
server = server.toLowerCase();
|
||||
if(!servers.contains(server))
|
||||
|
||||
if (!servers.contains(server)) {
|
||||
servers.add(server);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -29,7 +32,10 @@ public class DisabledServersStorage extends StorageTemplate {
|
||||
}
|
||||
|
||||
public boolean isListed(String server) {
|
||||
if(servers.isEmpty()) return false;
|
||||
if (servers.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Storage.isServer(server, servers);
|
||||
}
|
||||
|
||||
@@ -42,7 +48,11 @@ public class DisabledServersStorage extends StorageTemplate {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
if(!Reflection.isProxyServer()) return;
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
getConfig().reload();
|
||||
servers = (ArrayList<String>) getConfig().getOrSet(getNavigatePath(), servers);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.rayzs.pat.plugin;
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
@@ -136,7 +137,12 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.initialize();
|
||||
|
||||
PATScheduler.createScheduler(this::loadAllCommands);
|
||||
StorageConverter.initialize();
|
||||
|
||||
PATScheduler.createScheduler(() -> {
|
||||
Storage.reload();
|
||||
loadAllCommands();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -376,17 +382,44 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginNames() {
|
||||
public List<String> getPluginNames(String format) {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
PluginDescriptionFile description = plugin.getDescription();
|
||||
pluginNames.add(description.getName() + " (" + description.getVersion() + ")");
|
||||
|
||||
pluginNames.add(
|
||||
format.replace("%n", description.getName())
|
||||
.replace("%v", description.getVersion())
|
||||
);
|
||||
}
|
||||
|
||||
return pluginNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginCommands(String pluginName, boolean useColons) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
|
||||
if (pluginName.isBlank()) return commands;
|
||||
|
||||
pluginName = pluginName.toLowerCase();
|
||||
|
||||
for (Map.Entry<String, Command> entry : BukkitLoader.getCommandsMap().entrySet()) {
|
||||
if (entry.getKey().toLowerCase().startsWith(pluginName + ":")) {
|
||||
String command = entry.getKey().substring(pluginName.length() + 1);
|
||||
|
||||
commands.add(command);
|
||||
|
||||
if (useColons) {
|
||||
commands.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
private void loadCommandMap() {
|
||||
try {
|
||||
if (Bukkit.getPluginManager() instanceof SimplePluginManager) {
|
||||
@@ -451,6 +484,10 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
BukkitLoader.disallowedCommands = commands.stream().filter(command -> !allowedCommands.contains(command)).toList();
|
||||
}
|
||||
|
||||
public static Map<String, Command> getCommandsMap() {
|
||||
return commandsMap;
|
||||
}
|
||||
|
||||
public static boolean useSuggestions() {
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.rayzs.pat.plugin;
|
||||
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
@@ -102,6 +103,8 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.initialize();
|
||||
|
||||
StorageConverter.initialize();
|
||||
|
||||
// Reload proxy commands after 1, 5, and 15 seconds.
|
||||
for (int i : new Integer[] { 1, 5, 15 }) {
|
||||
ProxyServer.getInstance().getScheduler().schedule(this, BungeePacketAnalyzer::loadProxyCommands, i, TimeUnit.SECONDS);
|
||||
@@ -254,17 +257,26 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginNames() {
|
||||
public List<String> getPluginNames(String format) {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
|
||||
for (Plugin plugin : ProxyServer.getInstance().getPluginManager().getPlugins()) {
|
||||
PluginDescription description = plugin.getDescription();
|
||||
pluginNames.add(description.getName() + " (" + description.getVersion() + ")");
|
||||
|
||||
pluginNames.add(
|
||||
format.replace("%n", description.getName())
|
||||
.replace("%v", description.getVersion())
|
||||
);
|
||||
}
|
||||
|
||||
return pluginNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginCommands(String pluginName, boolean useColons) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
public void startUpdaterTask() {
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED)
|
||||
return;
|
||||
|
||||
@@ -41,5 +41,12 @@ public interface PluginLoader {
|
||||
List<String> getOnlinePlayerNames();
|
||||
List<String> getOfflinePlayerNames();
|
||||
|
||||
List<String> getPluginNames();
|
||||
List<String> getPluginCommands(String pluginName, boolean useColons);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* %n = Plugin name
|
||||
* %v = Plugin version
|
||||
*/
|
||||
List<String> getPluginNames(String format);
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
@@ -37,7 +38,7 @@ import java.util.*;
|
||||
|
||||
@Plugin(name = "ProAntiTab",
|
||||
id = "proantitab",
|
||||
version = "2.1.0",
|
||||
version = "2.2.0",
|
||||
authors = "Rayzs_YT",
|
||||
description = "Hide more than just your plugins. Hide almost everything!",
|
||||
url = "https://www.rayzs.de/products/proantitab/page",
|
||||
@@ -121,6 +122,8 @@ public class VelocityLoader implements PluginLoader {
|
||||
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.initialize();
|
||||
|
||||
StorageConverter.initialize();
|
||||
}
|
||||
|
||||
public static org.slf4j.Logger getPluginLogger() {
|
||||
@@ -132,7 +135,6 @@ public class VelocityLoader implements PluginLoader {
|
||||
server.getScheduler().buildTask(VelocityLoader.instance, () -> {
|
||||
PermissionUtil.reloadPermissions();
|
||||
Storage.getLoader().updateCommandCache();
|
||||
|
||||
}).delay(1, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
|
||||
@@ -278,7 +280,7 @@ public class VelocityLoader implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginNames() {
|
||||
public List<String> getPluginNames(String format) {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
for (PluginContainer plugin : server.getPluginManager().getPlugins()) {
|
||||
PluginDescription description = plugin.getDescription();
|
||||
@@ -286,12 +288,20 @@ public class VelocityLoader implements PluginLoader {
|
||||
String pluginName = description.getName().orElse("/");
|
||||
String version = description.getVersion().orElse("/");
|
||||
|
||||
pluginNames.add(pluginName + " (" + version + ")");
|
||||
pluginNames.add(
|
||||
format.replace("%n", pluginName)
|
||||
.replace("%v", version)
|
||||
);
|
||||
}
|
||||
|
||||
return pluginNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginCommands(String pluginName, boolean useColons) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
public void startUpdaterTask() {
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED) return;
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package de.rayzs.pat.plugin.converter;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.utils.configuration.ConfigurationBuilder;
|
||||
import de.rayzs.pat.utils.configuration.Configurator;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Converter {
|
||||
|
||||
private final String pluginName, fileName, folderPath;
|
||||
protected final ConfigurationBuilder config;
|
||||
|
||||
public Converter(String pluginName, String folderName, String fileName) {
|
||||
this.pluginName = pluginName;
|
||||
this.fileName = fileName;
|
||||
this.folderPath = "./plugins/" + folderName;
|
||||
this.config = exists() ? Configurator.get(fileName, folderPath) : null;
|
||||
}
|
||||
|
||||
public String getPluginName() {
|
||||
return pluginName;
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
return new File(folderPath, fileName + ".yml").exists();
|
||||
}
|
||||
|
||||
protected void applyStorage(BlacklistStorage storage, List<String> commands) {
|
||||
for (String command : commands) {
|
||||
boolean exist = command.contains(" ")
|
||||
? storage.getCommands().contains(command)
|
||||
: storage.isListed(command);
|
||||
|
||||
if (exist) continue;
|
||||
|
||||
storage.add(command);
|
||||
}
|
||||
|
||||
storage.save();
|
||||
}
|
||||
|
||||
public abstract void apply(CommandSender sender);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package de.rayzs.pat.plugin.converter;
|
||||
|
||||
import de.rayzs.pat.plugin.converter.converters.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.*;
|
||||
|
||||
public class StorageConverter {
|
||||
|
||||
private StorageConverter() {}
|
||||
|
||||
private static final Map<String, Converter> converters = new HashMap<>();
|
||||
|
||||
|
||||
public static void initialize() {
|
||||
|
||||
if (!converters.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
registerConverter(new AdvancedPlHideConverter());
|
||||
registerConverter(new CommandWhitelistConverter());
|
||||
registerConverter(new PluginHiderPlus());
|
||||
registerConverter(new PlHideFree());
|
||||
registerConverter(new PlHidePro());
|
||||
}
|
||||
|
||||
public static Set<String> getConverters() {
|
||||
return converters.keySet();
|
||||
}
|
||||
|
||||
public static Converter getConverter(@NotNull String name) {
|
||||
return converters.get(name);
|
||||
}
|
||||
|
||||
public static void registerConverter(@NotNull Converter converter) {
|
||||
if (!converter.exists()) return;
|
||||
|
||||
converters.putIfAbsent(converter.getPluginName(), converter);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package de.rayzs.pat.plugin.converter.converters;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AdvancedPlHideConverter extends Converter {
|
||||
|
||||
public AdvancedPlHideConverter() {
|
||||
super("AdvancedPlHide", "AdvancedPlHide", "config");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(CommandSender sender) {
|
||||
List<String> groups = config.getKeys("groups", false).stream().toList();
|
||||
|
||||
for (String groupName : groups) {
|
||||
List<String> commands = (ArrayList<String>) config.get("groups."+ groupName + ".tabcomplete");
|
||||
BlacklistStorage storage;
|
||||
|
||||
if (groupName.equalsIgnoreCase("default")) {
|
||||
storage = Storage.Blacklist.getBlacklist();
|
||||
} else {
|
||||
Group group = GroupManager.registerAndGetGroup(groupName);
|
||||
storage = group.getGeneralGroupBlacklist();
|
||||
}
|
||||
|
||||
applyStorage(storage, commands);
|
||||
|
||||
}
|
||||
|
||||
sender.sendMessage("&e&lNotice: &7AdvanedPlHide works based on permissions whether to whitelist or blacklist commands from a group. Due to the fact that this cannot be detected by PAT and formatted in the exact way, all commands have been interpreted as whitelisted commands instead. Also, since PAT groups are only intended to whitelist commands, all created groups based on AdvancedPlHide have been created with the intention of whitelisting commands instead. If you wish to change that, please check out the GitHub wiki on how to use the storage.yml of PAT the intended way. (https://github.com/RayzsYT/ProAntiTab/wiki/How-to#introduction)");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package de.rayzs.pat.plugin.converter.converters;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandWhitelistConverter extends Converter {
|
||||
|
||||
public CommandWhitelistConverter() {
|
||||
super("CommandWhitelist", "CommandWhitelist", "config");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(CommandSender sender) {
|
||||
List<String> groups = config.getKeys("groups", false).stream().toList();
|
||||
|
||||
for (String groupName : groups) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
|
||||
final List<String> l1 = (ArrayList<String>) config.get("groups." + groupName + ".commands");
|
||||
final List<String> l2 = (ArrayList<String>) config.get("groups." + groupName + ".subcommands");
|
||||
|
||||
commands.addAll(l1);
|
||||
commands.addAll(l2);
|
||||
|
||||
BlacklistStorage storage;
|
||||
|
||||
if (groupName.equalsIgnoreCase("default")) {
|
||||
storage = Storage.Blacklist.getBlacklist();
|
||||
} else {
|
||||
Group group = GroupManager.registerAndGetGroup(groupName);
|
||||
storage = group.getGeneralGroupBlacklist();
|
||||
}
|
||||
|
||||
applyStorage(storage, commands);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package de.rayzs.pat.plugin.converter.converters;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlHideFree extends Converter {
|
||||
|
||||
public PlHideFree() {
|
||||
super("PlHide", "Pl-Hide-Free", "config");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(CommandSender sender) {
|
||||
List<String> groups = config.getKeys("groups", false).stream().toList();
|
||||
|
||||
for (String groupName : groups) {
|
||||
List<String> execution = (ArrayList<String>) config.get("groups." + groupName + ".commands");
|
||||
List<String> commands = execution.stream().filter(s -> !s.startsWith("!") && !s.equalsIgnoreCase("*")).map(this::translate).toList();
|
||||
|
||||
BlacklistStorage storage;
|
||||
|
||||
if (groupName.equalsIgnoreCase("default")) {
|
||||
storage = Storage.Blacklist.getBlacklist();
|
||||
} else {
|
||||
Group group = GroupManager.registerAndGetGroup(groupName);
|
||||
storage = group.getGeneralGroupBlacklist();
|
||||
}
|
||||
|
||||
applyStorage(storage, commands);
|
||||
|
||||
}
|
||||
|
||||
sender.sendMessage("§e§lNotice: §7Since PAT is mainly focussed on either blocking or whitelisting commands entirely, PAT is viewing and converting the file such that commands are only working in whitelist mode. If you wish to use ProAntiTab in blacklist mode instead, then please checkout the wiki! (https://github.com/RayzsYT/ProAntiTab/wiki/How-to#introduction)");
|
||||
}
|
||||
|
||||
private String translate(String input) {
|
||||
if (input.contains(" ")) {
|
||||
if (input.endsWith("~")) {
|
||||
return translate(input.substring(0, input.length() - 1) + "_-");
|
||||
}
|
||||
|
||||
if (input.endsWith("*")) {
|
||||
return input.substring(0, input.length() - 2);
|
||||
} else if (input.contains("*")) {
|
||||
return input.substring(0, input.indexOf('*') - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package de.rayzs.pat.plugin.converter.converters;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PlHidePro extends Converter {
|
||||
|
||||
public PlHidePro() {
|
||||
super("PlHidePro", "Pl-Hide-Pro", "config");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(CommandSender sender) {
|
||||
|
||||
boolean updateGroupPerWorld = (boolean) config.get("per_world_group_updates");
|
||||
Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_WORLD.getConfig().setAndSave("update-groups-per-world", updateGroupPerWorld);
|
||||
|
||||
boolean autoLowercaseCommands = (boolean) config.get("auto_lowercase_base_commands");
|
||||
Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.getConfig().setAndSave("auto-lowercase-commands.enabled", autoLowercaseCommands);
|
||||
|
||||
boolean f3brand = (boolean) config.get("replace-f3-server-brand");
|
||||
String f3brandString = (String) config.get("f3-server-brand");
|
||||
Storage.ConfigSections.Settings.CUSTOM_BRAND.getConfig().setAndSave("custom-server-brand.enabled", f3brand);
|
||||
|
||||
if (f3brand) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_BRAND.getConfig().setAndSave("custom-server-brand.repeat-delay", -1);
|
||||
Storage.ConfigSections.Settings.CUSTOM_BRAND.getConfig().setAndSave("custom-server-brand.brands", new ArrayList<>(Collections.singletonList(f3brandString.replace("§", "&"))));
|
||||
}
|
||||
|
||||
List<String> groups = config.getKeys("groups", false).stream().toList();
|
||||
|
||||
for (String groupName : groups) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
|
||||
final List<String> execution = (ArrayList<String>) config.get("groups." + groupName + ".commands");
|
||||
final List<String> tabCompletion = (ArrayList<String>) config.get("groups." + groupName + ".tabcomplete");
|
||||
|
||||
for (String s : execution) {
|
||||
if (s.equalsIgnoreCase("*")) {
|
||||
tabCompletion.remove("*");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!s.contains(" ") && s.startsWith("!")) {
|
||||
tabCompletion.remove(s);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tabCompletion.contains(s)) {
|
||||
commands.add(s);
|
||||
tabCompletion.remove(s);
|
||||
continue;
|
||||
}
|
||||
|
||||
commands.add("[CMD]" + s);
|
||||
}
|
||||
|
||||
commands.addAll(tabCompletion.stream().map(s -> "[TAB]" + s).toList());
|
||||
commands = commands.stream().map(this::translate).toList();
|
||||
|
||||
BlacklistStorage storage;
|
||||
|
||||
if (groupName.equalsIgnoreCase("default")) {
|
||||
storage = Storage.Blacklist.getBlacklist();
|
||||
} else {
|
||||
Group group = GroupManager.registerAndGetGroup(groupName);
|
||||
storage = group.getGeneralGroupBlacklist();
|
||||
}
|
||||
|
||||
applyStorage(storage, commands);
|
||||
}
|
||||
|
||||
sender.sendMessage("§e§lNotice: §7Since PAT is mainly focussed on either blocking or whitelisting commands entirely, PAT is viewing and converting the file such that commands are only working in whitelist mode. If you wish to use ProAntiTab in blacklist mode instead, then please checkout the wiki! (https://github.com/RayzsYT/ProAntiTab/wiki/How-to#introduction)");
|
||||
}
|
||||
|
||||
private String translate(String input) {
|
||||
if (input.contains(" ")) {
|
||||
if (input.endsWith("~")) {
|
||||
return translate(input.substring(0, input.length() - 1) + "_-");
|
||||
}
|
||||
|
||||
if (input.endsWith("*")) {
|
||||
return input.substring(0, input.length() - 2);
|
||||
} else if (input.contains("*")) {
|
||||
return input.substring(0, input.indexOf('*') - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package de.rayzs.pat.plugin.converter.converters;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PluginHiderPlus extends Converter {
|
||||
|
||||
public PluginHiderPlus() {
|
||||
super("PluginHider+", "PluginHiderPlus", "config");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(CommandSender sender) {
|
||||
|
||||
boolean blacklist = (boolean) config.get("reverse-suggestionsWhitelist");
|
||||
Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.getConfig().setAndSave("turn-blacklist-to-whitelist", !blacklist);
|
||||
|
||||
List<String> commands = (ArrayList<String>) config.get("suggestionsWhitelist");
|
||||
|
||||
if (blacklist) {
|
||||
List<String> blockedCommands = (ArrayList<String>) config.get("blockedCommands.everyone.commands");
|
||||
commands.addAll(blockedCommands);
|
||||
}
|
||||
|
||||
applyStorage(Storage.Blacklist.getBlacklist(), commands);
|
||||
sender.sendMessage("&e&lNotice: &7Since PluginHider+ both blocks certain commands and whitelist a few, the conversion into PAT's storage.yml format won't be accurate. Only whitelisted commands have been added, and blocked commands for everyone if the plugin was used in blacklist mode.");
|
||||
}
|
||||
}
|
||||
+30
-11
@@ -2,6 +2,8 @@ package de.rayzs.pat.plugin.listeners.bukkit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -45,7 +47,9 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandProcess(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
final String commandFirstArg = StringUtils.getFirstArg(event.getMessage());
|
||||
|
||||
if (Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.isCommand(commandFirstArg)) {
|
||||
@@ -71,6 +75,14 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
command = command.substring(1);
|
||||
command = StringUtils.getFirstArg(command);
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String displayCommand = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
@@ -79,10 +91,6 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
"%command%", displayCommand,
|
||||
"%world%", worldName);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
|
||||
MessageTranslator.send(
|
||||
@@ -127,13 +135,24 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
|
||||
return;
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
return;
|
||||
final boolean cancelBlockedCommand = Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED;
|
||||
|
||||
if (!Storage.Blacklist.canPlayerAccessChat(player, command)) {
|
||||
boolean allowed = Storage.Blacklist.canPlayerAccessChat(player, command);
|
||||
boolean blockedNamespace = false;
|
||||
|
||||
if (!Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender)) {
|
||||
blockedNamespace = cancelBlockedCommand
|
||||
? Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command)
|
||||
: Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesAlwaysBlock(command);
|
||||
|
||||
if (blockedNamespace) allowed = false;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED && !blockedNamespace) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!allowed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
player,
|
||||
event.getMessage(),
|
||||
|
||||
@@ -2,7 +2,9 @@ package de.rayzs.pat.plugin.listeners.bungee;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@@ -10,19 +12,32 @@ import net.md_5.bungee.api.event.TabCompleteEvent;
|
||||
import net.md_5.bungee.api.event.TabCompleteResponseEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class BungeeAntiTabListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onTabComplete(TabCompleteEvent event) {
|
||||
if(!(event.getSender() instanceof ProxiedPlayer)) return;
|
||||
public void onTabCompleteResponse(TabCompleteResponseEvent event) {
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
|
||||
if(!(event.getReceiver() instanceof ProxiedPlayer)) return;
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
|
||||
ServerInfo serverInfo = player.getServer().getInfo();
|
||||
String serverName = serverInfo.getName();
|
||||
String cursor = event.getCursor().substring(1);
|
||||
|
||||
String rawCursor = BungeePacketAnalyzer.getPlayerInput(player);
|
||||
|
||||
if (rawCursor == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!rawCursor.startsWith("/")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String cursor = rawCursor.substring(1);
|
||||
|
||||
if (event.getSuggestions().isEmpty())
|
||||
return;
|
||||
@@ -33,16 +48,59 @@ public class BungeeAntiTabListener implements Listener {
|
||||
if (PermissionUtil.hasBypassPermission(player))
|
||||
return;
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player, cursor, event.getSuggestions());
|
||||
List<String> suggestions = filteredTabCompletionEvent.getCompletion();
|
||||
|
||||
event.getSuggestions().removeIf(suggestion -> {
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(suggestion) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(suggestion)) {
|
||||
final boolean doesBypassNamespace = Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player);
|
||||
final boolean spaces = cursor.contains(" ");
|
||||
|
||||
boolean cancelsBeforeHand = false;
|
||||
|
||||
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(cursor) && !doesBypassNamespace) {
|
||||
cancelsBeforeHand = true;
|
||||
}
|
||||
|
||||
if (!cancelsBeforeHand && !cursor.isEmpty()) {
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(player, StringUtils.getFirstArg(cursor), serverName);
|
||||
}
|
||||
|
||||
if (!cancelsBeforeHand) {
|
||||
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(cursor) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(cursor);
|
||||
}
|
||||
|
||||
if (spaces) {
|
||||
if (cancelsBeforeHand) {
|
||||
event.getSuggestions().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawCursor, new ArrayList<>(event.getSuggestions()));
|
||||
|
||||
if (filteredTabCompletionEvent.isCancelled()) {
|
||||
event.getSuggestions().clear();
|
||||
} else {
|
||||
event.getSuggestions().removeIf(s -> !filteredTabCompletionEvent.getCompletion().contains(s));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
event.getSuggestions().removeIf(s -> {
|
||||
String cpy = s;
|
||||
if (cpy.startsWith("/")) {
|
||||
cpy = cpy.substring(1);
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(cpy) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(cpy)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !suggestions.contains(suggestion);
|
||||
return !Storage.Blacklist.canPlayerAccessTab(player, cpy, serverName);
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTabComplete(TabCompleteEvent event) {
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
|
||||
BungeePacketAnalyzer.setPlayerInput(player, event.getCursor());
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package de.rayzs.pat.plugin.listeners.bungee;
|
||||
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import net.md_5.bungee.api.event.ChatEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
@@ -20,15 +22,17 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
public void onChat(ChatEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
Connection connection = event.getSender();
|
||||
final Connection connection = event.getSender();
|
||||
if (! (connection instanceof ProxiedPlayer) || !event.getMessage().startsWith("/"))
|
||||
return;
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) connection;
|
||||
String serverName = player.getServer().getInfo().getName();
|
||||
final ProxiedPlayer player = (ProxiedPlayer) connection;
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final String serverName = player.getServer().getInfo().getName();
|
||||
|
||||
String command = event.getMessage();
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command))
|
||||
if (PermissionUtil.hasBypassPermission(player, command) || Storage.Blacklist.isDisabledServer(serverName))
|
||||
return;
|
||||
|
||||
command = command.startsWith("/") ? command.substring(1) : command;
|
||||
@@ -87,10 +91,24 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
|
||||
return;
|
||||
final boolean cancelBlockedCommand = Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED;
|
||||
|
||||
if (!Storage.Blacklist.canPlayerAccessChat(player, command, serverName)) {
|
||||
boolean allowed = Storage.Blacklist.canPlayerAccessChat(player, command, serverName);
|
||||
boolean blockedNamespace = false;
|
||||
|
||||
if (!Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender)) {
|
||||
blockedNamespace = cancelBlockedCommand
|
||||
? Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command)
|
||||
: Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesAlwaysBlock(command);
|
||||
|
||||
if (blockedNamespace) allowed = false;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED && !blockedNamespace) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!allowed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
player,
|
||||
event.getMessage(),
|
||||
|
||||
@@ -68,6 +68,10 @@ public class VelocityAntiTabListener {
|
||||
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
|
||||
if (!cache.containsKey(serverName)) {
|
||||
|
||||
+28
-10
@@ -10,6 +10,9 @@ import com.velocitypowered.api.proxy.Player;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.api.event.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class VelocityBlockCommandListener {
|
||||
@@ -27,20 +30,21 @@ public class VelocityBlockCommandListener {
|
||||
if(!event.getResult().isAllowed())
|
||||
return event;
|
||||
|
||||
CommandSource commandSource = event.getCommandSource();
|
||||
Object consoleSender = Storage.getLoader().getConsoleSender();
|
||||
final CommandSource commandSource = event.getCommandSource();
|
||||
final Object consoleSender = Storage.getLoader().getConsoleSender();
|
||||
|
||||
if(! (commandSource instanceof Player))
|
||||
return event;
|
||||
|
||||
Player player = (Player) commandSource;
|
||||
String command = StringUtils.getFirstArg(event.getCommand());
|
||||
|
||||
String serverName = player.getCurrentServer().isPresent()
|
||||
final Player player = (Player) commandSource;
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final String serverName = player.getCurrentServer().isPresent()
|
||||
? player.getCurrentServer().get().getServerInfo().getName()
|
||||
: "unknown";
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command))
|
||||
String command = StringUtils.getFirstArg(event.getCommand());
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command) || Storage.Blacklist.isDisabledServer(serverName))
|
||||
return event;
|
||||
|
||||
final String displayCommand = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
@@ -97,10 +101,24 @@ public class VelocityBlockCommandListener {
|
||||
return event;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
|
||||
return event;
|
||||
final boolean cancelBlockedCommand = Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED;
|
||||
|
||||
if (!Storage.Blacklist.canPlayerAccessChat(player, command, serverName)) {
|
||||
boolean allowed = Storage.Blacklist.canPlayerAccessChat(player, command, serverName);
|
||||
boolean blockedNamespace = false;
|
||||
|
||||
if (!Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender)) {
|
||||
blockedNamespace = cancelBlockedCommand
|
||||
? Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command)
|
||||
: Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesAlwaysBlock(command);
|
||||
|
||||
if (blockedNamespace) allowed = false;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED && !blockedNamespace) {
|
||||
return event;
|
||||
}
|
||||
|
||||
if (!allowed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
player,
|
||||
event.getCommand(),
|
||||
|
||||
+16
-2
@@ -5,6 +5,7 @@ import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.api.netty.proxy.VelocityPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
@@ -14,6 +15,7 @@ import de.rayzs.pat.api.storage.Storage;
|
||||
import com.velocitypowered.api.proxy.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -55,8 +57,20 @@ public class VelocityConnectionListener {
|
||||
public void onServerSwitch(ServerConnectedEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!VelocityPacketAnalyzer.isInjected(player))
|
||||
VelocityPacketAnalyzer.inject(player);
|
||||
if (!VelocityPacketAnalyzer.isInjected(player)) {
|
||||
|
||||
if (!VelocityPacketAnalyzer.inject(player)) {
|
||||
Logger.warning("Attempting delayed injection for " + player.getUsername());
|
||||
server.getScheduler().buildTask(loader, () -> {
|
||||
|
||||
if (!VelocityPacketAnalyzer.inject(player)) {
|
||||
Logger.warning("Second injection for " + player.getUsername() + " failed as well!");
|
||||
player.disconnect(Component.text("Failed to inject player!"));
|
||||
}
|
||||
|
||||
}).delay(1, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_SERVER.ENABLED) {
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
@@ -90,16 +90,18 @@ public class Logger {
|
||||
.append(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED ? "WHITELIST" : "BLACKLIST")
|
||||
.append("\n");
|
||||
|
||||
builder.append("Detected Software-API: ")
|
||||
.append(Reflection.isProxyServer()
|
||||
? Reflection.isPaper() ? "Waterfall" :
|
||||
Reflection.isVelocityServer() ? "Velocity" : "Bungeecord"
|
||||
: Reflection.isFoliaServer() ? "Folia"
|
||||
: Reflection.isPaper() ? "Paper" : "Spigot")
|
||||
.append("\n");
|
||||
builder.append("Detected Software-API: ");
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
builder.append(Reflection.isPaper() ? "Waterfall" : Reflection.isVelocityServer() ? "Velocity" : "Bungeecord");
|
||||
} else {
|
||||
builder.append(Reflection.isFoliaServer() ? "Folia" : Reflection.isPaper() ? "Paper" : "Spigot");
|
||||
}
|
||||
|
||||
builder.append("\n");
|
||||
|
||||
builder.append("Installed plugins: \n ")
|
||||
.append(String.join("\n ", Storage.getLoader().getPluginNames()))
|
||||
.append(String.join("\n ", Storage.getLoader().getPluginNames("%n (%v)")))
|
||||
.append("\n\n");
|
||||
|
||||
builder.append("Detected supported plugins:")
|
||||
@@ -129,7 +131,7 @@ public class Logger {
|
||||
.append("\n");
|
||||
|
||||
builder.append("last-received-sync: ")
|
||||
.append(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ? Storage.LAST_SYNC : "Deactivated")
|
||||
.append(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ? TimeConverter.calcAndGetTime(Storage.LAST_SYNC) : "Deactivated")
|
||||
.append("\n");
|
||||
}
|
||||
|
||||
@@ -143,7 +145,7 @@ public class Logger {
|
||||
.append("\n");
|
||||
|
||||
builder.append("last-sent-sync: ")
|
||||
.append(Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED ? "Deactivated" : (System.currentTimeMillis() - Storage.LAST_SYNC))
|
||||
.append(Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED ? "Deactivated" : (TimeConverter.calcAndGetTime(Storage.LAST_SYNC)))
|
||||
.append("\n\n");
|
||||
|
||||
for (ClientInfo client : Communicator.CLIENTS) {
|
||||
|
||||
@@ -35,6 +35,12 @@ public class CommandProcess {
|
||||
COMMANDS.add(new RemoveCommand());
|
||||
COMMANDS.add(new ClearCommand());
|
||||
|
||||
COMMANDS.add(new ConvertCommand());
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
COMMANDS.add(new ExtractCommand());
|
||||
}
|
||||
|
||||
COMMANDS.add(new CreateGroupCommand());
|
||||
COMMANDS.add(new DeleteGroupCommand());
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ public class AddCommand extends ProCommand {
|
||||
if (command.isEmpty())
|
||||
return false;
|
||||
|
||||
final boolean loadBlacklist = command.startsWith("plugin=") || command.startsWith("!");
|
||||
final int length = args.length;
|
||||
|
||||
if (length == 1) {
|
||||
@@ -67,6 +68,8 @@ public class AddCommand extends ProCommand {
|
||||
|
||||
if (!exist) {
|
||||
Storage.Blacklist.getBlacklist().add(command).save();
|
||||
if (loadBlacklist) Storage.Blacklist.getBlacklist().load();
|
||||
|
||||
Storage.handleChange();
|
||||
}
|
||||
|
||||
@@ -107,7 +110,9 @@ public class AddCommand extends ProCommand {
|
||||
if (Reflection.isProxyServer())
|
||||
return null;
|
||||
|
||||
return BukkitLoader.getDisallowedCommands();
|
||||
return Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
? BukkitLoader.getDisallowedCommands()
|
||||
: BukkitLoader.getAllowedCommands();
|
||||
}
|
||||
|
||||
String fullString = String.join(" ", args);
|
||||
|
||||
@@ -34,6 +34,7 @@ public class ClearCommand extends ProCommand {
|
||||
}
|
||||
|
||||
Storage.Blacklist.getBlacklist().clear().save();
|
||||
Storage.Blacklist.getBlacklist().load();
|
||||
Storage.handleChange();
|
||||
|
||||
CONFIRMATION.remove(sender.getUniqueId());
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ConvertCommand extends ProCommand {
|
||||
|
||||
public ConvertCommand() {
|
||||
super(
|
||||
"convert",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
|
||||
if (args.length != 1)
|
||||
return false;
|
||||
|
||||
String converterName = args[0];
|
||||
Converter converter = StorageConverter.getConverter(converterName);
|
||||
if (converter == null) {
|
||||
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.CONVERT.INVALID_CONVERTER,
|
||||
"%converter%", converterName)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
converterName = converter.getPluginName();
|
||||
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.CONVERT.SUCCESS,
|
||||
"%converter%", converterName)
|
||||
);
|
||||
|
||||
converter.apply(sender);
|
||||
Storage.reload();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||
return StorageConverter.getConverters().stream().toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ExtractCommand extends ProCommand {
|
||||
|
||||
public ExtractCommand() {
|
||||
super(
|
||||
"extract",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
|
||||
if (args.length < 1) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.EXTRACT.USAGE);
|
||||
return true;
|
||||
}
|
||||
|
||||
String pluginName = args[0].toLowerCase();
|
||||
boolean failed = false, useColons = false;
|
||||
Group group = null;
|
||||
|
||||
if (args.length == 2) {
|
||||
|
||||
group = GroupManager.getGroupByName(args[1]);
|
||||
if (group == null) {
|
||||
useColons = Boolean.parseBoolean(args[1]);
|
||||
|
||||
if (!useColons && !args[1].equalsIgnoreCase("false")) {
|
||||
failed = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
useColons = Boolean.parseBoolean(args[1]);
|
||||
} catch (Exception exception) {
|
||||
group = GroupManager.getGroupByName(args[1]);
|
||||
failed = group == null;
|
||||
}
|
||||
|
||||
} else if (args.length == 3) {
|
||||
group = GroupManager.getGroupByName(args[1]);
|
||||
|
||||
if (group == null) {
|
||||
failed = true;
|
||||
} else {
|
||||
try {
|
||||
useColons = Boolean.parseBoolean(args[2]);
|
||||
} catch (Exception exception) {
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (failed) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.EXTRACT.USAGE);
|
||||
return true;
|
||||
}
|
||||
|
||||
List<String> pluginNames = Storage.getLoader().getPluginNames("%n");
|
||||
boolean pluginFound = false;
|
||||
|
||||
for (String name : pluginNames) {
|
||||
if (name.equalsIgnoreCase(pluginName)) {
|
||||
pluginFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pluginFound) {
|
||||
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.EXTRACT.PLUGIN_NOT_FOUND,
|
||||
"%plugin%", pluginName)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
List<String> commands = Storage.getLoader().getPluginCommands(args[0], useColons);
|
||||
|
||||
BlacklistStorage storage = group == null
|
||||
? Storage.Blacklist.getBlacklist()
|
||||
: group.getGeneralGroupBlacklist();
|
||||
|
||||
commands = commands.stream().filter(command -> !storage.isListed(command)).toList();
|
||||
commands.forEach(storage::add);
|
||||
|
||||
storage.save();
|
||||
|
||||
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.EXTRACT.SUCCESS,
|
||||
"%amount%", String.valueOf(commands.size()),
|
||||
"%plugin%", pluginName
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||
final int length = args.length;
|
||||
|
||||
if (length <= 1) {
|
||||
return Storage.getLoader().getPluginNames("%n");
|
||||
}
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
if (length == 2 || length == 3 && GroupManager.getGroupByName(args[1]) != null) {
|
||||
result.add("true");
|
||||
result.add("false");
|
||||
}
|
||||
|
||||
if (length == 2) {
|
||||
result.addAll(GroupManager.getGroupNames());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ public class RemoveCommand extends ProCommand {
|
||||
if (command.isEmpty())
|
||||
return false;
|
||||
|
||||
final boolean loadBlacklist = command.startsWith("plugin=") || command.startsWith("!");
|
||||
final int length = args.length;
|
||||
|
||||
if (length == 1) {
|
||||
@@ -64,6 +65,8 @@ public class RemoveCommand extends ProCommand {
|
||||
|
||||
if (exist) {
|
||||
Storage.Blacklist.getBlacklist().remove(command).save();
|
||||
if (loadBlacklist) Storage.Blacklist.getBlacklist().load();
|
||||
|
||||
Storage.handleChange();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ListCommand extends ProCommand {
|
||||
String message = Storage.ConfigSections.Messages.GROUP.LIST_MESSAGE;
|
||||
message = StringUtils.replace(message,
|
||||
"%group%", groupName,
|
||||
"%size%", String.valueOf(Storage.Blacklist.getBlacklist().getCommands().size()),
|
||||
"%size%", String.valueOf(group.getCommands().size()),
|
||||
"%commands%", commandsListMessage
|
||||
);
|
||||
|
||||
|
||||
@@ -22,30 +22,8 @@ public class ReloadCommand extends ProCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
boolean proxy = Reflection.isProxyServer();
|
||||
boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !proxy;
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.RELOAD.LOADING);
|
||||
|
||||
ConfigUpdater.initialize();
|
||||
Storage.loadAll(Reflection.isProxyServer() || !backend);
|
||||
|
||||
CustomServerBrand.initialize();
|
||||
GroupManager.clearAllGroups();
|
||||
GroupManager.initialize();
|
||||
|
||||
if (!proxy) {
|
||||
BackendUpdater.stop();
|
||||
BackendUpdater.start();
|
||||
}
|
||||
|
||||
if (!backend) {
|
||||
Storage.handleChange();
|
||||
}
|
||||
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
Storage.getLoader().handleReload();
|
||||
|
||||
Storage.reload();
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.RELOAD.DONE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,15 @@ public class ServAddCommand extends ProCommand {
|
||||
Group group = GroupManager.getGroupByName(groupName);
|
||||
|
||||
if (group == null) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER.replace("%group%", groupName));
|
||||
|
||||
String message = Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%group%", groupName,
|
||||
"%server%", serverName
|
||||
);
|
||||
|
||||
sender.sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.rayzs.pat.plugin.process.impl.server;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
@@ -66,12 +67,14 @@ public class ServClearCommand extends ProCommand {
|
||||
|
||||
if (group == null) {
|
||||
|
||||
sender.sendMessage(
|
||||
Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER
|
||||
.replace("%group%", groupName)
|
||||
.replace("%server%", serverName)
|
||||
String message = Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%group%", groupName,
|
||||
"%server%", serverName
|
||||
);
|
||||
|
||||
sender.sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,12 +95,14 @@ public class ServRemoveCommand extends ProCommand {
|
||||
|
||||
if (group == null) {
|
||||
|
||||
sender.sendMessage(
|
||||
Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER
|
||||
.replace("%group%", groupName)
|
||||
.replace("%server%", serverName)
|
||||
String message = Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%group%", groupName,
|
||||
"%server%", serverName
|
||||
);
|
||||
|
||||
sender.sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ public class ServListCommand extends ProCommand {
|
||||
);
|
||||
|
||||
String message = Storage.ConfigSections.Messages.BLACKLIST.LIST_SERVER_MESSAGE;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%size%", String.valueOf(blacklist.getCommands().size()),
|
||||
"%commands%", commandsListMessage,
|
||||
@@ -57,7 +58,15 @@ public class ServListCommand extends ProCommand {
|
||||
Group group = GroupManager.getGroupByName(groupName);
|
||||
|
||||
if (group == null) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER.replace("%group%", groupName));
|
||||
|
||||
String message = Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%group%", groupName,
|
||||
"%server%", serverName
|
||||
);
|
||||
|
||||
sender.sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,14 @@ import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
|
||||
public class CommandsCache {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* RECODE PLANNED
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
private List<String> filteredCommands = null, allCommands = null;
|
||||
private boolean change = false;
|
||||
|
||||
@@ -42,28 +50,31 @@ public class CommandsCache {
|
||||
}
|
||||
|
||||
public void handleCommands(List<String> commands, String server) {
|
||||
if(!isOutdated(commands))
|
||||
if (!isOutdated(commands))
|
||||
return;
|
||||
|
||||
LinkedList<String> tmpFilteredCommands = new LinkedList<>();
|
||||
List<String> tmpAllCommands = new ArrayList<>(commands);
|
||||
allCommands = tmpAllCommands;
|
||||
|
||||
for (String command : tmpAllCommands) {
|
||||
command = StringUtils.getFirstArg(command);
|
||||
final int length = allCommands.size();
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (i >= tmpAllCommands.size())
|
||||
break;
|
||||
|
||||
String command = StringUtils.getFirstArg(tmpAllCommands.get(i));
|
||||
Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(command);
|
||||
|
||||
if (type != Storage.Blacklist.BlockType.BOTH && type != Storage.Blacklist.BlockType.TAB)
|
||||
continue;
|
||||
|
||||
if (isFilterListAvailable()) {
|
||||
if (filteredCommands.contains(command))
|
||||
if (filteredCommands.contains(command))
|
||||
continue;
|
||||
|
||||
if (!Storage.Blacklist.isBlockedTab(command, server))
|
||||
filteredCommands.add(command);
|
||||
tmpFilteredCommands.add(command);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
filteredCommands = tmpFilteredCommands;
|
||||
|
||||
@@ -34,6 +34,12 @@ public class LuckPermsAdapter {
|
||||
|
||||
|
||||
public static User getUser(UUID uuid) {
|
||||
|
||||
if (uuid == null) {
|
||||
Logger.warning("Attempted to get LuckPerms user with null UUID!");
|
||||
return null;
|
||||
}
|
||||
|
||||
return PROVIDER.getUserManager().getUser(uuid);
|
||||
}
|
||||
|
||||
|
||||
+6
-16
@@ -81,14 +81,9 @@ public class BukkitConfigurationBuilder implements ConfigurationBuilder {
|
||||
if (result != null)
|
||||
return result;
|
||||
|
||||
if (fileName.equals("config")) {
|
||||
if (!ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart((!path.isBlank() ? path + "." : "") + target);
|
||||
return object;
|
||||
}
|
||||
|
||||
set(path, target, object);
|
||||
return get(path, target);
|
||||
if (fileName.equals("config") && !ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart((!path.isBlank() ? path + "." : "") + target);
|
||||
return object;
|
||||
}
|
||||
|
||||
set(path, target, object);
|
||||
@@ -103,14 +98,9 @@ public class BukkitConfigurationBuilder implements ConfigurationBuilder {
|
||||
if (result != null)
|
||||
return result;
|
||||
|
||||
if (fileName.equals("config")) {
|
||||
if (!ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart(target);
|
||||
return object;
|
||||
}
|
||||
|
||||
set(target, object);
|
||||
return get(target);
|
||||
if (fileName.equals("config") && !ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart(target);
|
||||
return object;
|
||||
}
|
||||
|
||||
set(target, object);
|
||||
|
||||
@@ -88,14 +88,9 @@ public class ProxyConfigurationBuilder implements ConfigurationBuilder {
|
||||
if (result != null)
|
||||
return result;
|
||||
|
||||
if (fileName.equals("config")) {
|
||||
if (!ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart((!path.isBlank() ? path + "." : "") + target);
|
||||
return object;
|
||||
}
|
||||
|
||||
set(path, target, object);
|
||||
return get(path, target);
|
||||
if (fileName.equals("config") && !ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart((!path.isBlank() ? path + "." : "") + target);
|
||||
return object;
|
||||
}
|
||||
|
||||
set(path, target, object);
|
||||
@@ -110,14 +105,9 @@ public class ProxyConfigurationBuilder implements ConfigurationBuilder {
|
||||
if (result != null)
|
||||
return result;
|
||||
|
||||
if (fileName.equals("config")) {
|
||||
if (!ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart(target);
|
||||
return object;
|
||||
}
|
||||
|
||||
set(target, object);
|
||||
return get(target);
|
||||
if (fileName.equals("config") && !ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart(target);
|
||||
return object;
|
||||
}
|
||||
|
||||
set(target, object);
|
||||
|
||||
@@ -101,13 +101,20 @@ public class ConfigUpdater {
|
||||
}
|
||||
|
||||
Logger.warning(" ");
|
||||
Logger.warning("The config.yml is missing a few parts.");
|
||||
Logger.warning("What can be done to solve this issue? There are two options:");
|
||||
Logger.warning("Hey, the config.yml is missing a few parts.");
|
||||
Logger.warning("This most likely happened because PAT added a new feature or message.");
|
||||
Logger.warning(" ");
|
||||
Logger.warning("No worries though! This isn't a bad or dangerous thing.");
|
||||
Logger.warning("You can even ignore or disable this warning entirely by disabling 'announce-missing-parts'.");
|
||||
Logger.warning(" ");
|
||||
Logger.warning("But more importantly. If you want to fill the missing parts,");
|
||||
Logger.warning("then you would have three options on how to do so:");
|
||||
Logger.warning(" ");
|
||||
Logger.warning("Option 1: Delete your current config.yml and restart the server.");
|
||||
Logger.warning("Option 2: Set the missing parts/sections yourself in the config.yml.");
|
||||
Logger.warning("Option 3: Enable 'auto-update-config'. But *please* read the warning message above that option.");
|
||||
Logger.warning(" ");
|
||||
Logger.warning("To simplify that process, a new file with the newest config.yml content has been created as comparison. (plugins/ProAntiTab/comparable-config.yml)");
|
||||
Logger.warning("To simplify this process, a new file with the newest config.yml content has been created as comparison. (plugins/ProAntiTab/comparable-config.yml)");
|
||||
Logger.warning(" ");
|
||||
Logger.warning("Following parts are missing:");
|
||||
|
||||
@@ -116,7 +123,9 @@ public class ConfigUpdater {
|
||||
});
|
||||
|
||||
Logger.warning(" ");
|
||||
Logger.warning("How to read? Check out the newly generated " + HOW_TO_READ_FILE_NAME + " file. ^^");
|
||||
Logger.warning("You don't know how to interpret the missing parts? No worries.");
|
||||
Logger.warning("A new file has been created which explains with examples on how to read and apply the missing parts.");
|
||||
Logger.warning("-> ./plugins/ProAntiTab/" + HOW_TO_READ_FILE_NAME);
|
||||
Logger.warning(" ");
|
||||
}
|
||||
}
|
||||
@@ -108,6 +108,10 @@ public class Group implements Serializable {
|
||||
|
||||
public void add(String command) {
|
||||
this.generalGroupBlacklist.add(command).save();
|
||||
|
||||
if (command.startsWith("plugin=") || command.startsWith("!")) {
|
||||
this.generalGroupBlacklist.load();
|
||||
}
|
||||
}
|
||||
|
||||
public void add(String command, String server) {
|
||||
@@ -118,6 +122,10 @@ public class Group implements Serializable {
|
||||
|
||||
public void remove(String command) {
|
||||
this.generalGroupBlacklist.remove(command).save();
|
||||
|
||||
if (command.startsWith("plugin=") || command.startsWith("!")) {
|
||||
this.generalGroupBlacklist.load();
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(String command, String server) {
|
||||
@@ -128,6 +136,7 @@ public class Group implements Serializable {
|
||||
|
||||
public void clear() {
|
||||
this.generalGroupBlacklist.clear().save();
|
||||
this.generalGroupBlacklist.load();
|
||||
}
|
||||
|
||||
public void clear(String server) {
|
||||
|
||||
@@ -55,30 +55,38 @@ public class GroupManager {
|
||||
return playerGroups;
|
||||
}
|
||||
|
||||
public static boolean canAccessCommand(Object targetObj, String unmodifiedCommand, Storage.Blacklist.BlockType type) {
|
||||
public static AccessResult canAccessCommand(Object targetObj, String unmodifiedCommand, Storage.Blacklist.BlockType type) {
|
||||
return canAccessCommand(targetObj, unmodifiedCommand, type, null);
|
||||
}
|
||||
|
||||
public static boolean canAccessCommand(Object targetObj, String unmodifiedCommand, Storage.Blacklist.BlockType type, String server) {
|
||||
public static AccessResult
|
||||
canAccessCommand(Object targetObj, String unmodifiedCommand, Storage.Blacklist.BlockType type, String server) {
|
||||
final CommandSender sender = CommandSenderHandler.from(targetObj);
|
||||
|
||||
if (sender == null) {
|
||||
Logger.warning("Failed to load player! (GroupManager#62)");
|
||||
return false;
|
||||
Logger.warning("Failed to load player! (GroupManager#66)");
|
||||
return AccessResult.UNKNOWN;
|
||||
}
|
||||
|
||||
final List<Group> playerGroups = sender.getGroups();
|
||||
|
||||
if (playerGroups == null || playerGroups.isEmpty()) {
|
||||
return false;
|
||||
return AccessResult.NO_GROUPS;
|
||||
}
|
||||
|
||||
String command = type.toString() + unmodifiedCommand;
|
||||
|
||||
boolean permitted = false;
|
||||
String command = type.toString() + unmodifiedCommand;
|
||||
String allCommand = type + "*";
|
||||
String negatedCommand = type.toString() + BlockType.NEGATE + unmodifiedCommand;
|
||||
|
||||
boolean all = false,
|
||||
permitted = false,
|
||||
negated = false;
|
||||
|
||||
for (Group group : playerGroups) {
|
||||
|
||||
all = group.contains(allCommand);
|
||||
permitted = group.contains(command);
|
||||
negated = group.contains(negatedCommand);
|
||||
|
||||
if (permitted) {
|
||||
break;
|
||||
@@ -90,21 +98,35 @@ public class GroupManager {
|
||||
|
||||
for (String s : servers) {
|
||||
|
||||
if (group.contains(command, s)) {
|
||||
permitted = true;
|
||||
break;
|
||||
if (!all) {
|
||||
all = group.contains(allCommand, s);
|
||||
}
|
||||
|
||||
if (!permitted) {
|
||||
permitted = group.contains(command, s);
|
||||
}
|
||||
|
||||
if (!negated) {
|
||||
negated = group.contains(negatedCommand, s);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (negated) {
|
||||
return AccessResult.NEGATED;
|
||||
}
|
||||
|
||||
if (all) {
|
||||
return AccessResult.ALLOWED;
|
||||
}
|
||||
|
||||
if (!permitted && type != BlockType.BOTH)
|
||||
return canAccessCommand(targetObj, unmodifiedCommand, Storage.Blacklist.BlockType.BOTH, server);
|
||||
|
||||
return permitted;
|
||||
return permitted ? AccessResult.ALLOWED : AccessResult.NOT_LISTED;
|
||||
}
|
||||
|
||||
public static void setGroup(String groupName, List<String> commands) {
|
||||
@@ -251,4 +273,19 @@ public class GroupManager {
|
||||
public static boolean isGroupRegistered(String groupName) {
|
||||
return getGroupByName(groupName) != null;
|
||||
}
|
||||
|
||||
public enum AccessResult {
|
||||
ALLOWED(true), NEGATED(false),
|
||||
NO_GROUPS(false), NOT_LISTED(false),
|
||||
UNKNOWN(false);
|
||||
|
||||
private final boolean bool;
|
||||
AccessResult(boolean bool) {
|
||||
this.bool = bool;
|
||||
}
|
||||
|
||||
public boolean asBoolean() {
|
||||
return this.bool;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package de.rayzs.pat.utils.permission;
|
||||
import java.util.*;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.adapter.GroupManagerAdapter;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
@@ -24,6 +25,10 @@ public class PermissionUtil {
|
||||
}
|
||||
|
||||
public static void reloadPermissions(UUID uuid) {
|
||||
if (uuid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
resetPermissions(uuid);
|
||||
setPlayerPermissions(uuid);
|
||||
|
||||
|
||||
@@ -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.1.0
|
||||
version: 2.2.0
|
||||
main: de.rayzs.pat.plugin.BungeeLoader
|
||||
|
||||
softDepends: [LuckPerms, PAPIProxyBridge]
|
||||
@@ -64,6 +64,15 @@ turn-blacklist-to-whitelist: true
|
||||
# Pro tip: You can also just use auto-lowercase-commands feature instead. ^^
|
||||
base-command-case-sensitive: true
|
||||
|
||||
# (!) Warning:
|
||||
# Enabling this could lead to performance issues depending on
|
||||
# the amount of players and commands. (> 1100)
|
||||
#
|
||||
# This allows PAT groups to block commands, which have been allowed
|
||||
# inside the global section. This can be achieved by negating commands
|
||||
# inside a PAT group.
|
||||
allow-group-overruling: false
|
||||
|
||||
# (!) Warning:
|
||||
# Enabling this could lead to performance issues if many players
|
||||
# change worlds frequently in a short amount of time.
|
||||
@@ -178,6 +187,9 @@ custom-version:
|
||||
# You can bypass this restriction with the proantitab.namespace permission.
|
||||
block-namespace-commands:
|
||||
enabled: false
|
||||
# Basically blocks the command execution no matter if
|
||||
# 'cancel-blocked-commands' is enabled or not.
|
||||
always-block-command: true
|
||||
|
||||
#>> HTP (Overwritten)
|
||||
# Auto lowercase all commands when being executed,
|
||||
@@ -271,6 +283,15 @@ perms-check:
|
||||
player-is-missing: "&cPlease specify the player whose permission you want to check."
|
||||
player-not-online: "&c%player% is not online!"
|
||||
|
||||
extract:
|
||||
usage: '&7Usage: &f/pat extract [plugin] <use-colon> &7or &f<group> <use-colon>'
|
||||
plugin-not-found: '&cPlugin %plugin% not found!'
|
||||
success: '&aSuccessfully extracted &e%amount% &anew commands from %plugin%!'
|
||||
|
||||
convert:
|
||||
converter-not-found: '&cConverter or necessary files could not be found!'
|
||||
success: '&aSuccessfully converted &e%converter% &ainto the PAT storage.yml!'
|
||||
|
||||
help:
|
||||
- '&7Available commands are: &f/%label%&7... &8[&fBUKKIT&8]'
|
||||
- '&7Format: &8<optional> (required)'
|
||||
@@ -280,6 +301,8 @@ help:
|
||||
- '&f postdebug &7to post the PAT logs'
|
||||
- '&f update <player> &7to update player(s) permissions'
|
||||
- "&f perms <player> &7to check a player's permissions"
|
||||
- "&f extract (plugin) &7to extract all plugin commands"
|
||||
- "&f convert (plugin) &7converts into a PAT storage.yml"
|
||||
- '&f add/rem (command) &8<group> &7to manage the list'
|
||||
- '&f clear &8<group> &7to clear the list'
|
||||
- '&f creategroup (group) &7to create a group'
|
||||
|
||||
@@ -32,7 +32,6 @@ updater:
|
||||
# In other words, the backend servers won't receive any updates from the proxy about the storage.yml.
|
||||
# It's here to prevent any unnecessary communication between the proxy and the backend servers, if PAT is being used on the proxy alone.
|
||||
# For why this can be the case, read the following: https://github.com/RayzsYT/ProAntiTab/wiki/FAQ#can-i-install-pat-just-on-my-proxy-server
|
||||
# It is NOT recommended to enable this option, unless you know what you are doing.
|
||||
disable-sync: false
|
||||
|
||||
# This is a very necessary feature if you have way too many commands to block and instead decide
|
||||
@@ -48,6 +47,15 @@ turn-blacklist-to-whitelist: true
|
||||
# /HelP --> Allowed
|
||||
base-command-case-sensitive: true
|
||||
|
||||
# (!) Warning:
|
||||
# Enabling this could lead to performance issues depending on
|
||||
# the amount of players and commands. (> 1100)
|
||||
#
|
||||
# This allows PAT groups to block commands, which have been allowed
|
||||
# inside the global section. This can be achieved by negating commands
|
||||
# inside a PAT group.
|
||||
allow-group-overruling: false
|
||||
|
||||
# Here you can customize the server version that is displayed on a ping. (The text at the player-count)
|
||||
custom-protocol-ping:
|
||||
enabled: true
|
||||
@@ -145,6 +153,9 @@ custom-version:
|
||||
# You can bypass this restriction with the proantitab.namespace permission.
|
||||
block-namespace-commands:
|
||||
enabled: false
|
||||
# Basically blocks the command execution no matter if
|
||||
# 'cancel-blocked-commands' is enabled or not.
|
||||
always-block-command: true
|
||||
|
||||
# Patches a small exploit which causes the server to lag.
|
||||
# Due to the fact that PAT interacts directly with Tab-Completions and their packets,
|
||||
@@ -236,6 +247,10 @@ perms-check:
|
||||
player-is-missing: "&cPlease specify the player whose permission you want to check."
|
||||
player-not-online: "&c%player% is not online!"
|
||||
|
||||
convert:
|
||||
converter-not-found: '&cConverter or necessary files could not be found!'
|
||||
success: '&aSuccessfully converted &e%converter% &ainto the PAT storage.yml!'
|
||||
|
||||
help:
|
||||
- '&7Available commands are: &f/%label%&7... &8[&fPROXY&8]'
|
||||
- '&7Format: &8<optional> (required)'
|
||||
@@ -245,6 +260,7 @@ help:
|
||||
- '&f postdebug &7to post the PAT logs'
|
||||
- '&f update <player> &7to update player(s) permissions'
|
||||
- "&f perms <player> &7to check a player's permissions"
|
||||
- "&f convert (plugin) &7converts into a PAT storage.yml"
|
||||
- '&f add/rem (command) &8<group> &7to manage the list'
|
||||
- '&f clear &8<group> &7to clear the list'
|
||||
- '&f creategroup (group) &7to create a group'
|
||||
|
||||
@@ -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.1.0
|
||||
version: 2.2.0
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
main: de.rayzs.pat.plugin.BukkitLoader
|
||||
|
||||
Reference in new issue
Block a user