Compare commits

...
42 Commits
Author SHA1 Message Date
rayzsyt 1f8d5b78a7 Force command-update on Bungeecord 2026-01-25 01:24:50 +01:00
rayzsyt fee0362c69 Ensure packet not being sent if sync is disabled 2026-01-25 01:22:46 +01:00
rayzsyt 428d944933 Minor changes 2026-01-25 00:20:03 +01:00
rayzsyt 180d23fb1a Fixed wrong usage of sub-arguments in CommandWhitelist conversion 2026-01-23 12:35:04 +01:00
rayzsyt f54dc0f028 Implement Craftbukkit support 2026-01-21 22:05:38 +01:00
rayzsyt ef141a6e7f Disable MiniMessage for Craftbukkit 2026-01-21 21:45:25 +01:00
rayzsyt 55b0b5df75 Add Craftbukkit check 2026-01-21 21:37:10 +01:00
rayzsyt bc78304e97 Small adjustment 2026-01-21 20:18:48 +01:00
rayzsyt 42d8ea3526 Implement TEMP_PLAYER_SERVER_CACHE usage 2026-01-21 19:42:51 +01:00
rayzsyt dfc0066c17 Implement context check 2026-01-21 19:42:21 +01:00
rayzsyt 9e3e61e9a2 Reimplemented update-groups-per-server 2026-01-21 19:41:19 +01:00
rayzsyt 6551bffcdb Implement TEMP_PLAYER_SERVER_CACHE cache 2026-01-21 19:13:22 +01:00
rayzsyt 44f3b4d6d5 Return world name in getPlayerSerName(UUID) method 2026-01-21 18:12:27 +01:00
rayzsyt c672eaaf81 Cancelled event 2026-01-19 16:18:14 +01:00
rayzsyt 460013d22a Added default slash if not there 2026-01-19 16:17:06 +01:00
rayzsyt af89f082aa Always clear sub-arguments for custom-plugins & custom-version feature 2026-01-19 15:50:25 +01:00
rayzsyt e0c3c8a343 Made always executable if it's the console 2026-01-18 19:49:31 +01:00
rayzsyt 83480db4c6 Small adjustments 2026-01-18 19:44:46 +01:00
rayzsyt 04d441cfd6 Add missing interface 2026-01-18 19:44:29 +01:00
rayzsyt 842c2654c6 Add server placeholder to forwarded notification alert 2026-01-18 19:44:01 +01:00
rayzsyt 01d825da86 Implement NotificationPacket call 2026-01-18 18:50:21 +01:00
rayzsyt d61dd872eb Check if option is actually enabled 2026-01-18 17:49:01 +01:00
rayzsyt 3c417c6a8e Add displayCommand to NotificationPacket implementation 2026-01-18 17:40:01 +01:00
rayzsyt f0772a0969 Implement NotificationPacket 2026-01-18 17:39:47 +01:00
rayzsyt 2a83c1c548 Implement NotificationPacket and simplified logic 2026-01-18 17:35:23 +01:00
rayzsyt 12114c63bf Implement ForwardNotificationPacket 2026-01-18 17:30:37 +01:00
rayzsyt 8123ff2f27 Add Forward-Console-Notification-Alerts option 2026-01-18 17:29:29 +01:00
rayzsyt b56ebb3fcb Add NotificationPacket 2026-01-18 17:16:36 +01:00
rayzsyt 7adcce2361 Updated reference url 2026-01-18 17:10:08 +01:00
rayzsyt 6444ec153c Removed unused methods 2026-01-18 17:08:48 +01:00
rayzsyt 841253708d Changed version name 2026-01-18 16:31:46 +01:00
rayzsyt 467308be62 Implemented %offline_players% 2026-01-17 17:53:05 +01:00
rayzsyt d2f8305727 Added new commands to default config 2026-01-17 16:57:48 +01:00
rayzsyt 1a19435b96 Added checks to ensure the list hasn't been modified during the for-loop 2026-01-15 20:07:58 +01:00
rayzsyt eb4b2b1e17 Removed unnecessary computation 2026-01-15 19:53:32 +01:00
rayzsyt 8bca4bc091 Fixed sub-argument disappearing on Spigot servers 2026-01-15 19:48:02 +01:00
rayzsyt dfef20fb87 Fixed subargument blocking in BLACKLIST mode 2026-01-15 19:10:38 +01:00
rayzsyt f4e1dbf385 Fixed subargument blocking in BLACKLIST mode 2026-01-15 19:07:25 +01:00
rayzsyt 93a84f668a Fixed subargument blocking in BLACKLIST mode 2026-01-15 16:55:10 +01:00
rayzsyt f8463c9927 Fix command being blocked entirely if used in BLACKLIST mode 2026-01-15 16:22:46 +01:00
rayzsyt 34b5cd89e5 Ensures that the parent isn't null 2026-01-15 16:15:41 +01:00
rayzsyt 6aae96ab87 Removed old comment 2026-01-15 15:58:05 +01:00
31 changed files with 363 additions and 161 deletions

No files matched your search

+2 -2
View File
@@ -122,7 +122,7 @@ enabled: false
######
# **C**USTOM PLUGINS LIST
Just blocking the /plugins command is pretty boring after some time. This feature here allows you to make it more interesting by faking a /plugins message with, for example, fake plugins! ^^
Just blocking the /plugins command is pretty boring. This feature here allows you to make it more interesting by displaying for example fake plugins.
![https://www.rayzs.de/proantitab/assets/fakeplugins2.PNG](https://www.rayzs.de/proantitab/assets/fakeplugins2.PNG)
<details>
@@ -146,7 +146,7 @@ message:
######
# **C**USTOM VERSION COMMAND
Who wouldn't like to pretend to own a custom server-jar? Have fun customizing your very own /version command to your personal liking. ^^
Who wouldn't like to pretend to own a custom server-jar? Have fun customizing your very own /version command to your personal liking.
![https://www.rayzs.de/proantitab/assets/custom-version.png](https://www.rayzs.de/proantitab/assets/custom-version.png)
<details>
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>de.rayzs.pat</groupId>
<artifactId>ProAntiTab</artifactId>
<version>2.2.0</version>
<version>2.3.0</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
@@ -21,6 +21,7 @@ import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.group.TinyGroup;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.utils.sender.CommandSender;
public class Communicator {
@@ -39,20 +40,19 @@ public class Communicator {
LAST_BUKKIT_SYNC = System.currentTimeMillis();
public static void sendPacket(Object packet) {
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) return;
CLIENT.send(packet);
}
public static void sendPacket(ClientInfo clientInfo, Object packet) {
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) return;
clientInfo.sendBytes(CommunicationPackets.convertToBytes(packet));
}
public static void receiveInformation(String serverName, Object packet) {
ClientInfo client = getClientByName(serverName);
if (packet instanceof CommunicationPackets.RequestPacket) {
CommunicationPackets.RequestPacket requestPacket = (CommunicationPackets.RequestPacket) packet;
if (packet instanceof CommunicationPackets.RequestPacket requestPacket) {
if (!requestPacket.isToken(Storage.TOKEN))
return;
@@ -71,19 +71,25 @@ public class Communicator {
return;
}
if (packet instanceof CommunicationPackets.UpdateCommandsPacket) {
if (packet instanceof CommunicationPackets.NotificationPacket notificationPacket) {
if (!notificationPacket.isToken(Storage.TOKEN) || Reflection.isProxyServer()) {
return;
}
BukkitLoader.handleNotificationPacket(notificationPacket);
}
if (packet instanceof CommunicationPackets.UpdateCommandsPacket updateCommandsPacket) {
if (Reflection.isProxyServer())
return;
CommunicationPackets.UpdateCommandsPacket updateCommandsPacket = (CommunicationPackets.UpdateCommandsPacket) packet;
BukkitLoader.handleUpdateCommandsPacket(updateCommandsPacket);
}
if (packet instanceof CommunicationPackets.ForcePermissionResetPacket) {
if (packet instanceof CommunicationPackets.ForcePermissionResetPacket permissionResetPacket) {
if (Reflection.isProxyServer())
return;
CommunicationPackets.ForcePermissionResetPacket permissionResetPacket = (CommunicationPackets.ForcePermissionResetPacket) packet;
if (!permissionResetPacket.isToken(Storage.TOKEN))
return;
@@ -95,8 +101,7 @@ public class Communicator {
return;
}
if (packet instanceof CommunicationPackets.BackendDataPacket) {
CommunicationPackets.BackendDataPacket backendDataPacket = (CommunicationPackets.BackendDataPacket) packet;
if (packet instanceof CommunicationPackets.BackendDataPacket backendDataPacket) {
if (!backendDataPacket.isToken(Storage.TOKEN))
return;
@@ -104,8 +109,7 @@ public class Communicator {
return;
}
if (packet instanceof CommunicationPackets.FeedbackPacket) {
CommunicationPackets.FeedbackPacket feedbackPacket = (CommunicationPackets.FeedbackPacket) packet;
if (packet instanceof CommunicationPackets.FeedbackPacket feedbackPacket) {
if (!feedbackPacket.isToken(Storage.TOKEN))
return;
@@ -134,8 +138,7 @@ public class Communicator {
return;
}
if (packet instanceof CommunicationPackets.PacketBundle) {
CommunicationPackets.PacketBundle packetBundle = (CommunicationPackets.PacketBundle) packet;
if (packet instanceof CommunicationPackets.PacketBundle packetBundle) {
if (!packetBundle.isToken(Storage.TOKEN) || !packetBundle.isId(SERVER_ID.toString()))
return;
@@ -223,12 +226,30 @@ public class Communicator {
}
public static void sendPermissionReset() {
if(Reflection.isProxyServer())
if (Reflection.isProxyServer()) {
sendPacket(new CommunicationPackets.ForcePermissionResetPacket(Storage.TOKEN));
}
}
public static void sendNotificationPacket(CommandSender targetSender, String displayedCommand) {
if (!Storage.ConfigSections.Settings.FORWARD_CONSOLE_NOTIFICATIONS.ENABLED) {
return;
}
final String serverName = targetSender.getServerName();
for (ClientInfo client : CLIENTS) {
if (client.getName().equalsIgnoreCase(serverName)) {
sendPacket(client, new CommunicationPackets.NotificationPacket(Storage.TOKEN, targetSender.getUniqueId(), displayedCommand));
return;
}
}
}
public static void sendUpdateCommand() {
sendPacket(new CommunicationPackets.UpdateCommandsPacket(Storage.TOKEN));
if (Reflection.isProxyServer()) {
sendPacket(new CommunicationPackets.UpdateCommandsPacket(Storage.TOKEN));
}
}
public static void sendUpdateCommand(UUID targetUUID) {
@@ -40,6 +40,8 @@ public class ModernPacketHandler implements BukkitPacketHandler {
}
String text = (String) stringField.get(packetObj);
if (!text.isBlank() && text.charAt(0) != '/') text = '/' + text;
if (Storage.ConfigSections.Settings.PATCH_EXPLOITS.isMalicious(text)) {
MessageTranslator.send(
Bukkit.getConsoleSender(),
@@ -66,6 +66,8 @@ public class Storage {
public static boolean USE_PLACEHOLDERAPI = false, USE_PAPIPROXYBRIDGE = false, USE_VIAVERSION = false, USE_VELOCITY = false, USE_SIMPLECLOUD;
public static long LAST_SYNC = System.currentTimeMillis();
public static ExpireCache<UUID, String> TEMP_PLAYER_SERVER_CACHE = new ExpireCache<>(1, TimeUnit.SECONDS);
private static PermissionPlugin PERMISSION_PLUGIN = PermissionPlugin.NONE;
public static void initialize(PluginLoader loader, String currentVersion) {
@@ -256,6 +258,7 @@ public class Storage {
if (!Reflection.isVelocityServer()) {
BungeePacketAnalyzer.sendCommandsPacket();
Communicator.sendUpdateCommand();
}
return;
@@ -353,6 +356,7 @@ public class Storage {
public static CustomPluginsSection CUSTOM_PLUGIN = new CustomPluginsSection();
public static CustomVersionSection CUSTOM_VERSION = new CustomVersionSection();
public static DisableSyncSection DISABLE_SYNC = new DisableSyncSection();
public static ForwardConsoleNotificationAlertsSection FORWARD_CONSOLE_NOTIFICATIONS = new ForwardConsoleNotificationAlertsSection();
public static CustomProtocolPingSection CUSTOM_PROTOCOL_PING = new CustomProtocolPingSection();
public static CustomUnknownCommandSection CUSTOM_UNKNOWN_COMMAND = new CustomUnknownCommandSection();
public static TurnBlacklistToWhitelistSection TURN_BLACKLIST_TO_WHITELIST = new TurnBlacklistToWhitelistSection();
@@ -656,7 +660,7 @@ public class Storage {
return !turn;
}
return turn != listed; // Shorter version of above's code
return turn != listed;
}
@@ -0,0 +1,22 @@
package de.rayzs.pat.api.storage.config.settings;
import de.rayzs.pat.api.storage.storages.ConfigStorage;
import de.rayzs.pat.utils.Reflection;
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
public class ForwardConsoleNotificationAlertsSection extends ConfigStorage {
public boolean ENABLED;
public ForwardConsoleNotificationAlertsSection() {
super("forward-console-notification-alerts");
}
@Override
public void load() {
super.load();
if(!Reflection.isProxyServer()) return;
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
}
}
@@ -6,7 +6,6 @@ import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
public class UpdateGroupsPerServerSection extends ConfigStorage {
// Disabled for now
public boolean ENABLED = false;
public UpdateGroupsPerServerSection() {
@@ -17,11 +16,9 @@ public class UpdateGroupsPerServerSection extends ConfigStorage {
public void load() {
super.load();
/*
if (!Reflection.isProxyServer())
return;
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
*/
}
}
@@ -21,6 +21,7 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
public boolean isListed(String command, boolean ignoreColons) {
final boolean caseSensitive = Storage.ConfigSections.Settings.BASE_COMMAND_CASE_SENSITIVE.ENABLED;
final boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
if (commands == null || command.isEmpty()) {
return false;
@@ -28,7 +29,7 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
boolean isNegated = Storage.Blacklist.BlockTypeFetcher.isNegated(command);
if (!isNegated) {
if (!isNegated == turn) {
command = StringUtils.getFirstArg(command);
}
@@ -43,7 +44,7 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
command = command.substring(command.indexOf(':'));
}
if (!isNegated) {
if (!isNegated == turn) {
listedCommand = StringUtils.getFirstArg(listedCommand);
}
@@ -209,7 +209,10 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
@Override
public String getPlayerServerName(UUID uuid) {
return null;
final Player player = Bukkit.getPlayer(uuid);
if (player == null) { return null; }
return player.getWorld().getName();
}
@Override
@@ -280,6 +283,24 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
}, 20L, 20L * Storage.ConfigSections.Settings.UPDATE.PERIOD);
}
public static void handleNotificationPacket(CommunicationPackets.NotificationPacket packet) {
if (!Storage.SEND_CONSOLE_NOTIFICATION) { return; }
final Player player = Bukkit.getPlayer(packet.getTargetUUID());
if (player == null) {
return;
}
final List<String> notificationMessage = MessageTranslator.replaceMessageList(
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
"%player%", player.getName(),
"%command%", packet.getDisplayedCommand(),
"%server%", Storage.SERVER_NAME,
"%world%", player.getWorld().getName());
Logger.info(notificationMessage);
}
public static void handleUpdateCommandsPacket(CommunicationPackets.UpdateCommandsPacket packet) {
if (!packet.hasTargetUUID()) {
@@ -178,10 +178,16 @@ public class BungeeLoader extends Plugin implements PluginLoader {
@Override
public String getPlayerServerName(UUID uuid) {
final String cachedServerName = Storage.TEMP_PLAYER_SERVER_CACHE.get(uuid);
if (cachedServerName != null) {
return cachedServerName;
}
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
if (player == null || player.getServer() == null || player.getServer().getInfo() == null)
if (player == null || player.getServer() == null || player.getServer().getInfo() == null) {
return null;
}
return player.getServer().getInfo().getName();
}
@@ -39,7 +39,7 @@ import java.util.*;
@Plugin(name = "ProAntiTab",
id = "proantitab",
version = "2.2.1",
version = "2.3.0",
authors = "Rayzs_YT",
description = "Hides more than just your plugins.",
url = "https://www.rayzs.de/products/proantitab/page",
@@ -221,6 +221,11 @@ public class VelocityLoader implements PluginLoader {
@Override
public String getPlayerServerName(UUID uuid) {
final String cachedServerName = Storage.TEMP_PLAYER_SERVER_CACHE.get(uuid);
if (cachedServerName != null) {
return cachedServerName;
}
Optional<Player> optPlayer = server.getPlayer(uuid);
if (optPlayer.isEmpty())
@@ -229,8 +234,9 @@ public class VelocityLoader implements PluginLoader {
Player player = optPlayer.get();
Optional<ServerConnection> optConnection = player.getCurrentServer();
if (optConnection.isEmpty())
if (optConnection.isEmpty()) {
return null;
}
ServerConnection connection = optConnection.get();
return connection.getServer().getServerInfo().getName();
@@ -24,7 +24,10 @@ public class CommandWhitelistConverter extends Converter {
List<String> commands = new ArrayList<>();
final List<String> l1 = (ArrayList<String>) config.get("groups." + groupName + ".commands");
final List<String> l2 = (ArrayList<String>) config.get("groups." + groupName + ".subcommands");
final List<String> l2 = ((ArrayList<String>) config.get("groups." + groupName + ".subcommands"))
.stream()
.map(c -> Storage.Blacklist.BlockType.NEGATE + c)
.toList();
commands.addAll(l1);
commands.addAll(l2);
@@ -3,6 +3,7 @@ package de.rayzs.pat.plugin.listeners.bukkit;
import de.rayzs.pat.api.event.events.FilteredSuggestionEvent;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.scheduler.PATScheduler;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import org.bukkit.event.player.PlayerCommandSendEvent;
@@ -66,6 +67,13 @@ public class BukkitAntiTabListener implements Listener {
return;
}
if (Reflection.isCraftbukkit() && !Bukkit.getOnlinePlayers().contains(player)) {
event.getCommands().clear();
PATScheduler.createScheduler(player::updateCommands, 10);
return;
}
final List<Group> groups = GroupManager.getPlayerGroups(sender);
final List<String> playerCommands = COMMANDS_CACHE.getPlayerCommands(new ArrayList<>(event.getCommands()), sender, groups);
final FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, playerCommands);
@@ -1,5 +1,6 @@
package de.rayzs.pat.plugin.listeners.bungee;
import de.rayzs.pat.api.communication.Communicator;
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
@@ -51,6 +52,8 @@ public class BungeeBlockCommandListener implements Listener {
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
Communicator.sendNotificationPacket(sender, displayCommand);
MessageTranslator.send(
player,
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE,
@@ -73,6 +76,8 @@ public class BungeeBlockCommandListener implements Listener {
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
Communicator.sendNotificationPacket(sender, displayCommand);
MessageTranslator.send(
player,
Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE,
@@ -125,6 +130,8 @@ public class BungeeBlockCommandListener implements Listener {
if (!executeCommandEvent.doesNotify())
return;
Communicator.sendNotificationPacket(sender, displayCommand);
if (Storage.SEND_CONSOLE_NOTIFICATION)
Logger.info(notificationMessage);
@@ -3,6 +3,7 @@ package de.rayzs.pat.plugin.listeners.velocity;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.command.CommandExecuteEvent;
import com.velocitypowered.api.command.CommandSource;
import de.rayzs.pat.api.communication.Communicator;
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
@@ -62,6 +63,8 @@ public class VelocityBlockCommandListener {
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
Communicator.sendNotificationPacket(sender, displayCommand);
MessageTranslator.send(
player,
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE,
@@ -84,6 +87,8 @@ public class VelocityBlockCommandListener {
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
Communicator.sendNotificationPacket(sender, displayCommand);
MessageTranslator.send(
player,
Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE,
@@ -138,6 +143,8 @@ public class VelocityBlockCommandListener {
if (!executeCommandEvent.doesNotify())
return event;
Communicator.sendNotificationPacket(sender, displayCommand);
if (Storage.SEND_CONSOLE_NOTIFICATION)
MessageTranslator.send(consoleSender, notificationMessage);
@@ -1,6 +1,7 @@
package de.rayzs.pat.plugin.listeners.velocity;
import com.velocitypowered.api.event.connection.DisconnectEvent;
import com.velocitypowered.api.proxy.server.ServerInfo;
import de.rayzs.pat.api.brand.CustomServerBrand;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
@@ -33,8 +34,14 @@ public class VelocityConnectionListener {
public void onServerPreConnect(ServerPreConnectEvent event) {
final Player player = event.getPlayer();
final CommandSender sender = CommandSenderHandler.from(player);
sender.updateSenderObject(player);
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_SERVER.ENABLED) {
final ServerInfo serverInfo = event.getOriginalServer().getServerInfo();
if (serverInfo != null) Storage.TEMP_PLAYER_SERVER_CACHE.put(player.getUniqueId(), serverInfo.getName());
}
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
if(CustomServerBrand.isEnabled())
@@ -54,7 +61,7 @@ public class VelocityConnectionListener {
@Subscribe
public void onServerSwitch(ServerConnectedEvent event) {
Player player = event.getPlayer();
final Player player = event.getPlayer();
if (!VelocityPacketAnalyzer.isInjected(player)) {
@@ -72,8 +79,10 @@ public class VelocityConnectionListener {
}
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_SERVER.ENABLED) {
CommandSender sender = CommandSenderHandler.from(player);
final ServerInfo serverInfo = event.getServer().getServerInfo();
if (serverInfo != null) Storage.TEMP_PLAYER_SERVER_CACHE.put(player.getUniqueId(), serverInfo.getName());
CommandSender sender = CommandSenderHandler.from(player);
assert sender != null;
PermissionUtil.reloadPermissions(sender);
}
@@ -18,20 +18,20 @@ public class NotifyCommand extends ProCommand {
@Override
public boolean execute(CommandSender sender, String[] args) {
boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !Reflection.isProxyServer();
if (backend) {
sender.sendMessage(Storage.ConfigSections.Messages.NO_PROXY.MESSAGE);
return true;
}
boolean enabled = false;
boolean enabled;
if (sender.isConsole()) {
enabled = Storage.SEND_CONSOLE_NOTIFICATION;
Storage.SEND_CONSOLE_NOTIFICATION = !Storage.SEND_CONSOLE_NOTIFICATION;
} else {
boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !Reflection.isProxyServer();
if (backend) {
sender.sendMessage(Storage.ConfigSections.Messages.NO_PROXY.MESSAGE);
return true;
}
enabled = Storage.NOTIFY_PLAYERS.contains(sender.getUniqueId());
if (enabled)
@@ -65,8 +65,7 @@ public class SubArguments {
}
public static void handleCommandNode(UUID uuid, ProxyCommandNodeHelper helper) {
if (!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED)
return;
final boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
Arguments arguments = PLAYER_COMMANDS.get(uuid);
if (arguments == null) {
@@ -78,32 +77,47 @@ public class SubArguments {
return;
}
List<String> inputs = source.getAllInputs();
List<String> allEntries = inputs.stream().map(StringUtils::getFirstArg).toList();
final List<String> inputs = source.getAllInputs();
helper.removeIf(allEntries::contains);
if (turn) {
List<String> allEntries = inputs.stream().map(StringUtils::getFirstArg).toList();
helper.removeIf(allEntries::contains);
}
final int length = inputs.size();
for (int i = 0; i < length; i++) {
String input;
try {
input = inputs.get(i);
} catch (IndexOutOfBoundsException indexOutOfBoundsException) {
break;
}
for (String input : inputs) {
final boolean negated = Storage.Blacklist.BlockTypeFetcher.isNegated(input);
if (!negated) {
helper.add(input, true);
if (turn) helper.add(input, true);
else helper.removeSubArguments(input);
continue;
}
final Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(input);
if (type != Storage.Blacklist.BlockType.BOTH && type != Storage.Blacklist.BlockType.TAB) {
if (type == Storage.Blacklist.BlockType.CHAT) {
continue;
}
input = Storage.Blacklist.BlockTypeFetcher.cleanse(input);
helper.removeSubArguments(input);
if (turn) helper.removeSubArguments(input);
else helper.add(input, true);
}
}
public static void handleCommandNode(UUID uuid, BukkitCommandNodeHelper helper) throws Exception {
if (!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED)
return;
final boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
Arguments arguments = PLAYER_COMMANDS.get(uuid);
if (arguments == null) {
@@ -115,10 +129,19 @@ public class SubArguments {
return;
}
List<String> inputs = source.getAllInputs();
List<String> argumentsList = new ArrayList<>();
final List<String> inputs = new ArrayList<>(source.getAllInputs());
final List<String> argumentsList = new ArrayList<>();
final int length = inputs.size();
for (int i = 0; i < length; i++) {
String input;
try {
input = inputs.get(i);
} catch (IndexOutOfBoundsException indexOutOfBoundsException) {
break;
}
for (String input : inputs) {
final Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(input);
if (type == Storage.Blacklist.BlockType.CHAT) {
continue;
@@ -128,11 +151,15 @@ public class SubArguments {
input = Storage.Blacklist.BlockTypeFetcher.cleanse(input);
if (!negated) {
argumentsList.add(input);
if (turn) argumentsList.add(input);
else helper.removeSubArguments(input);
continue;
}
helper.removeSubArguments(input);
if (turn) helper.removeSubArguments(input);
else argumentsList.add(input);
}
if (argumentsList.isEmpty()) {
@@ -136,6 +136,24 @@ public class ExecuteCommand extends ExecuteCommandEvent {
cpyCommand = StringUtils.replace(command, "%both_players%", "%players%");
}
if (c.contains("%offline_players%")) {
final String[] cSplit = c.split(" ");
final String[] cpyCommandSplit = cpyCommand.split(" ");
for (int i = 0; i < cSplit.length; i++) {
if (i >= cpyCommandSplit.length) {
break;
}
if (cSplit[i].equals("%offline_players%") && !cpyCommandSplit[i].endsWith("players%")) {
cpyCommandSplit[i] = "%offline_players%";
}
}
cpyCommand = String.join(" ", cpyCommandSplit);
}
boolean ends = c.endsWith("_-");
if (ends) {
c = StringUtils.replace(c, "_-", "");
@@ -17,6 +17,12 @@ public class TabCompletion extends FilteredTabCompletionEvent {
if (event.getCompletion().isEmpty()) return;
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(cursor) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(cursor)) {
event.setCompletion(List.of());
event.setCancelled(true);
return;
}
final boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
final UUID uuid = event.getSenderObj() instanceof UUID
? (UUID) event.getSenderObj()
@@ -75,6 +81,11 @@ public class TabCompletion extends FilteredTabCompletionEvent {
possibilities.addAll(SubArguments.getOnlinePlayerNames());
}
if (result.contains("%offline_players%")) {
possibilities.remove("%offline_players%");
possibilities.removeAll(SubArguments.getOnlinePlayerNames());
}
if (result.contains("%hidden_players%")) {
possibilities.remove("%hidden_players%");
@@ -111,6 +122,9 @@ public class TabCompletion extends FilteredTabCompletionEvent {
if (result.contains("%players%"))
possibilities.removeIf(possibility -> SubArguments.getPlayerNames().contains(possibility));
if (result.contains("%offline_players%"))
possibilities.removeIf(possibility -> !SubArguments.getPlayerNames().contains(possibility));
if (result.contains("%online_players%"))
possibilities.removeIf(possibility -> SubArguments.getOnlinePlayerNames().contains(possibility));
@@ -2,6 +2,7 @@ package de.rayzs.pat.plugin.subarguments.events;
import de.rayzs.pat.plugin.subarguments.SubArguments;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.Reflection;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import de.rayzs.pat.api.event.events.*;
import de.rayzs.pat.utils.subargs.Arguments;
@@ -45,54 +46,46 @@ public class UpdateList {
argument.clearArguments();
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
for (String command : event.getCommands())
for (String command : event.getCommands()) {
argument.buildArgumentStacks(command);
final List<String> chatInputs = new ArrayList<>(argument.CHAT_ARGUMENTS.getGeneralArgument().getInputs());
final List<String> tabInput = new ArrayList<>(argument.TAB_ARGUMENTS.getGeneralArgument().getInputs());
for (String command : chatInputs) {
Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(command);
if (type != Storage.Blacklist.BlockType.NEGATE) {
command = Storage.Blacklist.BlockTypeFetcher.modify(command, type);
}
argument.CHAT_ARGUMENTS.buildArguments(command);
}
for (String command : tabInput) {
Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(command);
if (type != Storage.Blacklist.BlockType.NEGATE)
command = Storage.Blacklist.BlockTypeFetcher.modify(command, type);
argument.TAB_ARGUMENTS.buildArguments(command);
}
for (String command : SubArguments.getGroupCommands(uuid, serverName))
for (String command : SubArguments.getGroupCommands(uuid, serverName)) {
argument.buildArgumentStacks(command);
}
for (String command : SubArguments.getServerCommands(uuid)) {
argument.buildArgumentStacks(command);
}
} else {
List<String> groupCommands = SubArguments.getGroupCommands(uuid, serverName);
for (String command : argument.CHAT_ARGUMENTS.getGeneralArgument().getInputs()) {
if (groupCommands.contains(command)) continue;
final List<String> groupCommands = SubArguments.getGroupCommands(uuid, serverName);
argument.CHAT_ARGUMENTS.buildArguments(Storage.Blacklist.BlockTypeFetcher.modify(command));
if (Reflection.isProxyServer()) {
final List<String> commands = SubArguments.getServerCommands(uuid);
commands.removeIf(groupCommands::contains);
for (String command : commands) {
argument.buildArgumentStacks(command);
}
} else {
for (String command : Arguments.ARGUMENTS.CHAT_ARGUMENTS.getGeneralArgument().getInputs()) {
if (groupCommands.contains(command)) continue;
argument.CHAT_ARGUMENTS.buildArguments(Storage.Blacklist.BlockTypeFetcher.modify(command));
}
for (String command : Arguments.ARGUMENTS.TAB_ARGUMENTS.getGeneralArgument().getInputs()) {
if (groupCommands.contains(command)) continue;
argument.TAB_ARGUMENTS.buildArguments(Storage.Blacklist.BlockTypeFetcher.modify(command));
}
}
for (String command : argument.TAB_ARGUMENTS.getGeneralArgument().getInputs()) {
if (groupCommands.contains(command)) continue;
argument.TAB_ARGUMENTS.buildArguments(Storage.Blacklist.BlockTypeFetcher.modify(command));
}
}
SubArguments.PLAYER_COMMANDS.putIfAbsent(uuid, argument);
@@ -119,6 +119,30 @@ public class CommunicationPackets {
}
}
public static class NotificationPacket implements CommunicationPacket, Serializable {
private final String proxyToken, displayedCommand;
private final UUID targetUUID;
public NotificationPacket(String proxyToken, UUID targetUUID, String displayedCommand) {
this.proxyToken = proxyToken;
this.targetUUID = targetUUID;
this.displayedCommand = displayedCommand;
}
public UUID getTargetUUID() {
return targetUUID;
}
public String getDisplayedCommand() {
return displayedCommand;
}
public boolean isToken(String token) {
return proxyToken.equals(token);
}
}
public static class ForcePermissionResetPacket implements Serializable {
private final String proxyToken;
@@ -5,58 +5,10 @@ import io.netty.buffer.*;
public class PacketUtils {
/*
Copyright (c) 2012, md_5. All rights reserved.
Original code from Bungeecord source:
https://github.com/SpigotMC/BungeeCord/blob/master/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java#L72-L94
*/
public static String readString(ByteBuf buf) throws Exception {
return readString( buf, Short.MAX_VALUE );
}
public static String readString(ByteBuf byteBuf, int maxLength) throws Exception {
int len = readVarInt(byteBuf);
if ( len > maxLength * 3 )
throw new Exception("Cannot receive string longer than " + maxLength * 3 + " (got " + len + " bytes)" );
String string = byteBuf.toString(byteBuf.readerIndex(), len, StandardCharsets.UTF_8);
byteBuf.readerIndex(byteBuf.readerIndex() + len );
if (string.length() > maxLength)
throw new Exception( "Cannot receive string longer than " + maxLength + " (got " + string.length() + " characters)" );
return string;
}
/*
Copyright (c) 2012, md_5. All rights reserved.
Original code from Bungeecord source:
https://github.com/SpigotMC/BungeeCord/blob/master/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java#L233-L261
*/
public static int readVarInt(ByteBuf input) throws Exception {
return readVarInt(input, 5);
}
public static int readVarInt(ByteBuf input, int maxBytes) throws Exception {
int out = 0, bytes = 0;
byte in;
while (true) {
in = input.readByte();
out |= (in & 0x7F) << (bytes++ * 7);
if (bytes > maxBytes) throw new Exception( "VarInt too big (max " + maxBytes + ")" );
if ((in & 0x80) != 0x80) break;
}
return out;
}
/*
Copyright (c) 2012, md_5. All rights reserved.
Original code from Bungeecord source:
https://github.com/SpigotMC/BungeeCord/blob/master/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java#L263C1-L283C6
https://github.com/SpigotMC/BungeeCord/blob/master/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java#L307-L327
*/
public static void writeVarInt(int value, ByteBuf output) {
@@ -75,7 +27,7 @@ public class PacketUtils {
/*
Copyright (c) 2012, md_5. All rights reserved.
Original code from Bungeecord source:
https://github.com/SpigotMC/BungeeCord/blob/master/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java#L50C4-L71C1
https://github.com/SpigotMC/BungeeCord/blob/master/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java#L88-L108
*/
public static void writeString(String string, ByteBuf byteBuf) throws Exception {
@@ -9,7 +9,7 @@ import java.util.*;
public class Reflection {
private static boolean legacy, proxy, velocity, paper, folia, weird, oldChannelMethod;
private static boolean legacy, proxy, velocity, paper, folia, craftbukkit, weird, oldChannelMethod;
private static String versionName, fullVersionName, rawVersionName, versionPackageName;
private static Version version;
private static int major, minor, release;
@@ -17,13 +17,19 @@ public class Reflection {
public static void initialize(Object serverObj) {
try {
Class.forName("org.bukkit.Server");
loadVersionName(serverObj);
loadAges();
loadVersionEnum();
legacy = minor <= 16;
weird = Reflection.getMinor() == 20 && Reflection.getRelease() >= 6 || Reflection.getMinor() > 20;
proxy = false;
} catch (Throwable ignored) { proxy = true; }
} catch (Throwable ignored) {
proxy = true;
craftbukkit = false;
}
if (!proxy) {
try {
@@ -56,6 +62,17 @@ public class Reflection {
if (proxy) version = Version.UNKNOWN;
oldChannelMethod = folia || paper && Reflection.isWeird();
if (!proxy && !paper && !folia) {
try {
Class.forName("org.spigotmc.SpigotConfig");
craftbukkit = false;
} catch (Throwable throwable) {
craftbukkit = true;
}
}
}
public static void toggleInjectionMethod() {
@@ -76,6 +93,10 @@ public class Reflection {
return folia;
}
public static boolean isCraftbukkit() {
return craftbukkit;
}
public static boolean isProxyServer() {
return proxy;
}
@@ -401,8 +422,7 @@ public class Reflection {
v_1_18_1, v_1_18_2,
v_1_19, v_1_19_1, v_1_19_2, v_1_19_3, v_1_19_4,
v_1_20, v_1_20_1, v_1_20_2, v_1_20_3, v_1_20_4, v_1_20_5, v_1_20_6,
v_1_21, v_1_21_1, v_1_21_2, v_1_21_3, v_1_21_4, v_1_21_5, v_1_21_6, v_1_21_7, v_1_21_8,
v_1_22, v_1_22_1, v_1_22_2
v_1_21, v_1_21_1, v_1_21_2, v_1_21_3, v_1_21_4, v_1_21_5, v_1_21_6, v_1_21_7, v_1_21_8, v_1_21_9, v_1_21_10, v_1_21_11
}
public enum SearchOption { CONTAINS, EQUALS, ENDS, STARTS }
@@ -4,6 +4,7 @@ import de.rayzs.pat.api.communication.Communicator;
import de.rayzs.pat.plugin.listeners.bukkit.BukkitAntiTabListener;
import de.rayzs.pat.utils.permission.PermissionPlugin;
import de.rayzs.pat.utils.scheduler.PATScheduler;
import net.luckperms.api.context.ImmutableContextSet;
import net.luckperms.api.event.sync.PreNetworkSyncEvent;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.plugin.VelocityLoader;
@@ -15,6 +16,8 @@ import net.luckperms.api.event.node.*;
import de.rayzs.pat.utils.Reflection;
import net.luckperms.api.node.*;
import net.luckperms.api.*;
import net.luckperms.api.query.QueryOptions;
import java.util.*;
public class LuckPermsAdapter {
@@ -44,17 +47,29 @@ public class LuckPermsAdapter {
}
public static Map<String, Boolean> getPermissions(UUID uuid) {
User user = getUser(uuid);
if (user == null) return null;
final User user = PROVIDER.getUserManager().getUser(uuid);
return user.getCachedData().getPermissionData().getPermissionMap();
if (user == null) {
return null;
}
final ImmutableContextSet.Builder builder = ImmutableContextSet.builder();
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_SERVER.ENABLED || Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_WORLD.ENABLED) {
final String contextValue = Storage.getLoader().getPlayerServerName(uuid);
if (contextValue != null) {
builder.add("server", contextValue).add("world", contextValue);
}
}
return user.getCachedData().getPermissionData(QueryOptions.contextual(builder.build())).getPermissionMap();
}
public static void setPermissions(UUID uuid) {
Map<String, Boolean> permissions = getPermissions(uuid);
if (permissions == null) return;
permissions.forEach((permission, permitted) -> {
if (permission.startsWith("proantitab.") || permission.equals("*"))
@@ -41,12 +41,13 @@ public class MessageTranslator {
for (Map.Entry<Character, String> entry : colors.entrySet())
endingColors.put(entry.getKey(), "</" + entry.getValue().substring(1));
support = !Storage.USE_SIMPLECLOUD && (Reflection.getMinor() >= 18 || Reflection.isProxyServer());
support = !Reflection.isCraftbukkit() && !Storage.USE_SIMPLECLOUD && (Reflection.getMinor() >= 18 || Reflection.isProxyServer());
if(support)
if (support) {
translator = Reflection.isVelocityServer() ? new VelocityMessageTranslator()
: Reflection.isProxyServer() ? new BungeeMessageTranslator()
: new BukkitMessageTranslator();
}
}
public static String translateLegacy(String text) {
@@ -73,7 +73,14 @@ public class BukkitCommandNodeHelper {
}
public void spareRecursively(List<String> spares) throws Exception {
spareRecursively("", root, spares);
final Set<String> sparesSet = new HashSet<>(spares.stream().map(StringUtils::getFirstArg).toList());
for (String childName : sparesSet) {
Node child = root.getChild(childName);
if (child != null) {
spareRecursively(child.getName(), child, spares);
}
}
}
private void spareRecursively(String str, Node parent, List<String> spares) throws Exception {
@@ -88,12 +95,6 @@ public class BukkitCommandNodeHelper {
}
for (final Node child : children) {
if (parent.isRoot()) {
spareRecursively(child.getName(), child, spares);
continue;
}
final String command = str + " " + child.getName();
final String[] commandArgs = command.split(" ");
@@ -146,7 +147,7 @@ public class BukkitCommandNodeHelper {
final int max = args.length - 1;
final int nextIndex = index + 1;
if (index > max || nextIndex > max) {
if (parent == null || index > max || nextIndex > max) {
return;
}
+1 -1
View File
@@ -3,7 +3,7 @@ description: Hides more than just your plugins.
website: https://www.rayzs.de/products/proantitab/page
author: Rayzs_YT
version: 2.2.1
version: 2.3.0
main: de.rayzs.pat.plugin.BungeeLoader
softDepends: [LuckPerms, PAPIProxyBridge]
@@ -161,6 +161,8 @@ custom-plugins:
commands:
- pl
- plugins
- bukkit:pl
- bukkit:plugins
message:
- '&fPlugins (0):'
@@ -178,6 +180,9 @@ custom-version:
- about
- version
- ver
- bukkit:about
- bukkit:version
- bukkit:ver
message:
- '&fThis server is running CraftBukkit version git-NasaSpigot-294 (MC: X)'
+18
View File
@@ -56,6 +56,19 @@ base-command-case-sensitive: true
# inside a PAT group.
allow-group-overruling: false
# Enabling this updates player groups on each server switch, meaning you can
# give a user the permission to a PAT group with a server context to only
# give the player the PAT group when he's on a certain server.
#
# Example command:
# lpv (...) permission set proantitab.group.<group> server=<server>
update-groups-per-server: false
# Enabling this forwards the notification message to the backend
# server so it will be displayed there as well. (Only in console)
forward-console-notification-alerts: false
# Here you can customize the server version that is displayed on a ping. (The text at the player-count)
custom-protocol-ping:
enabled: true
@@ -129,6 +142,8 @@ custom-plugins:
commands:
- pl
- plugins
- bukkit:pl
- bukkit:plugins
message:
- '&fPlugins (0):'
@@ -145,6 +160,9 @@ custom-version:
- about
- version
- ver
- bukkit:about
- bukkit:version
- bukkit:ver
message:
- '&fThis server is running CraftBukkit version git-NasaSpigot-294 (MC: X)'
+1 -1
View File
@@ -3,7 +3,7 @@ description: Hides more than just your plugins.
website: https://www.rayzs.de/products/proantitab/page
author: Rayzs_YT
version: 2.2.1
version: 2.3.0
api-version: 1.13
folia-supported: true
main: de.rayzs.pat.plugin.BukkitLoader