mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-15 13:26:00 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95963b59b8 | ||
|
|
ce1a326f5b | ||
|
|
aef3c3edfc | ||
|
|
4332f677f9 | ||
|
|
298e98b06d | ||
|
|
c419444481 | ||
|
|
3206a616b9 | ||
|
|
3fd9328842 | ||
|
|
e39939598b | ||
|
|
cc02837035 | ||
|
|
0c8b50b32f | ||
|
|
b5833c05b2 | ||
|
|
810ed9982c | ||
|
|
cc470740af | ||
|
|
ed8d5e0cf3 | ||
|
|
161eafeea7 | ||
|
|
b4c54101c9 | ||
|
|
729b1ccf8d | ||
|
|
3f14a091ec | ||
|
|
8282a0147b | ||
|
|
b4628443d4 |
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>de.rayzs.pat</groupId>
|
||||
<artifactId>ProAntiTab</artifactId>
|
||||
<version>1.8.2</version>
|
||||
<version>1.8.3</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -15,7 +15,6 @@ 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 {
|
||||
@@ -60,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(is121Packet) {
|
||||
if(is121Packet || Reflection.isPaper() && packetObj.getClass().getSimpleName().equals("PacketPlayOutTabComplete")) {
|
||||
try {
|
||||
Field suggestionsField = Reflection.getFieldsByTypeNormal(packetObj.getClass(), "List", Reflection.SearchOption.ENDS).get(0);
|
||||
List<?> suggestionsTmp = (List<?>) suggestionsField.get(packetObj),
|
||||
@@ -74,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();
|
||||
@@ -83,10 +81,6 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
}
|
||||
|
||||
if (spaces == 0) {
|
||||
for (Object suggestion : suggestions) {
|
||||
System.out.println(suggestion);
|
||||
}
|
||||
|
||||
suggestions.removeIf(suggestion -> {
|
||||
String command = getSuggestionFromEntry(suggestion);
|
||||
return Storage.Blacklist.isBlocked(player, command);
|
||||
@@ -98,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++) {
|
||||
@@ -115,7 +109,6 @@ 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;
|
||||
|
||||
@@ -152,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,19 +1,21 @@
|
||||
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 de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import io.netty.channel.*;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
@@ -27,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);
|
||||
@@ -116,6 +118,29 @@ 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) {
|
||||
@@ -164,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() {
|
||||
|
||||
@@ -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.2",
|
||||
version = "1.8.3",
|
||||
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;
|
||||
|
||||
|
||||
+8
-1
@@ -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,7 +78,7 @@ 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;
|
||||
}
|
||||
@@ -88,12 +88,12 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
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;
|
||||
|
||||
|
||||
+5
-4
@@ -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);
|
||||
}
|
||||
}
|
||||
+126
-10
@@ -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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
+6
-5
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -2,7 +2,7 @@ name: ProAntiTab
|
||||
description: Hide more than just your plugins. Hide almost everything!
|
||||
|
||||
author: Rayzs_YT
|
||||
version: 1.8.2
|
||||
version: 1.8.3
|
||||
main: de.rayzs.pat.plugin.BungeeLoader
|
||||
|
||||
softDepends:
|
||||
|
||||
@@ -119,8 +119,8 @@ block-namespace-commands:
|
||||
enabled: false
|
||||
|
||||
# Patches a small exploit which causes the server to lag.
|
||||
# Due to the fact that PAT interact with Tab-Completion and their packets directly,
|
||||
# it would be a shame to not use it then to also block some exploits, while being at it. ^^
|
||||
# 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.'
|
||||
|
||||
@@ -99,8 +99,8 @@ block-namespace-commands:
|
||||
enabled: false
|
||||
|
||||
# Patches a small exploit which causes the server to lag.
|
||||
# Due to the fact that PAT interact with Tab-Completion and their packets directly,
|
||||
# it would be a shame to not use it then to also block some exploits, while being at it. ^^
|
||||
# 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.'
|
||||
|
||||
@@ -2,8 +2,9 @@ name: ProAntiTab
|
||||
description: Hide more than just your plugins. Hide almost everything!
|
||||
|
||||
author: Rayzs_YT
|
||||
version: 1.8.2
|
||||
version: 1.8.3
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
main: de.rayzs.pat.plugin.BukkitLoader
|
||||
|
||||
softdepend:
|
||||
|
||||
Reference in new issue
Block a user