Compare commits

...
42 Commits
Author SHA1 Message Date
RayzsYT 1f7e6cd77a Fix exception on <1.21 servers 2024-10-31 20:38:40 +01:00
RayzsYT 34cba027f9 Even more improved server-based commands 2024-10-31 20:30:39 +01:00
RayzsYT db42fc1295 Updated version 2024-10-31 20:00:53 +01:00
RayzsYT 5270a432e9 Improve per-server functionality (same server-endings) 2024-10-31 19:56:25 +01:00
RayzsYT ab052d62b5 Minor code improvement 2024-10-31 12:55:21 +01:00
RayzsYT a878944b33 Updated version name 2024-10-27 13:04:34 +01:00
RayzsYT cb349e8abb Fixed CustomServerBrand issues with Folia 2024-10-27 13:02:25 +01:00
RayzsYT 95963b59b8 Fixed Folia server version detection error 2024-10-27 02:26:13 +02:00
RayzsYT ce1a326f5b Removed debug message 2024-10-26 22:01:23 +02:00
RayzsYT aef3c3edfc Fixed issue with PacketInjector on Folia servers 2024-10-26 22:01:09 +02:00
RayzsYT 4332f677f9 Fixed subargs-tabcompletion issue for custom-version & custom-plugins feature 2024-10-26 20:47:49 +02:00
RayzsYT 298e98b06d Removed sending empty messages 2024-10-24 23:08:16 +02:00
RayzsYT c419444481 Fixed Pattern-issue with * 2024-10-20 03:36:42 +02:00
RayzsYT 3206a616b9 Change event call-methods 2024-10-19 20:45:46 +02:00
RayzsYT 3fd9328842 Update Version 2024-10-19 20:31:36 +02:00
RayzsYT e39939598b Implemented ServerPlayersChangeEvent & fixed minor CustomServerBrand issue 2024-10-19 20:29:10 +02:00
RayzsYT cc02837035 Change event call-methods 2024-10-19 20:22:29 +02:00
RayzsYT 0c8b50b32f Change event call-methods 2024-10-19 20:22:04 +02:00
RayzsYT b5833c05b2 Change event call-methods 2024-10-19 20:21:41 +02:00
RayzsYT 810ed9982c Implemented ServerPlayersChangeEvent 2024-10-19 19:59:42 +02:00
RayzsYT cc470740af Add Event 2024-10-19 19:59:21 +02:00
RayzsYT ed8d5e0cf3 Nothing 2024-10-19 18:34:35 +02:00
RayzsYT 161eafeea7 Fix ConcurrentModificationException ( Credits: xii69/ProAntiTab@8491e3eb30 ) 2024-10-19 18:33:55 +02:00
RayzsYT b4c54101c9 Nothing. Just test ([Test](https://github.com/RayzsYT/ProAntiTab)) 2024-10-19 18:23:47 +02:00
RayzsYT 729b1ccf8d Remove debug message 2024-10-13 14:13:06 +02:00
RayzsYT 3f14a091ec Fix Folia Support 2024-10-10 00:12:49 +02:00
RayzsYT 8282a0147b Fixed Issue With SignedVelocity 2024-10-10 00:07:42 +02:00
RayzsYT b4628443d4 Change Description 2024-10-09 22:40:38 +02:00
RayzsYT 60516283e2 Modify PatchExploit Integration 2024-10-08 22:44:21 +02:00
RayzsYT b3e622d652 Add Check 2024-10-08 22:31:55 +02:00
RayzsYT 1ee5623a80 Reposition 2024-10-08 22:21:53 +02:00
RayzsYT 419d1ae508 Update Version 2024-10-08 22:19:54 +02:00
RayzsYT a9eaa531e7 Update 2024-10-08 22:19:27 +02:00
RayzsYT ff7e3cd444 Update 2024-10-08 22:18:19 +02:00
RayzsYT abb4c5404f Implement PatchExploit 2024-10-08 22:10:02 +02:00
RayzsYT c804ec51bd Add PatchExploit Section 2024-10-08 22:09:51 +02:00
RayzsYT cc025c52b1 Add Methods 2024-10-08 22:09:36 +02:00
RayzsYT c29bab0e84 Add Method 2024-10-08 22:09:25 +02:00
RayzsYT ab74e04a53 Add New Section 2024-10-08 22:09:13 +02:00
RayzsYT 8713aafc27 Add Methods 2024-10-08 22:09:03 +02:00
RayzsYT 60e3188990 Fix 1.21.1 Meteor Exploit 2024-10-08 21:29:35 +02:00
RayzsYT 97abf3834b Update Version 2024-10-08 21:29:21 +02:00
36 changed files with 422 additions and 101 deletions

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>de.rayzs.pat</groupId>
<artifactId>ProAntiTab</artifactId>
<version>1.8.0</version>
<version>1.8.5</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
@@ -5,6 +5,8 @@ import de.rayzs.pat.utils.message.MessageTranslator;
import java.util.concurrent.atomic.AtomicInteger;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.plugin.BukkitLoader;
import de.rayzs.pat.utils.scheduler.PATScheduler;
import de.rayzs.pat.utils.scheduler.PATSchedulerTask;
import io.netty.channel.Channel;
import de.rayzs.pat.api.brand.*;
import org.bukkit.entity.Player;
@@ -19,7 +21,7 @@ public class BukkitServerBrand implements ServerBrand {
private static final List<Player> MODIFIED_BRAND_PLAYERS = new ArrayList<>();
private static final Server SERVER = Bukkit.getServer();
private static String BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0);
private static int TASK = -1;
private static PATSchedulerTask TASK;
private static boolean INITIALIZED = false;
private static Class<?> brandPayloadClass, clientBoundCustomPacketPayloadPacketClass, customPacketPayloadPacketClass;
@@ -48,9 +50,9 @@ public class BukkitServerBrand implements ServerBrand {
exception.printStackTrace();
}
if(TASK != -1) {
Bukkit.getScheduler().cancelTask(TASK);
TASK = -1;
if(TASK != null && TASK.isActive()) {
TASK.cancelTask();
TASK = null;
MODIFIED_BRAND_PLAYERS.clear();
}
@@ -58,12 +60,13 @@ public class BukkitServerBrand implements ServerBrand {
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0) + "§r";
TASK = Bukkit.getScheduler().scheduleAsyncRepeatingTask(BukkitLoader.getPlugin(), () -> {
PATScheduler.createAsyncScheduler(() -> {
Bukkit.getOnlinePlayers().forEach(this::send);
}, 1, Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY);
} else {
AtomicInteger animationState = new AtomicInteger(0);
TASK = Bukkit.getScheduler().scheduleAsyncRepeatingTask(BukkitLoader.getPlugin(), () -> {
TASK = PATScheduler.createAsyncScheduler(() -> {
if (animationState.getAndIncrement() >= Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().size() - 1)
animationState.set(0);
BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(animationState.get()) + "§r";
@@ -151,7 +151,7 @@ public class Communicator {
bundle = new CommunicationPackets.PacketBundle(Storage.TOKEN, serverId, commandsPacket, groupsPacket);
clientInfo.sendBytes(CommunicationPackets.convertToBytes(bundle));
PATEventHandler.call(bundle, serverName);
PATEventHandler.callSentSyncEvents(bundle, serverName);
}
public static void sendRequest() {
@@ -9,7 +9,7 @@ public class PATEventHandler {
private static List<PATEvent> EVENTS = new ArrayList<>();
public static ExecuteCommandEvent call(Object senderObj, String command, boolean blocked) {
public static ExecuteCommandEvent callExecuteCommandEvents(Object senderObj, String command, boolean blocked) {
ExecuteCommandEvent event = EmptyEvent.createEmptyExecuteCommandEvent(senderObj, command, blocked);
for (PATEvent patEvent : EVENTS) {
@@ -22,7 +22,7 @@ public class PATEventHandler {
return event;
}
public static FilteredSuggestionEvent call(Object senderObj, List<String> suggestions) {
public static FilteredSuggestionEvent callFilteredSuggestionEvents(Object senderObj, List<String> suggestions) {
FilteredSuggestionEvent event = EmptyEvent.createEmptyFilteredSuggestionEvent(senderObj, suggestions);
for (PATEvent patEvent : EVENTS) {
@@ -35,7 +35,7 @@ public class PATEventHandler {
return event;
}
public static FilteredTabCompletionEvent call(Object senderObj, String cursor, List<String> completion) {
public static FilteredTabCompletionEvent callFilteredTabCompletionEvents(Object senderObj, String cursor, List<String> completion) {
FilteredTabCompletionEvent event = EmptyEvent.createEmptyFilteredTabCompletion(senderObj, cursor, completion);
for (PATEvent patEvent : EVENTS) {
@@ -48,7 +48,20 @@ public class PATEventHandler {
return event;
}
public static UpdatePluginEvent call() {
public static ServerPlayersChangeEvent callServerPlayersChangeEvents(Object senderObj, ServerPlayersChangeEvent.Type type) {
ServerPlayersChangeEvent event = EmptyEvent.createEmptyServerPlayersChangeEvent(senderObj, type);
for (PATEvent patEvent : EVENTS) {
if(patEvent instanceof ServerPlayersChangeEvent) {
ServerPlayersChangeEvent serverPlayersChangeEvent = (ServerPlayersChangeEvent) patEvent;
serverPlayersChangeEvent.handle(event);
}
}
return event;
}
public static UpdatePluginEvent callUpdatePluginEvents() {
UpdatePluginEvent event = EmptyEvent.createEmptyUpdatePluginEvent();
for (PATEvent patEvent : EVENTS) {
@@ -61,7 +74,7 @@ public class PATEventHandler {
return event;
}
public static UpdatePlayerCommandsEvent call(Object playerObj, List<String> commands, boolean serverBased) {
public static UpdatePlayerCommandsEvent callUpdatePlayerCommandsEvents(Object playerObj, List<String> commands, boolean serverBased) {
UpdatePlayerCommandsEvent event = EmptyEvent.createEmptyUpdatePlayerCommandsEvent(playerObj, commands, serverBased);
for (PATEvent patEvent : EVENTS) {
@@ -74,7 +87,7 @@ public class PATEventHandler {
return event;
}
public static SentSyncEvent call(CommunicationPackets.PacketBundle packetBundle, String serverName) {
public static SentSyncEvent callSentSyncEvents(CommunicationPackets.PacketBundle packetBundle, String serverName) {
SentSyncEvent event = EmptyEvent.createEmptySentSyncEvent(packetBundle, serverName);
for (PATEvent patEvent : EVENTS) {
@@ -87,7 +100,7 @@ public class PATEventHandler {
return event;
}
public static ReceiveSyncEvent call(CommunicationPackets.PacketBundle packetBundle) {
public static ReceiveSyncEvent callReceiveSyncEvents(CommunicationPackets.PacketBundle packetBundle) {
ReceiveSyncEvent event = EmptyEvent.createEmptyReceiveSyncEvent(packetBundle);
for (PATEvent patEvent : EVENTS) {
@@ -110,6 +123,15 @@ public class PATEventHandler {
public static class EmptyEvent {
public static ServerPlayersChangeEvent createEmptyServerPlayersChangeEvent(Object senderObj, ServerPlayersChangeEvent.Type type) {
return new ServerPlayersChangeEvent(senderObj, type) {
@Override
public void handle(ServerPlayersChangeEvent event) {
}
};
}
public static SentSyncEvent createEmptySentSyncEvent(CommunicationPackets.PacketBundle packetBundle, String serverName) {
return new SentSyncEvent(null, packetBundle, serverName) {
@Override
@@ -0,0 +1,20 @@
package de.rayzs.pat.api.event.events;
import de.rayzs.pat.api.event.PATEvent;
public abstract class ServerPlayersChangeEvent extends PATEvent<ServerPlayersChangeEvent> {
private final Type type;
public ServerPlayersChangeEvent(Object senderObj, Type type) {
super(senderObj);
this.type = type;
}
public ServerPlayersChangeEvent() {
super(null);
this.type = Type.UNKNOWN;
}
public enum Type { JOINED, LEFT, UNKNOWN }
}
@@ -121,7 +121,7 @@ public class BukkitPacketAnalyzer {
UUID uuid = player.getUniqueId();
if(packetName.equals("ClientboundCommandSuggestionsPacket") && SENT_PACKET.contains(player.getUniqueId())) {
if((packetName.equals("ClientboundCommandSuggestionsPacket") || Reflection.isFoliaServer()) && SENT_PACKET.contains(player.getUniqueId())) {
Object newPacketObj = SENT_PACKET.get(uuid);
SENT_PACKET.remove(uuid);
super.write(channel, newPacketObj, promise);
@@ -42,7 +42,7 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
}
cancelsBeforeHand = Storage.Blacklist.isBlocked(player, input, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input);
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(input);
} else return true;
for (Field field : Reflection.getFields(packetObj)) {
@@ -7,11 +7,14 @@ import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.plugin.BukkitLoader;
import de.rayzs.pat.api.netty.bukkit.*;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.utils.scheduler.PATScheduler;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import de.rayzs.pat.utils.*;
import java.lang.reflect.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ModernPacketHandler implements BukkitPacketHandler {
@@ -26,6 +29,12 @@ public class ModernPacketHandler implements BukkitPacketHandler {
}
String text = (String) stringField.get(packetObj);
if(Storage.ConfigSections.Settings.PATCH_EXPLOITS.isMalicious(text)) {
MessageTranslator.send(Bukkit.getConsoleSender(), Storage.ConfigSections.Settings.PATCH_EXPLOITS.ALERT_MESSAGE.get().replace("%player%", player.getName()));
PATScheduler.createScheduler(() -> player.kickPlayer(ChatColor.translateAlternateColorCodes('&', Storage.ConfigSections.Settings.PATCH_EXPLOITS.KICK_MESSAGE.get())));
return false;
}
BukkitPacketAnalyzer.insertPlayerInput(player, text);
return true;
}
@@ -33,13 +42,15 @@ public class ModernPacketHandler implements BukkitPacketHandler {
@Override
public boolean handleOutgoingPacket(Player player, Object packetObj) throws Exception {
Object suggestionObj;
String rawInput = BukkitPacketAnalyzer.getPlayerInput(player), input = rawInput;
if(input == null) return false;
boolean cancelsBeforeHand = false;
boolean is121Packet = packetObj.getClass().getSimpleName().equals("ClientboundCommandSuggestionsPacket"),
cancelsBeforeHand = false;
int spaces = 0;
if(input.startsWith("/")) {
if(input.startsWith("/") || is121Packet) {
input = input.replace("/", "");
if(input.contains(" ")) {
String[] split = input.split(" ");
@@ -48,10 +59,10 @@ public class ModernPacketHandler implements BukkitPacketHandler {
}
cancelsBeforeHand = Storage.Blacklist.isBlocked(player, input, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input);
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(input);
}
if(packetObj.getClass().getSimpleName().equals("ClientboundCommandSuggestionsPacket")) {
if(is121Packet || Reflection.isFoliaServer() && packetObj.getClass().getSimpleName().equals("PacketPlayOutTabComplete")) {
try {
Field suggestionsField = Reflection.getFieldsByTypeNormal(packetObj.getClass(), "List", Reflection.SearchOption.ENDS).get(0);
List<?> suggestionsTmp = (List<?>) suggestionsField.get(packetObj),
@@ -62,8 +73,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
start = (int) intFields.get(1).get(packetObj),
length = (int) intFields.get(2).get(packetObj);
Class<?> clientboundCommandSuggestionsPacketClass = Class.forName("net.minecraft.network.protocol.game.ClientboundCommandSuggestionsPacket");
Class<?> clientboundCommandSuggestionsPacketClass = Class.forName("net.minecraft.network.protocol.game." + (packetObj.getClass().getSimpleName().equals("PacketPlayOutTabComplete") ? "PacketPlayOutTabComplete" : "ClientboundCommandSuggestionsPacket"));
if ((input.isEmpty() || cancelsBeforeHand) && Reflection.isWeird()) return false;
if (spaces >= 1 && cancelsBeforeHand || !BukkitLoader.isLoaded()) {
suggestions.clear();
@@ -82,7 +92,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
for (Object suggestion : suggestions)
suggestionsAsString.add(getSuggestionFromEntry(suggestion));
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.call(player.getUniqueId(), rawInput, suggestionsAsString);
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, suggestionsAsString);
if (filteredTabCompletionEvent.isCancelled()) suggestions.clear();
for (int i = 0; i < suggestions.size(); i++) {
@@ -99,9 +109,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
Object clientboundCommandSuggestionsPacketObj = clientboundCommandSuggestionsPacketClass
.getConstructor(int.class, int.class, int.class, List.class)
.newInstance(id, start, length, suggestions);
BukkitPacketAnalyzer.sendPacket(player.getUniqueId(), clientboundCommandSuggestionsPacketObj);
return false;
} catch (Throwable throwable) { throwable.printStackTrace(); }
@@ -137,7 +145,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
for (Suggestion suggestion : suggestions.getList())
suggestionsAsString.add(suggestion.getText());
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.call(player.getUniqueId(), rawInput, suggestionsAsString);
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, suggestionsAsString);
if(filteredTabCompletionEvent.isCancelled()) suggestions.getList().clear();
suggestions.getList().removeIf(suggestion -> !filteredTabCompletionEvent.getCompletion().contains(suggestion.getText()));
}
@@ -197,7 +197,7 @@ public class BungeePacketAnalyzer {
if(!playerInput.equals("/")) {
cancelsBeforeHand = Storage.Blacklist.isBlocked(player, StringUtils.replaceFirst(playerInput, "/", ""), !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, server);
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(StringUtils.replaceFirst(playerInput, "/", ""));
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(StringUtils.replaceFirst(playerInput, "/", ""));
}
final String cursor = playerInput;
if(cursor.startsWith("/")) {
@@ -1,18 +1,24 @@
package de.rayzs.pat.api.netty.proxy;
import com.mojang.brigadier.tree.CommandNode;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.proxy.crypto.SignedChatCommand;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.packet.chat.session.UnsignedPlayerCommandPacket;
import de.rayzs.pat.api.brand.CustomServerBrand;
import de.rayzs.pat.plugin.listeners.velocity.VelocityBlockCommandListener;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.utils.permission.PermissionUtil;
import com.velocitypowered.proxy.protocol.packet.*;
import java.lang.reflect.Field;
import java.util.concurrent.ConcurrentHashMap;
import com.velocitypowered.api.proxy.Player;
import de.rayzs.pat.plugin.VelocityLoader;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.*;
import io.netty.channel.*;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import java.util.*;
public class VelocityPacketAnalyzer {
@@ -23,7 +29,7 @@ public class VelocityPacketAnalyzer {
private static final HashMap<Player, String> PLAYER_INPUT_CACHE = new HashMap<>();
private static HashMap<String, CommandsCache> COMMANDS_CACHE_MAP = new HashMap<>();
private static Class<?> minecraftConnectionClass, connectedPlayerConnectionClass;
private static Class<?> minecraftConnectionClass, connectedPlayerConnectionClass, signedChatCommandPacketClass;
public static void injectAll() {
VelocityLoader.getServer().getAllPlayers().forEach(VelocityPacketAnalyzer::inject);
@@ -112,11 +118,40 @@ public class VelocityPacketAnalyzer {
MinecraftPacket packet = (MinecraftPacket) msg;
if(packet.getClass().getSimpleName().equals("SignedChatCommand")) {
try {
if(signedChatCommandPacketClass == null)
signedChatCommandPacketClass = Class.forName("com.velocitypowered.proxy.crypto.SignedChatCommand");
Object signedChatCommandPacket = signedChatCommandPacketClass.cast(packet);
Field commandField = signedChatCommandPacket.getClass().getField("command");
String command = (String) commandField.get(signedChatCommandPacket);
if(!VelocityBlockCommandListener.handleCommand(player, command))
return;
} catch (Exception exception) {
exception.printStackTrace();
}
}
if(packet instanceof UnsignedPlayerCommandPacket) {
UnsignedPlayerCommandPacket unsignedPlayerCommandPacket = (UnsignedPlayerCommandPacket) packet;
if(!VelocityBlockCommandListener.handleCommand(player, unsignedPlayerCommandPacket.getCommand()))
return;
}
if(packet instanceof TabCompleteRequestPacket) {
TabCompleteRequestPacket request = (TabCompleteRequestPacket) msg;
if(request.getCommand() != null) {
insertPlayerInput(player, request.getCommand());
super.channelRead(ctx, msg);
if(Storage.ConfigSections.Settings.PATCH_EXPLOITS.isMalicious(request.getCommand())) {
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), Storage.ConfigSections.Settings.PATCH_EXPLOITS.ALERT_MESSAGE.get().replace("%player%", player.getUsername()));
player.disconnect(LegacyComponentSerializer.legacyAmpersand().deserialize(Storage.ConfigSections.Settings.PATCH_EXPLOITS.KICK_MESSAGE.get()));
} else {
insertPlayerInput(player, request.getCommand());
super.channelRead(ctx, msg);
}
}
} else super.channelRead(ctx, msg);
}
@@ -154,7 +189,7 @@ public class VelocityPacketAnalyzer {
if(!playerInput.equals("/")) {
cancelsBeforeHand = Storage.Blacklist.isBlocked(player, StringUtils.replaceFirst(playerInput, "/", ""), !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, server);
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(StringUtils.replaceFirst(playerInput, "/", ""));
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(StringUtils.replaceFirst(playerInput, "/", ""));
}
final String cursor = playerInput;
@@ -35,7 +35,7 @@ public class Storage {
loadToken();
if(loadBlacklist) Blacklist.loadAll();
PATEventHandler.call();
PATEventHandler.callUpdatePluginEvents();
}
public static void loadToken() {
@@ -108,6 +108,7 @@ public class Storage {
public static BlockNamespaceCommandsSection BLOCK_NAMESPACE_COMMANDS = new BlockNamespaceCommandsSection();
public static HandleThroughProxySection HANDLE_THROUGH_PROXY = new HandleThroughProxySection();
public static PatchExploitSection PATCH_EXPLOITS = new PatchExploitSection();
public static CustomBrandSection CUSTOM_BRAND = new CustomBrandSection();
public static CancelCommandSection CANCEL_COMMAND = new CancelCommandSection();
public static CustomPluginsSection CUSTOM_PLUGIN = new CustomPluginsSection();
@@ -188,7 +189,7 @@ public class Storage {
public static class Blacklist {
private static HashMap<String, GeneralBlacklist> SERVER_BLACKLISTS = new HashMap<>();
private static final HashMap<String, GeneralBlacklist> SERVER_BLACKLISTS = new HashMap<>();
private static final GeneralBlacklist BLACKLIST = BlacklistCreator.createGeneralBlacklist();
private static final IgnoredServersStorage IGNORED_SERVERS = new GeneralIgnoredServers();
private static final ExpireCache<String, List<GeneralBlacklist>> CACHED_SERVER_BLACKLIST = new ExpireCache<>(1, TimeUnit.HOURS);
@@ -341,13 +342,22 @@ public class Storage {
}
public static boolean isListed(Object playerObj, String command, boolean intensive, boolean listed, boolean slash, String server) {
return isListed(playerObj, command, intensive, listed, slash, server, false);
}
public static boolean isListed(Object playerObj, String command, boolean intensive, boolean listed, boolean slash, String server, boolean instantReturn) {
if(GroupManager.getGroupsByServer(server).stream().anyMatch(group -> isInListed(command, group.getAllCommands(server), intensive) && group.hasPermission(playerObj)))
return false;
if(!listed) for (GeneralBlacklist blacklist : getBlacklists(server)) {
if(listed) return true;
for (GeneralBlacklist blacklist : getBlacklists(server)) {
listed = blacklist.isListed(command, intensive, true, slash);
if(instantReturn) return listed;
if(listed) break;
}
return listed;
}
@@ -370,18 +380,26 @@ public class Storage {
if(focusOnBlock && blockedGlobal) return true;
for (GeneralBlacklist blacklist : getBlacklists(server)) {
if(!focusOnBlock) {
blockedServer = blacklist.isBlockedIgnorePermission(command, intensive);
if (blockedServer) break;
} else {
if(blacklist.isBlocked(command, intensive)) return true;
if(focusOnBlock && blacklist.isBlocked(command, intensive))
return true;
blockedServer = blacklist.isBlockedIgnorePermission(command, intensive);
break;
/* Former code
if (!blacklist.isBlockedIgnorePermission(command, intensive)) {
blockedServer = false;
break;
}
blockedServer = true;
*/
}
blocked = turn ? blockedGlobal && blockedServer : blockedServer || blockedGlobal;
if(!blocked
&& CACHED_SERVER_BLACKLIST.contains(server)
&& CACHED_SERVER_BLACKLIST.get(server).size() == 0)
&& CACHED_SERVER_BLACKLIST.get(server).isEmpty())
if(turn) blocked = true;
return blocked;
@@ -0,0 +1,32 @@
package de.rayzs.pat.api.storage.config.settings;
import de.rayzs.pat.api.storage.storages.ConfigStorage;
import de.rayzs.pat.utils.configuration.helper.*;
import de.rayzs.pat.utils.StringUtils;
import java.util.Collections;
public class PatchExploitSection extends ConfigStorage {
public boolean ENABLED;
public ConfigSectionHelper<String> ALERT_MESSAGE, KICK_MESSAGE;
public PatchExploitSection() {
super("patch-exploits");
}
@Override
public void load() {
super.load();
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
ALERT_MESSAGE = new ConfigSectionHelper<>(this, "alert-message", "%prefix% &4%player% &ctried to crash/lag the server.");
KICK_MESSAGE = new ConfigSectionHelper(this, "kick-message", "&cFailed to read packet! Please reconnect.");
}
public boolean isMalicious(String text) {
if(!ENABLED) return false;
return text.length() > 256
|| text.contains("nbt")
&& (StringUtils.countMatches('[', text) > 15 || StringUtils.countMatches('{', text) > 25);
}
}
@@ -219,7 +219,7 @@ public class BukkitLoader extends JavaPlugin {
BukkitAntiTabListener.handleTabCompletion(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED ? Storage.Blacklist.getBlacklist().getCommands() : getNotBlockedCommands());
}
PATEventHandler.call(packetBundle);
PATEventHandler.callReceiveSyncEvents(packetBundle);
}
public static boolean doesCommandExist(String command, boolean replace) {
@@ -28,7 +28,7 @@ import java.util.*;
@Plugin(name = "ProAntiTab",
id = "proantitab",
version = "1.8.1",
version = "1.8.5",
authors = "Rayzs_YT",
description = "Hide more than just your plugins. Hide almost everything!",
dependencies = {
@@ -55,7 +55,7 @@ public class BukkitAntiTabListener implements Listener {
final List<String> playerCommands = COMMANDS_CACHE.getPlayerCommands(event.getCommands(), player, player.getUniqueId());
event.getCommands().clear();
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.call(player, playerCommands);
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, playerCommands);
if(filteredSuggestionEvent.isCancelled()) return;
event.getCommands().addAll(filteredSuggestionEvent.getSuggestions());
@@ -43,7 +43,7 @@ public class BukkitBlockCommandListener implements Listener {
List<String> notificationMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Messages.NOTIFICATION.ALERT, "%player%", player.getName(), "%command%", command, "%world%", worldName);
if(Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command) && !PermissionUtil.hasBypassPermission(player, command)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
if(executeCommandEvent.isCancelled()) return;
@@ -59,7 +59,7 @@ public class BukkitBlockCommandListener implements Listener {
}
if(Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command) && !PermissionUtil.hasBypassPermission(player, command)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
if(executeCommandEvent.isCancelled()) return;
@@ -80,18 +80,18 @@ public class BukkitBlockCommandListener implements Listener {
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
if(Storage.Blacklist.isListed(command, true)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
return;
}
if(PermissionUtil.hasBypassPermission(player, command, false)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
return;
}
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
if(executeCommandEvent.isCancelled()) return;
@@ -101,7 +101,7 @@ public class BukkitBlockCommandListener implements Listener {
if(Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && !Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
if(executeCommandEvent.isCancelled()) return;
@@ -117,18 +117,18 @@ public class BukkitBlockCommandListener implements Listener {
}
if (!Storage.Blacklist.isListed(command, false)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
return;
}
if (PermissionUtil.hasBypassPermission(player, command, false)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
return;
}
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
if(executeCommandEvent.isCancelled()) return;
@@ -1,5 +1,7 @@
package de.rayzs.pat.plugin.listeners.bukkit;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
import de.rayzs.pat.api.brand.impl.BukkitServerBrand;
import de.rayzs.pat.api.communication.BackendUpdater;
@@ -18,13 +20,16 @@ public class BukkitPlayerConnectionListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
if(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
BackendUpdater.handle();
PermissionUtil.setPlayerPermissions(player.getUniqueId());
CustomServerBrand.preparePlayer(player);
CustomServerBrand.sendBrandToPlayer(player);
if(CustomServerBrand.isEnabled())
CustomServerBrand.sendBrandToPlayer(player);
if(!BukkitPacketAnalyzer.inject(player)) player.kickPlayer("Failed to inject player!");
@@ -40,6 +45,8 @@ public class BukkitPlayerConnectionListener implements Listener {
@EventHandler (priority = EventPriority.LOWEST)
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
BukkitPacketAnalyzer.uninject(player.getUniqueId());
PermissionUtil.resetPermissions(player.getUniqueId());
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) return;
@@ -31,7 +31,7 @@ public class BungeeAntiTabListener implements Listener {
event.getSuggestions().removeIf(command -> Storage.Blacklist.isBlocked(player, command, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, player.getServer().getInfo().getName()));
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.call(player, event.getSuggestions());
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, event.getSuggestions());
if(filteredSuggestionEvent.isCancelled()) event.getSuggestions().clear();
}
}
@@ -40,7 +40,7 @@ public class BungeeBlockCommandListener implements Listener {
List<String> notificationMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Messages.NOTIFICATION.ALERT, "%player%", player.getName(), "%command%", command, "%server%", serverName);
if(Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command) && !PermissionUtil.hasBypassPermission(player, command)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
if(executeCommandEvent.isCancelled()) return;
@@ -56,7 +56,7 @@ public class BungeeBlockCommandListener implements Listener {
}
if(Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command) && !PermissionUtil.hasBypassPermission(player, command)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
if(executeCommandEvent.isCancelled()) return;
@@ -78,22 +78,22 @@ public class BungeeBlockCommandListener implements Listener {
boolean listed, serverListed, ignored;
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
if(Storage.Blacklist.doesGroupBypass(player, command, true, true, false, serverName)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
return;
}
listed = Storage.Blacklist.isListed(command, false, true, false);
serverListed = Storage.Blacklist.isListed(player, command, false, listed, false, serverName);
serverListed = Storage.Blacklist.isListed(player, command, false, listed, false, serverName, true);
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
if(ignored ? !listed && serverListed : serverListed) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
return;
}
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
if(executeCommandEvent.isCancelled()) return;
@@ -102,7 +102,7 @@ public class BungeeBlockCommandListener implements Listener {
}
if(Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && !Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
if(executeCommandEvent.isCancelled()) return;
@@ -118,7 +118,7 @@ public class BungeeBlockCommandListener implements Listener {
}
if(Storage.Blacklist.doesGroupBypass(player, command, true, true, false, serverName)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
return;
}
@@ -128,12 +128,12 @@ public class BungeeBlockCommandListener implements Listener {
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
if(!listed && !serverListed || listed && serverListed && ignored) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
return;
}
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
if(executeCommandEvent.isCancelled()) return;
@@ -1,5 +1,7 @@
package de.rayzs.pat.plugin.listeners.bungee;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.utils.message.MessageTranslator;
@@ -18,15 +20,13 @@ public class BungeePlayerConnectionListener implements Listener {
@EventHandler (priority = EventPriority.LOWEST)
public void onPostLogin(PostLoginEvent event) {
ProxiedPlayer player = event.getPlayer();
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
if(CustomServerBrand.isEnabled() && Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
if(CustomServerBrand.isEnabled())
ProxyServer.getInstance().getScheduler().schedule(BungeeLoader.getPlugin(), () -> {
if (player.isConnected()) CustomServerBrand.sendBrandToPlayer(player);
}, 500, TimeUnit.MILLISECONDS);
}
PermissionUtil.setPlayerPermissions(player.getUniqueId());
if(Storage.OUTDATED && PermissionUtil.hasPermission(player, "joinupdate")) {
@@ -50,6 +50,7 @@ public class BungeePlayerConnectionListener implements Listener {
@EventHandler (priority = EventPriority.LOWEST)
public void onPlayerDisconnectEvent(PlayerDisconnectEvent event) {
ProxiedPlayer player = event.getPlayer();
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
PermissionUtil.resetPermissions(player.getUniqueId());
BungeePacketAnalyzer.uninject(player);
@@ -39,7 +39,7 @@ public class WaterfallAntiTabListener implements Listener {
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
event.getCommands().entrySet().removeIf(command -> playerCommands.contains(command.getKey()));
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.call(player, new ArrayList<>(event.getCommands().keySet()));
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, new ArrayList<>(event.getCommands().keySet()));
if(filteredSuggestionEvent.isCancelled()) event.getCommands().clear();
for (String commandName : filteredSuggestionEvent.getSuggestions()) {
@@ -50,6 +50,6 @@ public class WaterfallAntiTabListener implements Listener {
}
public static void updateCommands() {
COMMANDS_CACHE_MAP.values().forEach(CommandsCache::reset);
new ArrayList<>(COMMANDS_CACHE_MAP.values()).forEach(CommandsCache::reset);
}
}
@@ -26,7 +26,7 @@ public class VelocityAntiTabListener {
if(PermissionUtil.hasBypassPermission(player) || event.getSuggestions().isEmpty() || !player.getCurrentServer().isPresent()) return;
event.getSuggestions().removeIf(command -> Storage.Blacklist.isBlocked(player, command, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, player.getCurrentServer().get().getServerInfo().getName()));
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.call(player, event.getSuggestions());
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, event.getSuggestions());
if(filteredSuggestionEvent.isCancelled()) event.getSuggestions().clear();
}
@@ -61,6 +61,6 @@ public class VelocityAntiTabListener {
}
public static void updateCommands() {
COMMANDS_CACHE_MAP.values().forEach(CommandsCache::reset);
new ArrayList<>(COMMANDS_CACHE_MAP.values()).forEach(CommandsCache::reset);
}
}
@@ -3,6 +3,7 @@ package de.rayzs.pat.plugin.listeners.velocity;
import com.velocitypowered.api.event.command.CommandExecuteEvent;
import com.velocitypowered.api.command.CommandSource;
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
import de.rayzs.pat.plugin.VelocityLoader;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.utils.permission.PermissionUtil;
import com.velocitypowered.api.proxy.ProxyServer;
@@ -41,7 +42,7 @@ public class VelocityBlockCommandListener {
List<String> notificationMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Messages.NOTIFICATION.ALERT, "%player%", player.getUsername(), "%command%", command, "%server%", serverName);
if(Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
if(executeCommandEvent.isCancelled()) return;
@@ -54,7 +55,7 @@ public class VelocityBlockCommandListener {
}
if(Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
if(executeCommandEvent.isCancelled()) return;
@@ -73,7 +74,7 @@ public class VelocityBlockCommandListener {
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
if(Storage.Blacklist.doesGroupBypass(player, command, false, true, false, player.getCurrentServer().get().getServerInfo().getName())) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
return;
}
@@ -83,12 +84,12 @@ public class VelocityBlockCommandListener {
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
if(ignored ? !listed && serverListed : serverListed) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
return;
}
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
if(executeCommandEvent.isCancelled()) return;
@@ -97,7 +98,7 @@ public class VelocityBlockCommandListener {
}
if(Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && !Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
if(executeCommandEvent.isCancelled()) return;
@@ -110,7 +111,7 @@ public class VelocityBlockCommandListener {
}
if(Storage.Blacklist.doesGroupBypass(player, command, true, true, false, player.getCurrentServer().get().getServerInfo().getName())) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
return;
}
@@ -120,18 +121,18 @@ public class VelocityBlockCommandListener {
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
if(!listed && !serverListed || listed && serverListed && ignored) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
return;
}
if(Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player.getUniqueId())) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, false);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, false);
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
return;
}
ExecuteCommandEvent executeCommandEvent = PATEventHandler.call(player, rawCommand, true);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
if(executeCommandEvent.isBlocked()) event.setResult(CommandExecuteEvent.CommandResult.denied());
if(executeCommandEvent.isCancelled()) return;
@@ -140,4 +141,119 @@ public class VelocityBlockCommandListener {
if(Storage.SEND_CONSOLE_NOTIFICATION) MessageTranslator.send(server.getConsoleCommandSource(), notificationMessage);
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> server.getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(server.getPlayer(uuid).get(), notificationMessage));
}
public static boolean handleCommand(Player player, String commandSource) {
String command = commandSource,
serverName = player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "unknown";
boolean blocked = false;
command = StringUtils.replaceFirst(command, "/", "");
command = StringUtils.getFirstArg(command);
command = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
if (PermissionUtil.hasBypassPermission(player, command, false)) return true;
List<String> notificationMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Messages.NOTIFICATION.ALERT, "%player%", player.getUsername(), "%command%", command, "%server%", serverName);
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
if (executeCommandEvent.isBlocked()) blocked = true;
if (executeCommandEvent.isCancelled()) return true;
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE, "%command%", command.replaceFirst("/", ""));
if (Storage.SEND_CONSOLE_NOTIFICATION)
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> VelocityLoader.getServer().getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(VelocityLoader.getServer().getPlayer(uuid).get(), notificationMessage));
return !blocked;
}
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
if (executeCommandEvent.isBlocked()) blocked = true;
if (executeCommandEvent.isCancelled()) return true;
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE, "%command%", command.replaceFirst("/", ""));
if (Storage.SEND_CONSOLE_NOTIFICATION)
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> VelocityLoader.getServer().getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(VelocityLoader.getServer().getPlayer(uuid).get(), notificationMessage));
return !blocked;
}
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED) return true;
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE, "%command%", command.replaceFirst("/", ""));
boolean listed, serverListed, ignored;
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
if (Storage.Blacklist.doesGroupBypass(player, command, false, true, false, player.getCurrentServer().get().getServerInfo().getName())) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
return !executeCommandEvent.isBlocked();
}
listed = Storage.Blacklist.isListed(command, false, true, false);
serverListed = Storage.Blacklist.isListed(player, command, false, listed, false, serverName, true);
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
if (ignored ? !listed && serverListed : serverListed) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
return !executeCommandEvent.isBlocked();
}
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
if (executeCommandEvent.isBlocked()) blocked = true;
if (executeCommandEvent.isCancelled()) return true;
MessageTranslator.send(player, cancelCommandMessage);
return !blocked;
}
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && !Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
if (executeCommandEvent.isBlocked()) blocked = true;
if (executeCommandEvent.isCancelled()) return true;
MessageTranslator.send(player, cancelCommandMessage);
if (Storage.SEND_CONSOLE_NOTIFICATION)
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> VelocityLoader.getServer().getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(VelocityLoader.getServer().getPlayer(uuid).get(), notificationMessage));
return !blocked;
}
if (Storage.Blacklist.doesGroupBypass(player, command, true, true, false, player.getCurrentServer().get().getServerInfo().getName())) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
return !executeCommandEvent.isBlocked();
}
listed = Storage.Blacklist.isListed(command, true, true, false);
serverListed = Storage.Blacklist.isListed(player, command, true, listed, false, serverName);
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
if (!listed && !serverListed || listed && serverListed && ignored) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
return !executeCommandEvent.isBlocked();
}
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player.getUniqueId())) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
return !executeCommandEvent.isBlocked();
}
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
if (executeCommandEvent.isBlocked()) blocked = true;
if (executeCommandEvent.isCancelled()) return true;
MessageTranslator.send(player, cancelCommandMessage);
if (Storage.SEND_CONSOLE_NOTIFICATION)
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> VelocityLoader.getServer().getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(VelocityLoader.getServer().getPlayer(uuid).get(), notificationMessage));
return !blocked;
}
}
@@ -1,6 +1,8 @@
package de.rayzs.pat.plugin.listeners.velocity;
import com.velocitypowered.api.event.connection.DisconnectEvent;
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.utils.message.MessageTranslator;
import de.rayzs.pat.utils.permission.PermissionUtil;
@@ -25,15 +27,13 @@ public class VelocityConnectionListener {
@Subscribe
public void onServerPreConnect(ServerPreConnectEvent event) {
Player player = event.getPlayer();
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
if(CustomServerBrand.isEnabled() && Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
if(CustomServerBrand.isEnabled())
server.getScheduler().buildTask(loader, () -> {
if (player.isActive()) CustomServerBrand.sendBrandToPlayer(player);
}).delay(500, TimeUnit.MILLISECONDS).schedule();
}
PermissionUtil.setPlayerPermissions(player.getUniqueId());
if(Storage.OUTDATED && PermissionUtil.hasPermission(player, "joinupdate")) {
@@ -58,8 +58,9 @@ public class VelocityConnectionListener {
@Subscribe
public void onDisconnect(DisconnectEvent event) {
Player player = event.getPlayer();
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
PermissionUtil.resetPermissions(player.getUniqueId());
VelocityPacketAnalyzer.uninject(player);
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) return;
}
}
@@ -111,7 +111,7 @@ public class CommandsCache {
else
Logger.debug("Created list of commands for player with uuid " + uuidSubstring + " with a total of " + playerCommands.size() + " commands!");
PATEventHandler.call(targetObj, playerCommands, serverName != null);
PATEventHandler.callUpdatePlayerCommandsEvents(targetObj, playerCommands, serverName != null);
return playerCommands;
}
@@ -2,15 +2,15 @@ package de.rayzs.pat.utils;
import net.md_5.bungee.api.ProxyServer;
import io.netty.channel.Channel;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.lang.reflect.*;
import org.bukkit.Bukkit;
import java.util.*;
public class Reflection {
private static boolean legacy, proxy, velocity, paper, folia, weird;
private static String versionName, rawVersionName, versionPackageName;
private static String versionName, fullVersionName, rawVersionName, versionPackageName;
private static Version version;
private static int major, minor, release;
@@ -27,8 +27,8 @@ public class Reflection {
if(!proxy) {
try {
Class.forName("io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler");
folia = true;
Class.forName("com.destroystokyo.paper.proxy.VelocityProxy");
folia = versionName.toLowerCase().contains("folia");
} catch (Throwable throwable) {
folia = false;
}
@@ -274,7 +274,8 @@ public class Reflection {
public static Channel getPlayerChannel(Player player) throws Exception {
Object channelObject;
if(paper && Reflection.isWeird()) {
if(!folia && paper && Reflection.isWeird()) {
Object serverPlayerObj = getMethodsByReturnTypeAndName(player.getClass(), "ServerPlayer", SearchOption.ENDS, "getHandle").get(0).invoke(player),
serverGamePacketListenerImplObj = getFieldByName(serverPlayerObj.getClass(), "connection").get(serverPlayerObj),
connectionObj = getFieldByName(serverGamePacketListenerImplObj.getClass().getSuperclass(), "connection").get(serverGamePacketListenerImplObj);
@@ -339,9 +340,11 @@ public class Reflection {
}
}
private static void loadVersionName(Object serverObject) throws Exception {
versionName = proxy ? ProxyServer.getInstance().getName() : Bukkit.getName();
rawVersionName = (String) serverObject.getClass().getMethod("getBukkitVersion").invoke(serverObject);
fullVersionName = rawVersionName;
rawVersionName = rawVersionName.split("-")[0].replace(".", "_");
versionPackageName = serverObject.getClass().getPackage().getName();
versionPackageName = versionPackageName.substring(versionPackageName.lastIndexOf('.') + 1);
@@ -7,7 +7,7 @@ public class StringUtils {
public static String replaceFirst(String input, String trigger, String replacement) {
if (input.contains(trigger)) {
String[] split = input.split(trigger);
String[] split = input.split(trigger.equals("*") ? "\\*" : trigger);
if (split.length >= 1) {
int pointAfter = split[0].length() + trigger.length();
input = split[0] + replacement + input.substring(pointAfter);
@@ -17,6 +17,15 @@ public class StringUtils {
return input;
}
public static int countMatches(Character character, String string) {
int count = 0;
for (char c : string.toCharArray()) {
if(character == c) count++;
}
return count;
}
public static String replaceTriggers(String input, String replacement, String... triggers) {
for (String trigger : triggers) {
if(!input.contains(trigger)) continue;
@@ -89,6 +89,8 @@ public class MessageTranslator {
}
public static void send(Object target, String text, String... replacements) {
if(text.isEmpty()) return;
text = replaceMessageString(target, text, replacements);
if(text.contains("%no-message%")) return;
@@ -17,6 +17,12 @@ public class PATScheduler {
: new BukkitScheduler().getInstance(false, runnable, time);
}
public static PATSchedulerTask createScheduler(Runnable runnable) {
return Reflection.isFoliaServer()
? new FoliaScheduler().getInstance(false, runnable)
: new BukkitScheduler().getInstance(false, runnable);
}
public static PATSchedulerTask createAsyncScheduler(Runnable runnable, long time, long period) {
return Reflection.isFoliaServer()
? new FoliaScheduler().getInstance(true, runnable, time, period)
@@ -28,4 +34,10 @@ public class PATScheduler {
? new FoliaScheduler().getInstance(true, runnable, time)
: new BukkitScheduler().getInstance(true, runnable, time);
}
public static PATSchedulerTask createAsyncScheduler(Runnable runnable) {
return Reflection.isFoliaServer()
? new FoliaScheduler().getInstance(true, runnable)
: new BukkitScheduler().getInstance(true, runnable);
}
}
@@ -4,6 +4,7 @@ public interface PATSchedulerTask {
PATSchedulerTask getInstance(boolean async, Runnable runnable, long time, long period);
PATSchedulerTask getInstance(boolean async, Runnable runnable, long time);
PATSchedulerTask getInstance(boolean async, Runnable runnable);
boolean isActive();
void setTaskId(int taskId);
@@ -24,6 +24,14 @@ public class BukkitScheduler implements PATSchedulerTask {
return this;
}
@Override
public PATSchedulerTask getInstance(boolean async, Runnable runnable) {
this.taskId = async
? Bukkit.getScheduler().scheduleAsyncDelayedTask(BukkitLoader.getPlugin(), runnable)
: Bukkit.getScheduler().scheduleSyncDelayedTask(BukkitLoader.getPlugin(), runnable);
return this;
}
@Override
public boolean isActive() {
return this.taskId != 1;
@@ -23,6 +23,12 @@ public class FoliaScheduler implements PATSchedulerTask {
return this;
}
@Override
public PATSchedulerTask getInstance(boolean async, Runnable runnable) {
this.task = SCHEDULER.run(BukkitLoader.getPlugin(), __ -> runnable.run());
return this;
}
@Override
public boolean isActive() {
return !this.task.isCancelled();
+1 -1
View File
@@ -2,7 +2,7 @@ name: ProAntiTab
description: Hide more than just your plugins. Hide almost everything!
author: Rayzs_YT
version: 1.8.1
version: 1.8.5
main: de.rayzs.pat.plugin.BungeeLoader
softDepends:
@@ -118,6 +118,14 @@ custom-version:
block-namespace-commands:
enabled: false
# Patches a small exploit which causes the server to lag.
# Due to the fact that PAT interacts directly with Tab-Completions and their packets,
# it would be a waste not to provide some simple patches like these. ^^
patch-exploits:
enabled: true
alert-message: '%prefix% &4%player% &ctried to crash/lag the server.'
kick-message: '&cFailed to read packet! Please reconnect.'
#>> HTP (Overwritten)
# This feature allows you to customize your server brand you see when you press F3.
# Normally there is something like 'Purpur', or 'Spigot'.
@@ -98,6 +98,14 @@ custom-version:
block-namespace-commands:
enabled: false
# Patches a small exploit which causes the server to lag.
# Due to the fact that PAT interacts directly with Tab-Completions and their packets,
# it would be a waste not to provide some simple patches like these. ^^
patch-exploits:
enabled: true
alert-message: '%prefix% &4%player% &ctried to crash/lag the server.'
kick-message: '&cFailed to read packet! Please reconnect.'
# This feature allows you to customize your server brand you see when you press F3.
# Normally there is something like 'Purpur', or 'Spigot'.
# With this feature, you are able to change and even animate it.
+2 -1
View File
@@ -2,8 +2,9 @@ name: ProAntiTab
description: Hide more than just your plugins. Hide almost everything!
author: Rayzs_YT
version: 1.8.1
version: 1.8.5
api-version: 1.13
folia-supported: true
main: de.rayzs.pat.plugin.BukkitLoader
softdepend: