mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-13 12:41:58 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
735c3764db | ||
|
|
c160feb422 | ||
|
|
21ed81d9ce | ||
|
|
6c25c8570d | ||
|
|
560c9c3c8b | ||
|
|
095f4d6179 | ||
|
|
4d389a3e3b | ||
|
|
7f6a5aeba4 | ||
|
|
3006ffac30 | ||
|
|
d0a256a281 | ||
|
|
fceab89bc7 | ||
|
|
6c11525879 | ||
|
|
3decc0453b | ||
|
|
b4f9aec084 | ||
|
|
4cd1901e48 | ||
|
|
2aca1d42b0 | ||
|
|
23050b6788 | ||
|
|
07bd37bc51 | ||
|
|
de2ffe910f | ||
|
|
e3f33e0df4 | ||
|
|
d919bee580 | ||
|
|
ab10f02e3e | ||
|
|
647a4ed2b4 | ||
|
|
5b11e09ece | ||
|
|
5c006b3ba7 | ||
|
|
ba970a2ae4 | ||
|
|
2a51caba40 | ||
|
|
5b9035b766 | ||
|
|
41365e07f6 | ||
|
|
9fbaf9c628 | ||
|
|
730fe64eeb | ||
|
|
266fc497d8 | ||
|
|
871443b643 | ||
|
|
4094ee0211 | ||
|
|
0bcd099dcd | ||
|
|
04b603569d | ||
|
|
5a4951aec2 | ||
|
|
a16aa53561 | ||
|
|
a4bbcd5f99 | ||
|
|
75263af008 | ||
|
|
6c74c6f1d1 | ||
|
|
1ba064db1b | ||
|
|
e10c55a35b | ||
|
|
29a234d94d | ||
|
|
ccf97cca20 | ||
|
|
4ee5908c96 | ||
|
|
53128a49bb | ||
|
|
6092960af5 | ||
|
|
c9e4c9f077 | ||
|
|
d00a44de53 | ||
|
|
adfff4c520 | ||
|
|
fb0dac4e3b | ||
|
|
71a43bd431 | ||
|
|
339f0490cf | ||
|
|
3e9e71812a | ||
|
|
fd0e7c6f7f | ||
|
|
07a61712ea | ||
|
|
33080da0b1 | ||
|
|
02f48525e2 | ||
|
|
c2aacd1b0c | ||
|
|
b524ff0701 | ||
|
|
b5bffb6731 | ||
|
|
cf84c608a6 | ||
|
|
e61ea7c8b3 | ||
|
|
a63df948d7 | ||
|
|
509bad85c2 | ||
|
|
ef48117ab4 | ||
|
|
08724d4fa8 | ||
|
|
59e5c15c0f | ||
|
|
e96572b62b | ||
|
|
441eb3f439 | ||
|
|
479beb17de | ||
|
|
92939ba2fd | ||
|
|
4b4ba32191 | ||
|
|
2ba002d508 | ||
|
|
594f8a25da | ||
|
|
3ad852e1c8 | ||
|
|
b3a66eebee | ||
|
|
5baad90145 | ||
|
|
2ceb0b6219 |
No files matched your search
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Alihan
|
||||
Copyright (c) 2025 Alihan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>de.rayzs.pat</groupId>
|
||||
<artifactId>ProAntiTab</artifactId>
|
||||
<version>2.0.19</version>
|
||||
<version>2.1.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
||||
@@ -71,6 +71,14 @@ public class Communicator {
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet instanceof CommunicationPackets.UpdateCommandsPacket) {
|
||||
if (Reflection.isProxyServer())
|
||||
return;
|
||||
|
||||
CommunicationPackets.UpdateCommandsPacket updateCommandsPacket = (CommunicationPackets.UpdateCommandsPacket) packet;
|
||||
BukkitLoader.handleUpdateCommandsPacket(updateCommandsPacket);
|
||||
}
|
||||
|
||||
if (packet instanceof CommunicationPackets.ForcePermissionResetPacket) {
|
||||
if (Reflection.isProxyServer())
|
||||
return;
|
||||
@@ -219,6 +227,14 @@ public class Communicator {
|
||||
sendPacket(new CommunicationPackets.ForcePermissionResetPacket(Storage.TOKEN));
|
||||
}
|
||||
|
||||
public static void sendUpdateCommand() {
|
||||
sendPacket(new CommunicationPackets.UpdateCommandsPacket(Storage.TOKEN));
|
||||
}
|
||||
|
||||
public static void sendUpdateCommand(UUID targetUUID) {
|
||||
sendPacket(new CommunicationPackets.UpdateCommandsPacket(Storage.TOKEN, targetUUID));
|
||||
}
|
||||
|
||||
public static void sendFeedback() {
|
||||
sendPacket(new CommunicationPackets.FeedbackPacket(Storage.TOKEN, SERVER_ID.toString()));
|
||||
}
|
||||
|
||||
@@ -10,11 +10,13 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
|
||||
import com.mojang.brigadier.tree.RootCommandNode;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.utils.node.CommandNodeHelper;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
@@ -41,8 +43,6 @@ public class BungeePacketAnalyzer {
|
||||
private static final HashMap<ProxiedPlayer, Boolean> PLAYER_MODIFIED = new HashMap<>();
|
||||
private static final HashMap<ProxiedPlayer, String> PLAYER_INPUT_CACHE = new HashMap<>();
|
||||
|
||||
private static final com.mojang.brigadier.Command DUMMY_COMMAND = (context) -> 0;
|
||||
|
||||
private static final List<String> PLUGIN_COMMANDS = new ArrayList<>();
|
||||
|
||||
private static Class<?> channelWrapperClass, serverConnectionClass;
|
||||
@@ -50,6 +50,7 @@ public class BungeePacketAnalyzer {
|
||||
private static List<String> PROXY_COMMANDS;
|
||||
|
||||
static {
|
||||
CommandNodeHelper.setDefaultSuggestionProvider(Commands.SuggestionRegistry.ASK_SERVER);
|
||||
loadProxyCommands();
|
||||
}
|
||||
|
||||
@@ -138,6 +139,9 @@ public class BungeePacketAnalyzer {
|
||||
}
|
||||
|
||||
private static void modifyCommands(ProxiedPlayer player, Commands commands) {
|
||||
if (PermissionUtil.hasBypassPermission(player))
|
||||
return;
|
||||
|
||||
ServerInfo serverInfo = player.getServer().getInfo();
|
||||
String serverName = serverInfo.getName();
|
||||
|
||||
@@ -155,10 +159,18 @@ public class BungeePacketAnalyzer {
|
||||
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, serverName);
|
||||
|
||||
helper.removeIf(str -> !playerCommands.contains(str));
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Command> command : ProxyServer.getInstance().getPluginManager().getCommands()) {
|
||||
|
||||
if (ProxyServer.getInstance().getDisabledCommands().contains(command.getKey()))
|
||||
@@ -174,28 +186,30 @@ public class BungeePacketAnalyzer {
|
||||
String commandName = command.getKey();
|
||||
commandName = commandName.startsWith("/") ? commandName.substring(1) : commandName;
|
||||
|
||||
if (!playerCommands.contains(commandName)) {
|
||||
boolean tabablePluginCommand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(commandName);
|
||||
boolean tabableVersionCommand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(commandName);
|
||||
|
||||
if (!tabablePluginCommand && !tabableVersionCommand && !playerCommands.contains(commandName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CommandNode dummy = createDummyCommandNode(command.getKey());
|
||||
CommandNode dummy = CommandNodeHelper.createDummyCommandNode(command.getKey());
|
||||
commands.getRoot().addChild(dummy);
|
||||
}
|
||||
|
||||
// Disabled temporarily
|
||||
// PROXY_COMMANDS.stream().filter(playerCommands::contains).forEach(helper::add);
|
||||
// SubArgsModule.handleCommandNode(player.getUniqueId(), helper);
|
||||
|
||||
PROXY_COMMANDS.stream().filter(playerCommands::contains).forEach(input -> helper.add(input, true));
|
||||
SubArgsModule.handleCommandNode(player.getUniqueId(), helper);
|
||||
}
|
||||
|
||||
private static CommandNode createDummyCommandNode(String command) {
|
||||
return LiteralArgumentBuilder
|
||||
.literal(command)
|
||||
.executes(DUMMY_COMMAND)
|
||||
.then(RequiredArgumentBuilder
|
||||
.argument("args", (ArgumentType) StringArgumentType.greedyString())
|
||||
.suggests(Commands.SuggestionRegistry.ASK_SERVER)
|
||||
.executes(DUMMY_COMMAND))
|
||||
.build();
|
||||
public static void sendCommandsPacket() {
|
||||
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
|
||||
RootCommandNode root = new RootCommandNode();
|
||||
Commands packet = new Commands(root);
|
||||
|
||||
modifyCommands(player, packet);
|
||||
player.unsafe().sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
private static class PacketDecoder extends MessageToMessageDecoder<PacketWrapper> {
|
||||
@@ -247,7 +261,7 @@ public class BungeePacketAnalyzer {
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(player, StringUtils.replaceFirst(playerInput, "/", ""), server);
|
||||
|
||||
if (!cancelsBeforeHand)
|
||||
cancelsBeforeHand = !Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
cancelsBeforeHand = !Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
}
|
||||
|
||||
final String cursor = playerInput;
|
||||
|
||||
@@ -222,6 +222,10 @@ public class VelocityPacketAnalyzer {
|
||||
String command = offer.getText();
|
||||
if (command.startsWith("/")) command = StringUtils.replaceFirst(command, "/", "");
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !Storage.Blacklist.canPlayerAccessTab(player, command, player.getCurrentServer().get().getServerInfo().getName());
|
||||
});
|
||||
} else {
|
||||
@@ -237,6 +241,7 @@ public class VelocityPacketAnalyzer {
|
||||
}
|
||||
|
||||
response.getOffers().removeIf(offer -> !filteredTabCompletionEvent.getCompletion().contains(offer.getText()));
|
||||
|
||||
if (response.getOffers().isEmpty()) return;
|
||||
}
|
||||
}
|
||||
@@ -263,7 +268,7 @@ public class VelocityPacketAnalyzer {
|
||||
if (PermissionUtil.hasBypassPermission(player)) return;
|
||||
|
||||
final boolean newer = player.getProtocolVersion().getProtocol() > 340;
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, serverName);
|
||||
|
||||
if (commands.getRootNode().getChildren().size() == 1 && newer
|
||||
&& commands.getRootNode().getChild("args") != null
|
||||
@@ -280,6 +285,10 @@ public class VelocityPacketAnalyzer {
|
||||
if (command.getName().equals("args"))
|
||||
return false;
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command.getName()) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command.getName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !playerCommands.contains(command.getName());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,10 +4,12 @@ import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.api.storage.config.settings.*;
|
||||
import de.rayzs.pat.plugin.listeners.bukkit.BukkitAntiTabListener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.utils.permission.PermissionPlugin;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
@@ -70,14 +72,37 @@ public class Storage {
|
||||
public static String TOKEN = "", SERVER_NAME = null, CURRENT_VERSION = "", NEWER_VERSION = "";
|
||||
public static boolean OUTDATED = false, SEND_CONSOLE_NOTIFICATION = true;
|
||||
public static Object PLUGIN_OBJECT;
|
||||
public static boolean USE_LUCKPERMS = false, USE_GROUPMANAGER = false, USE_PLACEHOLDERAPI = false, USE_PAPIPROXYBRIDGE = false, USE_VIAVERSION = false, USE_VELOCITY = false, USE_SIMPLECLOUD;
|
||||
public static boolean USE_PLACEHOLDERAPI = false, USE_PAPIPROXYBRIDGE = false, USE_VIAVERSION = false, USE_VELOCITY = false, USE_SIMPLECLOUD;
|
||||
public static long LAST_SYNC = System.currentTimeMillis();
|
||||
|
||||
private static PermissionPlugin PERMISSION_PLUGIN = PermissionPlugin.NONE;
|
||||
|
||||
public static void initialize(PluginLoader loader, String currentVersion) {
|
||||
LOADER = loader;
|
||||
CURRENT_VERSION = currentVersion;
|
||||
}
|
||||
|
||||
public static void setPermissionPlugin(PermissionPlugin permissionPlugin) {
|
||||
if (PERMISSION_PLUGIN == PermissionPlugin.LUCKPERMS) {
|
||||
return;
|
||||
}
|
||||
|
||||
PERMISSION_PLUGIN = permissionPlugin;
|
||||
}
|
||||
|
||||
public static void broadcastPermissionsPluginNotice() {
|
||||
if (Storage.getPermissionPlugin() != PermissionPlugin.NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.warning("No known permissions plugin found, so some features may be disabled.");
|
||||
Logger.warning("Read more about it here: http://rayzs.de/products/proantitab/nkppf");
|
||||
}
|
||||
|
||||
public static PermissionPlugin getPermissionPlugin() {
|
||||
return PERMISSION_PLUGIN;
|
||||
}
|
||||
|
||||
public static void loadAll(boolean loadBlacklist) {
|
||||
loadConfig();
|
||||
loadToken();
|
||||
@@ -212,9 +237,15 @@ public class Storage {
|
||||
|
||||
Storage.getLoader().updateCommandCache();
|
||||
Communicator.sendPermissionReset();
|
||||
|
||||
if (!Reflection.isVelocityServer()) {
|
||||
BungeePacketAnalyzer.sendCommandsPacket();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
getLoader().handleReload();
|
||||
PermissionUtil.reloadPermissions();
|
||||
|
||||
if (Reflection.getMinor() < 13) {
|
||||
@@ -232,6 +263,14 @@ public class Storage {
|
||||
}
|
||||
}
|
||||
|
||||
// Quickly updates all player subarguments.
|
||||
public static void quickSubArgumentUpdate(UUID uuid) {
|
||||
List<String> playerCommands = new ArrayList<>(SubArgsModule.getServerCommands(uuid));
|
||||
playerCommands.addAll(SubArgsModule.getGroupCommands(uuid));
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(uuid, playerCommands, false);
|
||||
}
|
||||
|
||||
public static PluginLoader getLoader() {
|
||||
return LOADER;
|
||||
}
|
||||
@@ -301,7 +340,9 @@ public class Storage {
|
||||
public static CustomUnknownCommandSection CUSTOM_UNKNOWN_COMMAND = new CustomUnknownCommandSection();
|
||||
public static TurnBlacklistToWhitelistSection TURN_BLACKLIST_TO_WHITELIST = new TurnBlacklistToWhitelistSection();
|
||||
public static BaseCommandCaseSensitiveSection BASE_COMMAND_CASE_SENSITIVE = new BaseCommandCaseSensitiveSection();
|
||||
public static UpdateCommandsPerWorldSection UPDATE_COMMANDS_PER_WORLD = new UpdateCommandsPerWorldSection();
|
||||
public static UpdateGroupsPerWorldSection UPDATE_GROUPS_PER_WORLD = new UpdateGroupsPerWorldSection();
|
||||
public static UpdateGroupsPerServerSection UPDATE_GROUPS_PER_SERVER = new UpdateGroupsPerServerSection();
|
||||
|
||||
public static UpdateSection UPDATE = new UpdateSection();
|
||||
|
||||
public static void initialize() {}
|
||||
@@ -527,8 +568,10 @@ public class Storage {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command)) {
|
||||
return true;
|
||||
if (Storage.getPermissionPlugin() != PermissionPlugin.NONE) {
|
||||
if (PermissionUtil.hasBypassPermission(player, command)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return GroupManager.canAccessCommand(player, command, type, server);
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
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 UpdateGroupsPerServerSection extends ConfigStorage {
|
||||
|
||||
// Disabled for now
|
||||
public boolean ENABLED = false;
|
||||
|
||||
public UpdateGroupsPerServerSection() {
|
||||
super("update-groups-per-server");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
/*
|
||||
if (!Reflection.isProxyServer())
|
||||
return;
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
*/
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -4,12 +4,12 @@ import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
|
||||
public class UpdateCommandsPerWorldSection extends ConfigStorage {
|
||||
public class UpdateGroupsPerWorldSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
|
||||
public UpdateCommandsPerWorldSection() {
|
||||
super("update-commands-per-world");
|
||||
public UpdateGroupsPerWorldSection() {
|
||||
super("update-groups-per-world");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -22,6 +22,8 @@ import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.plugin.metrics.bStats;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.response.action.ActionHandler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -113,12 +115,12 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
if (getServer().getPluginManager().getPlugin("LuckPerms") != null) {
|
||||
LuckPermsAdapter.initialize();
|
||||
Bukkit.getOnlinePlayers().forEach(player -> PermissionUtil.setPlayerPermissions(player.getUniqueId()));
|
||||
}
|
||||
|
||||
final Plugin groupManagerPlugin = getServer().getPluginManager().getPlugin("GroupManager");
|
||||
if (groupManagerPlugin != null) {
|
||||
GroupManagerAdapter.initialize(groupManagerPlugin);
|
||||
Bukkit.getOnlinePlayers().forEach(player -> PermissionUtil.setPlayerPermissions(player.getUniqueId()));
|
||||
} else {
|
||||
final Plugin groupManagerPlugin = getServer().getPluginManager().getPlugin("GroupManager");
|
||||
if (groupManagerPlugin != null) {
|
||||
GroupManagerAdapter.initialize(groupManagerPlugin);
|
||||
Bukkit.getOnlinePlayers().forEach(player -> PermissionUtil.setPlayerPermissions(player.getUniqueId()));
|
||||
}
|
||||
}
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("ViaVersion") != null)
|
||||
@@ -128,7 +130,9 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
Logger.warning("Detected SimpleCloud. Therefore, MiniMessages are disabled!");
|
||||
}
|
||||
|
||||
Storage.broadcastPermissionsPluginNotice();
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.initialize();
|
||||
|
||||
@@ -255,14 +259,11 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
public static void delayedPermissionsReload() {
|
||||
@Override
|
||||
public void delayedPermissionsReload() {
|
||||
PATScheduler.createScheduler(PermissionUtil::reloadPermissions, 40);
|
||||
}
|
||||
|
||||
public static void userPermissionsReload(UUID uuid) {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(BukkitLoader.getPlugin(), () -> PermissionUtil.reloadPermissions(uuid));
|
||||
}
|
||||
|
||||
public void startUpdaterTask() {
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED)
|
||||
return;
|
||||
@@ -275,6 +276,19 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
}, 20L, 20L * Storage.ConfigSections.Settings.UPDATE.PERIOD);
|
||||
}
|
||||
|
||||
public static void handleUpdateCommandsPacket(CommunicationPackets.UpdateCommandsPacket packet) {
|
||||
|
||||
if (!packet.hasTargetUUID()) {
|
||||
Bukkit.getOnlinePlayers().forEach(Player::updateCommands);
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(packet.getTargetUUID());
|
||||
if (player != null) {
|
||||
player.updateCommands();
|
||||
}
|
||||
}
|
||||
|
||||
public static void synchronize(CommunicationPackets.PacketBundle packetBundle) {
|
||||
Storage.LAST_SYNC = System.currentTimeMillis();
|
||||
Communicator.sendFeedback();
|
||||
@@ -334,8 +348,13 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.ENABLED != unknownCommandPacket.isEnabled())
|
||||
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.ENABLED = unknownCommandPacket.isEnabled();
|
||||
|
||||
if (!loaded)
|
||||
if (!loaded) {
|
||||
loaded = true;
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
sender.updateGroups();
|
||||
});
|
||||
}
|
||||
|
||||
if (Reflection.getMinor() >= 13 && updatedList) {
|
||||
BukkitAntiTabListener.updateCommands();
|
||||
@@ -421,13 +440,8 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
List<String> allowedCommands = new ArrayList<>(result).stream().filter(command -> {
|
||||
|
||||
if (turn) {
|
||||
return Storage.Blacklist.getBlacklist().isListed(command);
|
||||
} else {
|
||||
return !Storage.Blacklist.getBlacklist().isListed(command);
|
||||
}
|
||||
|
||||
boolean contains = Storage.Blacklist.getBlacklist().getCommands().contains(command);
|
||||
return turn == contains;
|
||||
}).toList();
|
||||
|
||||
lastCommandsLoad = System.currentTimeMillis();
|
||||
|
||||
@@ -10,6 +10,7 @@ import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.response.action.ActionHandler;
|
||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||
import de.rayzs.pat.plugin.commands.BungeeCommand;
|
||||
@@ -94,7 +95,10 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
Logger.warning("Detected SimpleCloud and therefore MiniMessages by Kyori are disabled!");
|
||||
|
||||
BungeePacketAnalyzer.injectAll();
|
||||
|
||||
Storage.broadcastPermissionsPluginNotice();
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.initialize();
|
||||
|
||||
@@ -122,6 +126,16 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
BungeePacketAnalyzer.loadProxyCommands();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delayedPermissionsReload() {
|
||||
getProxy().getScheduler().schedule(this, () -> {
|
||||
PermissionUtil.reloadPermissions();
|
||||
Storage.getLoader().updateCommandCache();
|
||||
|
||||
Communicator.sendRequest();
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesCommandExist(String command) {
|
||||
return false;
|
||||
|
||||
@@ -13,6 +13,8 @@ public interface PluginLoader {
|
||||
|
||||
HashMap<String, CommandsCache> getCommandsCacheMap();
|
||||
|
||||
void delayedPermissionsReload();
|
||||
|
||||
void updateCommandCache();
|
||||
|
||||
List<String> getServerNames();
|
||||
|
||||
@@ -37,7 +37,7 @@ import java.util.*;
|
||||
|
||||
@Plugin(name = "ProAntiTab",
|
||||
id = "proantitab",
|
||||
version = "2.0.19",
|
||||
version = "2.1.0",
|
||||
authors = "Rayzs_YT",
|
||||
description = "Hide more than just your plugins. Hide almost everything!",
|
||||
url = "https://www.rayzs.de/products/proantitab/page",
|
||||
@@ -116,7 +116,9 @@ public class VelocityLoader implements PluginLoader {
|
||||
if(Storage.USE_SIMPLECLOUD)
|
||||
Logger.warning("Detected SimpleCloud and therefore MiniMessages by Kyori are disabled!");
|
||||
|
||||
Storage.broadcastPermissionsPluginNotice();
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.initialize();
|
||||
}
|
||||
@@ -125,10 +127,12 @@ public class VelocityLoader implements PluginLoader {
|
||||
return logger;
|
||||
}
|
||||
|
||||
public static void delayedPermissionsReload() {
|
||||
@Override
|
||||
public void delayedPermissionsReload() {
|
||||
server.getScheduler().buildTask(VelocityLoader.instance, () -> {
|
||||
PermissionUtil.reloadPermissions();
|
||||
Storage.getLoader().updateCommandCache();
|
||||
|
||||
}).delay(1, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package de.rayzs.pat.plugin.listeners.bukkit;
|
||||
|
||||
import de.rayzs.pat.api.event.events.FilteredSuggestionEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.adapter.ViaVersionAdapter;
|
||||
@@ -16,14 +18,23 @@ import java.util.*;
|
||||
public class BukkitAntiTabListener implements Listener {
|
||||
|
||||
private static final CommandsCache COMMANDS_CACHE = new CommandsCache();
|
||||
private static final List<UUID> knownOperators = new ArrayList<>();
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandSend(PlayerCommandSendEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
UUID uuid = player.getUniqueId();
|
||||
String uuidSubstring = uuid.toString().substring(uuid.toString().length() - 5);
|
||||
final Player player = event.getPlayer();
|
||||
final UUID uuid = player.getUniqueId();
|
||||
|
||||
|
||||
if (Storage.USE_VELOCITY) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.isOp()) {
|
||||
if (!knownOperators.contains(uuid)) {
|
||||
knownOperators.add(uuid);
|
||||
}
|
||||
|
||||
if (Storage.USE_VELOCITY || player.isOp()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -32,8 +43,9 @@ public class BukkitAntiTabListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getCommands().isEmpty()) {
|
||||
return;
|
||||
@@ -42,19 +54,35 @@ public class BukkitAntiTabListener implements Listener {
|
||||
List<String> allCommands = getCommands();
|
||||
COMMANDS_CACHE.handleCommands(allCommands);
|
||||
|
||||
if (!player.isOp() && knownOperators.contains(uuid)) {
|
||||
knownOperators.remove(uuid);
|
||||
|
||||
CommandSender sender = CommandSenderHandler.getSenderFromUUID(uuid);
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<String> playerCommands = COMMANDS_CACHE.getPlayerCommands(new ArrayList<>(event.getCommands()), player, player.getUniqueId());
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, playerCommands);
|
||||
final List<String> playerCommands = COMMANDS_CACHE.getPlayerCommands(new ArrayList<>(event.getCommands()), player);
|
||||
final FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, playerCommands);
|
||||
|
||||
event.getCommands().clear();
|
||||
|
||||
if (filteredSuggestionEvent.isCancelled())
|
||||
if (filteredSuggestionEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.getCommands().addAll(filteredSuggestionEvent.getSuggestions());
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.ALWAYS_TAB_COMPLETABLE) {
|
||||
event.getCommands().addAll(Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines());
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.ALWAYS_TAB_COMPLETABLE) {
|
||||
event.getCommands().addAll(Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines());
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getCommands() {
|
||||
@@ -88,10 +116,12 @@ public class BukkitAntiTabListener implements Listener {
|
||||
|
||||
public static void handleTabCompletion(UUID uuid) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
handleTabCompletion(player);
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
handleTabCompletion(player, getCommands());
|
||||
}
|
||||
|
||||
public static void handleTabCompletion(Player player) {
|
||||
|
||||
@@ -68,22 +68,64 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
String command = event.getMessage(),
|
||||
worldName = world.getName();
|
||||
|
||||
boolean bypassPermission = PermissionUtil.hasBypassPermission(player, command);
|
||||
|
||||
command = command.substring(1);
|
||||
command = StringUtils.getFirstArg(command);
|
||||
|
||||
final String displayName = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
//command = command.toLowerCase();
|
||||
final String displayCommand = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
|
||||
"%player%", player.getName(),
|
||||
"%command%", displayName,
|
||||
"%command%", displayCommand,
|
||||
"%world%", worldName);
|
||||
|
||||
if (bypassPermission)
|
||||
if (PermissionUtil.hasBypassPermission(player, command)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
|
||||
MessageTranslator.send(
|
||||
player,
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE,
|
||||
"%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
Logger.info(notificationMessage);
|
||||
|
||||
Storage.NOTIFY_PLAYERS.forEach(uuid -> {
|
||||
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
|
||||
if (p != null) {
|
||||
MessageTranslator.send(p, notificationMessage);
|
||||
}
|
||||
});
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
|
||||
|
||||
MessageTranslator.send(
|
||||
player,
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE,
|
||||
"%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
Logger.info(notificationMessage);
|
||||
|
||||
Storage.NOTIFY_PLAYERS.forEach(uuid -> {
|
||||
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
|
||||
if (p != null) {
|
||||
MessageTranslator.send(p, notificationMessage);
|
||||
}
|
||||
});
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
|
||||
return;
|
||||
|
||||
@@ -9,6 +9,7 @@ import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionPlugin;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
@@ -29,30 +30,39 @@ public class BukkitPlayerListener implements Listener {
|
||||
final Player player = event.getPlayer();
|
||||
final UUID uuid = player.getUniqueId();
|
||||
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
sender.updateSenderObject(player);
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
BackendUpdater.handle();
|
||||
}
|
||||
|
||||
PermissionUtil.setPlayerPermissions(player.getUniqueId());
|
||||
CustomServerBrand.preparePlayer(player);
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
|
||||
if (CustomServerBrand.isEnabled()) {
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
}
|
||||
|
||||
if (!Storage.USE_LUCKPERMS && !Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
PATScheduler.createScheduler(() -> {
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
if (Storage.getPermissionPlugin() != PermissionPlugin.LUCKPERMS) {
|
||||
|
||||
assert sender != null;
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
PATScheduler.createScheduler(() -> {
|
||||
|
||||
if (Reflection.getMinor() >= 13) {
|
||||
BukkitAntiTabListener.handleTabCompletion(player.getUniqueId());
|
||||
}
|
||||
}, 20);
|
||||
if (Storage.getPermissionPlugin() == PermissionPlugin.GROUPMANAGER) {
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
} else {
|
||||
sender.updateGroups();
|
||||
}
|
||||
|
||||
if (Reflection.getMinor() >= 13) {
|
||||
BukkitAntiTabListener.handleTabCompletion(player);
|
||||
}
|
||||
}, 20);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!BukkitPacketAnalyzer.inject(player)) {
|
||||
@@ -66,11 +76,9 @@ public class BukkitPlayerListener implements Listener {
|
||||
}, 10);
|
||||
}
|
||||
|
||||
// Update sub arguments for <1.12.2 servers.
|
||||
if (Reflection.getMinor() < 13) {
|
||||
List<String> playerCommands = new ArrayList<>(SubArgsModule.getServerCommands(uuid));
|
||||
playerCommands.addAll(SubArgsModule.getGroupCommands(uuid));
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(uuid, playerCommands, false);
|
||||
Storage.quickSubArgumentUpdate(uuid);
|
||||
}
|
||||
|
||||
if (Storage.OUTDATED && PermissionUtil.hasPermission(player, "joinupdate")) {
|
||||
@@ -99,7 +107,7 @@ public class BukkitPlayerListener implements Listener {
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.UPDATE_COMMANDS_PER_WORLD.ENABLED) {
|
||||
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_WORLD.ENABLED) {
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
assert sender != null;
|
||||
|
||||
@@ -36,32 +36,13 @@ public class BungeeAntiTabListener implements Listener {
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player, cursor, event.getSuggestions());
|
||||
List<String> suggestions = filteredTabCompletionEvent.getCompletion();
|
||||
|
||||
event.getSuggestions().removeIf(suggestion -> !suggestions.contains(suggestion));
|
||||
}
|
||||
event.getSuggestions().removeIf(suggestion -> {
|
||||
|
||||
@EventHandler
|
||||
public void onTabComplete(TabCompleteResponseEvent event) {
|
||||
// Ignoring this at first, due to transfer to the packet-based solution only. Hehe
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(suggestion) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(suggestion)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
if (!(event.getSender() instanceof ProxiedPlayer))
|
||||
return;
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
|
||||
|
||||
ServerInfo serverInfo = player.getServer().getInfo();
|
||||
String serverName = serverInfo.getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName))
|
||||
return;
|
||||
|
||||
if(PermissionUtil.hasBypassPermission(player))
|
||||
return;
|
||||
|
||||
event.getSuggestions().removeIf(command -> !Storage.Blacklist.canPlayerAccessTab(player, command, serverName));
|
||||
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, event.getSuggestions());
|
||||
if (filteredSuggestionEvent.isCancelled()) event.getSuggestions().clear();
|
||||
*/
|
||||
return !suggestions.contains(suggestion);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,7 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
String serverName = player.getServer().getInfo().getName();
|
||||
String command = event.getMessage();
|
||||
|
||||
boolean bypassPermission = PermissionUtil.hasBypassPermission(player, command);
|
||||
|
||||
if (bypassPermission)
|
||||
if (PermissionUtil.hasBypassPermission(player, command))
|
||||
return;
|
||||
|
||||
command = command.startsWith("/") ? command.substring(1) : command;
|
||||
@@ -38,7 +36,6 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
|
||||
final String displayCommand = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
|
||||
//command = command.toLowerCase();
|
||||
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
|
||||
@@ -46,6 +43,50 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
"%command%", displayCommand,
|
||||
"%server%", serverName);
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
|
||||
MessageTranslator.send(
|
||||
player,
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE,
|
||||
"%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
Logger.info(notificationMessage);
|
||||
|
||||
Storage.NOTIFY_PLAYERS.stream().forEach(uuid -> {
|
||||
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
|
||||
if (p != null) {
|
||||
MessageTranslator.send(p, notificationMessage);
|
||||
}
|
||||
});
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
|
||||
|
||||
MessageTranslator.send(
|
||||
player,
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE,
|
||||
"%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
Logger.info(notificationMessage);
|
||||
|
||||
Storage.NOTIFY_PLAYERS.forEach(uuid -> {
|
||||
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
|
||||
if (p != null) {
|
||||
MessageTranslator.send(p, notificationMessage);
|
||||
}
|
||||
});
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
|
||||
return;
|
||||
|
||||
|
||||
+19
-4
@@ -6,6 +6,8 @@ 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;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
@@ -19,7 +21,10 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
final ProxiedPlayer player = event.getPlayer();
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
sender.updateSenderObject(player);
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
|
||||
if(CustomServerBrand.isEnabled())
|
||||
@@ -27,7 +32,8 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
if (player.isConnected()) CustomServerBrand.sendBrandToPlayer(player);
|
||||
}, 500, TimeUnit.MILLISECONDS);
|
||||
|
||||
PermissionUtil.setPlayerPermissions(player.getUniqueId());
|
||||
PermissionUtil.setPlayerPermissions(sender);
|
||||
sender.updateGroups();
|
||||
|
||||
if(Storage.OUTDATED && PermissionUtil.hasPermission(player, "joinupdate")) {
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeLoader.getPlugin(), () -> {
|
||||
@@ -44,8 +50,16 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
|
||||
BungeePacketAnalyzer.inject(player);
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1)
|
||||
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_SERVER.ENABLED) {
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
assert sender != null;
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
}
|
||||
@@ -58,8 +72,9 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
PermissionUtil.resetPermissions(player.getUniqueId());
|
||||
BungeePacketAnalyzer.uninject(player);
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1)
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
}
|
||||
|
||||
@@ -21,15 +21,12 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onProxyDefineCommands(ProxyDefineCommandsEvent event) {
|
||||
|
||||
System.out.println("CALL");
|
||||
|
||||
if(!(event.getReceiver() instanceof ProxiedPlayer) || event.getCommands().isEmpty()) return;
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
String serverName = player.getServer().getInfo().getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName))
|
||||
if (Storage.Blacklist.isDisabledServer(serverName) || PermissionUtil.hasBypassPermission(player))
|
||||
return;
|
||||
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
@@ -44,13 +41,18 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
event.getCommands().forEach((key, value) -> commandsAsString.add(key));
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
if(PermissionUtil.hasBypassPermission(player)) return;
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, serverName);
|
||||
event.getCommands().entrySet().removeIf(command -> {
|
||||
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
|
||||
event.getCommands().entrySet().removeIf(command -> playerCommands.contains(command.getKey()));
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command.getKey()) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command.getKey())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return playerCommands.contains(command.getKey());
|
||||
});
|
||||
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, new ArrayList<>(event.getCommands().keySet()));
|
||||
if(filteredSuggestionEvent.isCancelled()) event.getCommands().clear();
|
||||
if (filteredSuggestionEvent.isCancelled()) event.getCommands().clear();
|
||||
|
||||
for (String commandName : filteredSuggestionEvent.getSuggestions()) {
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package de.rayzs.pat.plugin.listeners.velocity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -15,6 +14,7 @@ import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredSuggestionEvent;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
|
||||
@@ -29,6 +29,11 @@ public class VelocityAntiTabListener {
|
||||
@Subscribe (order = PostOrder.LAST)
|
||||
public void onTabComplete(TabCompleteEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!event.getPartialMessage().startsWith("/")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String serverName = player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "unknown";
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName))
|
||||
@@ -36,7 +41,14 @@ public class VelocityAntiTabListener {
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player) || event.getSuggestions().isEmpty() || !player.getCurrentServer().isPresent()) return;
|
||||
|
||||
event.getSuggestions().removeIf(command -> !Storage.Blacklist.canPlayerAccessTab(player, command, serverName));
|
||||
event.getSuggestions().removeIf(command -> {
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !Storage.Blacklist.canPlayerAccessTab(player, command, serverName);
|
||||
});
|
||||
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, event.getSuggestions());
|
||||
if(filteredSuggestionEvent.isCancelled()) event.getSuggestions().clear();
|
||||
}
|
||||
@@ -50,6 +62,10 @@ public class VelocityAntiTabListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
@@ -64,12 +80,8 @@ public class VelocityAntiTabListener {
|
||||
event.getRootNode().getChildren().stream().filter(command -> command != null && command.getName() != null).forEach(command -> commandsAsString.add(command.getName()));
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean newer = player.getProtocolVersion().getProtocol() > 340, argsChildrenExist = event.getRootNode().getChild("args") != null;
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, serverName);
|
||||
|
||||
if (event.getRootNode().getChildren().size() == 1
|
||||
&& newer && argsChildrenExist
|
||||
@@ -88,10 +100,14 @@ public class VelocityAntiTabListener {
|
||||
if (command.getName().equals("args"))
|
||||
return false;
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command.getName()) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command.getName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !playerCommands.contains(command.getName());
|
||||
});
|
||||
} catch (Exception exception) {
|
||||
System.out.println("An error occurred while processing commands in PAT: " + exception.getMessage());
|
||||
Logger.warning("An error occurred while processing commands in PAT: " + exception.getMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
+46
-6
@@ -40,15 +40,11 @@ public class VelocityBlockCommandListener {
|
||||
? player.getCurrentServer().get().getServerInfo().getName()
|
||||
: "unknown";
|
||||
|
||||
boolean bypassPermission = PermissionUtil.hasBypassPermission(player, command);
|
||||
|
||||
if (bypassPermission)
|
||||
if (PermissionUtil.hasBypassPermission(player, command))
|
||||
return event;
|
||||
|
||||
final String displayCommand = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
|
||||
//command = command.toLowerCase();
|
||||
|
||||
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
|
||||
@@ -57,6 +53,50 @@ public class VelocityBlockCommandListener {
|
||||
"%server%", serverName
|
||||
);
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
|
||||
MessageTranslator.send(
|
||||
player,
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE,
|
||||
"%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
MessageTranslator.send(consoleSender, notificationMessage);
|
||||
|
||||
Storage.NOTIFY_PLAYERS.forEach(uuid -> {
|
||||
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
|
||||
if (p != null) {
|
||||
MessageTranslator.send(p, notificationMessage);
|
||||
}
|
||||
});
|
||||
|
||||
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
return event;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
|
||||
|
||||
MessageTranslator.send(
|
||||
player,
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE,
|
||||
"%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
MessageTranslator.send(consoleSender, notificationMessage);
|
||||
|
||||
Storage.NOTIFY_PLAYERS.forEach(uuid -> {
|
||||
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
|
||||
if (p != null) {
|
||||
MessageTranslator.send(p, notificationMessage);
|
||||
}
|
||||
});
|
||||
|
||||
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
return event;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
|
||||
return event;
|
||||
|
||||
@@ -76,7 +116,7 @@ public class VelocityBlockCommandListener {
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
MessageTranslator.send(consoleSender, notificationMessage);
|
||||
|
||||
Storage.NOTIFY_PLAYERS.stream().forEach(uuid -> {
|
||||
Storage.NOTIFY_PLAYERS.forEach(uuid -> {
|
||||
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
|
||||
if (p != null) {
|
||||
MessageTranslator.send(p, notificationMessage);
|
||||
|
||||
+21
-4
@@ -12,6 +12,9 @@ import com.velocitypowered.api.event.player.*;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import com.velocitypowered.api.proxy.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class VelocityConnectionListener {
|
||||
@@ -26,7 +29,10 @@ public class VelocityConnectionListener {
|
||||
|
||||
@Subscribe
|
||||
public void onServerPreConnect(ServerPreConnectEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
sender.updateSenderObject(player);
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
|
||||
if(CustomServerBrand.isEnabled())
|
||||
@@ -34,7 +40,8 @@ public class VelocityConnectionListener {
|
||||
if (player.isActive()) CustomServerBrand.sendBrandToPlayer(player);
|
||||
}).delay(500, TimeUnit.MILLISECONDS).schedule();
|
||||
|
||||
PermissionUtil.setPlayerPermissions(player.getUniqueId());
|
||||
PermissionUtil.setPlayerPermissions(sender);
|
||||
sender.updateGroups();
|
||||
|
||||
if(Storage.OUTDATED && PermissionUtil.hasPermission(player, "joinupdate")) {
|
||||
server.getScheduler().buildTask(loader, () -> {
|
||||
@@ -48,10 +55,20 @@ public class VelocityConnectionListener {
|
||||
public void onServerSwitch(ServerConnectedEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(!VelocityPacketAnalyzer.isInjected(player))
|
||||
if (!VelocityPacketAnalyzer.isInjected(player))
|
||||
VelocityPacketAnalyzer.inject(player);
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) return;
|
||||
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_SERVER.ENABLED) {
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
assert sender != null;
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import javax.net.ssl.HttpsURLConnection;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.permission.PermissionPlugin;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
@@ -105,9 +106,15 @@ public class Logger {
|
||||
.append("\n");
|
||||
|
||||
builder.append(" LuckPerms: ")
|
||||
.append(Storage.USE_LUCKPERMS)
|
||||
.append(Storage.getPermissionPlugin() == PermissionPlugin.LUCKPERMS)
|
||||
.append("\n");
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
builder.append(" GroupManager: ")
|
||||
.append(Storage.getPermissionPlugin() == PermissionPlugin.GROUPMANAGER)
|
||||
.append("\n");
|
||||
}
|
||||
|
||||
builder.append(" PlaceholderAPI: ")
|
||||
.append(Storage.USE_PLACEHOLDERAPI)
|
||||
.append("\n");
|
||||
|
||||
@@ -5,9 +5,12 @@ import de.rayzs.pat.plugin.modules.events.ExecuteCommand;
|
||||
import de.rayzs.pat.plugin.modules.events.TabCompletion;
|
||||
import de.rayzs.pat.plugin.modules.events.UpdateList;
|
||||
import de.rayzs.pat.utils.node.CommandNodeHelper;
|
||||
import de.rayzs.pat.utils.permission.PermissionPlugin;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import de.rayzs.pat.utils.subargs.*;
|
||||
import java.util.stream.Collectors;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
@@ -72,11 +75,11 @@ public class SubArgsModule {
|
||||
ArgumentSource source = arguments.TAB_ARGUMENTS;
|
||||
if (source == null) return;
|
||||
|
||||
List<String> inputs = source.getAllInputs().stream().filter(str -> !str.contains("%")).toList();
|
||||
List<String> inputs = source.getAllInputs();
|
||||
List<String> allEntries = inputs.stream().map(StringUtils::getFirstArg).toList();
|
||||
|
||||
helper.removeIf(allEntries::contains);
|
||||
inputs.forEach(helper::add);
|
||||
inputs.forEach(input -> helper.add(input, true));
|
||||
}
|
||||
|
||||
public static List<String> getServerCommands(UUID uuid) {
|
||||
@@ -104,7 +107,14 @@ public class SubArgsModule {
|
||||
|
||||
public static List<String> getGroupCommands(UUID uuid, String serverName) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
List<Group> groups = GroupManager.getPlayerGroups(uuid);
|
||||
List<Group> groups;
|
||||
|
||||
if (Storage.getPermissionPlugin() == PermissionPlugin.NONE) {
|
||||
CommandSender sender = CommandSenderHandler.getSenderFromUUID(uuid);
|
||||
groups = GroupManager.getPlayerGroups(sender);
|
||||
} else {
|
||||
groups = GroupManager.getPlayerGroups(uuid);
|
||||
}
|
||||
|
||||
if (serverName == null) {
|
||||
groups.forEach(group -> commands.addAll(group.getCommands()));
|
||||
|
||||
@@ -35,34 +35,6 @@ public class ExecuteCommand extends ExecuteCommandEvent {
|
||||
|
||||
UUID uuid = sender.getUniqueId();
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
|
||||
MessageTranslator.send(
|
||||
event.getSenderObj(),
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE,
|
||||
"%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
event.setBlocked(true);
|
||||
event.setCancelled(true);
|
||||
event.setDoesNotify(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
|
||||
|
||||
MessageTranslator.send(
|
||||
event.getSenderObj(),
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE,
|
||||
"%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
event.setBlocked(true);
|
||||
event.setCancelled(true);
|
||||
event.setDoesNotify(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isBlocked(sender, command)) {
|
||||
event.setBlocked(true);
|
||||
event.setCancelled(true);
|
||||
|
||||
@@ -8,6 +8,7 @@ import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CreateGroupCommand extends ProCommand {
|
||||
@@ -50,6 +51,6 @@ public class CreateGroupCommand extends ProCommand {
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||
return args.length < 2 ? GroupManager.getGroupNames() : null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -26,7 +26,7 @@ public class ListGroupsCommand extends ProCommand {
|
||||
|
||||
String message = Storage.ConfigSections.Messages.GROUP.LIST_GROUP_MESSAGE;
|
||||
message = StringUtils.replace(message,
|
||||
"%size%", String.valueOf(Storage.Blacklist.getBlacklist().getCommands().size()),
|
||||
"%size%", String.valueOf(GroupManager.getGroups().size()),
|
||||
"%groups%", groupsListMessage
|
||||
);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.*;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
|
||||
public class CommandsCache {
|
||||
|
||||
@@ -45,9 +46,10 @@ public class CommandsCache {
|
||||
return;
|
||||
|
||||
LinkedList<String> tmpFilteredCommands = new LinkedList<>();
|
||||
allCommands = new ArrayList<>(commands);
|
||||
List<String> tmpAllCommands = new ArrayList<>(commands);
|
||||
allCommands = tmpAllCommands;
|
||||
|
||||
for (String command : allCommands) {
|
||||
for (String command : tmpAllCommands) {
|
||||
command = StringUtils.getFirstArg(command);
|
||||
|
||||
Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(command);
|
||||
@@ -67,11 +69,11 @@ public class CommandsCache {
|
||||
filteredCommands = tmpFilteredCommands;
|
||||
}
|
||||
|
||||
public List<String> getPlayerCommands(Collection<String> unfilteredCommands, Object targetObj, UUID uuid) {
|
||||
return getPlayerCommands(unfilteredCommands, targetObj, uuid, null);
|
||||
public List<String> getPlayerCommands(Collection<String> unfilteredCommands, Object targetObj) {
|
||||
return getPlayerCommands(unfilteredCommands, targetObj, null);
|
||||
}
|
||||
|
||||
public List<String> getPlayerCommands(Collection<String> unfilteredCommands, Object targetObj, UUID uuid, String serverName) {
|
||||
public List<String> getPlayerCommands(Collection<String> unfilteredCommands, Object targetObj, String serverName) {
|
||||
List<String> playerCommands = new LinkedList<>(unfilteredCommands);
|
||||
List<String> localFilteredCommands = filteredCommands == null ? null : new LinkedList<>();
|
||||
|
||||
@@ -83,27 +85,30 @@ public class CommandsCache {
|
||||
for (int i = 0; i < max; i++) {
|
||||
try {
|
||||
String command = filteredCommands.get(i);
|
||||
filteredCommands.add(command);
|
||||
} catch (ArrayIndexOutOfBoundsException outOfBoundsException) {
|
||||
System.out.println("Array is out of bounds " + i + "/" + max + "! " + outOfBoundsException.getMessage());
|
||||
localFilteredCommands.add(command);
|
||||
} catch (IndexOutOfBoundsException indexOutOfBoundsException) {
|
||||
Logger.warning("Array is out of bounds " + i + "/" + max + "! " + indexOutOfBoundsException.getMessage());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean hasNamespaceBypass = Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(targetObj);
|
||||
if (!PermissionUtil.hasBypassPermission(targetObj)) {
|
||||
boolean hasNamespaceBypass = Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(targetObj);
|
||||
|
||||
playerCommands.removeIf(command -> {
|
||||
if (!hasNamespaceBypass && Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command)) {
|
||||
return true;
|
||||
}
|
||||
playerCommands.removeIf(command -> {
|
||||
if (!hasNamespaceBypass && Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (localFilteredCommands.contains(command)) {
|
||||
return false;
|
||||
}
|
||||
if (localFilteredCommands.contains(command)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !Storage.Blacklist.canPlayerAccessTab(targetObj, command, serverName);
|
||||
});
|
||||
return !Storage.Blacklist.canPlayerAccessTab(targetObj, command, serverName);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(targetObj, playerCommands, serverName != null);
|
||||
|
||||
|
||||
@@ -58,6 +58,33 @@ public class CommunicationPackets {
|
||||
}
|
||||
}
|
||||
|
||||
public static class UpdateCommandsPacket implements CommunicationPacket, Serializable {
|
||||
private final String proxyToken;
|
||||
private final UUID targetUUID;
|
||||
|
||||
public UpdateCommandsPacket(String proxyToken) {
|
||||
this.proxyToken = proxyToken;
|
||||
this.targetUUID = null;
|
||||
}
|
||||
|
||||
public UpdateCommandsPacket(String proxyToken, UUID targetUUID) {
|
||||
this.proxyToken = proxyToken;
|
||||
this.targetUUID = targetUUID;
|
||||
}
|
||||
|
||||
public boolean hasTargetUUID() {
|
||||
return targetUUID != null;
|
||||
}
|
||||
|
||||
public UUID getTargetUUID() {
|
||||
return targetUUID;
|
||||
}
|
||||
|
||||
public boolean isToken(String token) {
|
||||
return proxyToken.equals(token);
|
||||
}
|
||||
}
|
||||
|
||||
public static class FeedbackPacket implements CommunicationPacket, Serializable {
|
||||
private final String proxyToken, serverId;
|
||||
|
||||
|
||||
@@ -16,13 +16,19 @@ public class ExpireCache<T, K> {
|
||||
}
|
||||
|
||||
public boolean put(T t, K k) {
|
||||
if(contains(t)) return false;
|
||||
if (contains(t)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
cache.put(t, k);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean remove(T t) {
|
||||
if(!contains(t)) return false;
|
||||
if (!contains(t)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
cache.invalidate(t);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@ package de.rayzs.pat.utils.adapter;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.plugin.listeners.bukkit.BukkitAntiTabListener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.permission.PermissionPlugin;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
@@ -24,8 +26,10 @@ public class GroupManagerAdapter implements Listener {
|
||||
private static GroupManager manager;
|
||||
|
||||
public static void initialize(Plugin plugin) {
|
||||
Logger.info("Successfully hooked into GroupManager for easier usage.");
|
||||
|
||||
Storage.setPermissionPlugin(PermissionPlugin.GROUPMANAGER);
|
||||
manager = (GroupManager) plugin;
|
||||
Storage.USE_GROUPMANAGER = true;
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new GroupManagerListener(), BukkitLoader.getPlugin());
|
||||
}
|
||||
@@ -52,26 +56,18 @@ public class GroupManagerAdapter implements Listener {
|
||||
@EventHandler
|
||||
public void onGMUser(GMUserEvent event) {
|
||||
PATScheduler.createScheduler(() -> {
|
||||
BukkitLoader.userPermissionsReload(event.getUser().getBukkitPlayer().getUniqueId());
|
||||
PermissionUtil.reloadPermissions(event.getUser().getBukkitPlayer().getUniqueId());
|
||||
}, 10);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onGMGroup(GMGroupEvent event) {
|
||||
PATScheduler.createScheduler(() -> {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
BukkitLoader.userPermissionsReload(player.getUniqueId());
|
||||
});
|
||||
}, 10);
|
||||
PATScheduler.createScheduler(PermissionUtil::reloadPermissions, 10);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onGMSystem(GMSystemEvent event) {
|
||||
PATScheduler.createScheduler(() -> {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
BukkitLoader.userPermissionsReload(player.getUniqueId());
|
||||
});
|
||||
}, 10);
|
||||
PATScheduler.createScheduler(PermissionUtil::reloadPermissions, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
package de.rayzs.pat.utils.adapter;
|
||||
|
||||
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.event.sync.PreNetworkSyncEvent;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import net.luckperms.api.model.user.User;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import net.luckperms.api.event.EventBus;
|
||||
import net.luckperms.api.event.node.*;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
@@ -22,24 +24,12 @@ public class LuckPermsAdapter {
|
||||
public static void initialize() {
|
||||
Logger.info("Successfully hooked into LuckPerms for easier usage.");
|
||||
|
||||
Storage.USE_LUCKPERMS = true;
|
||||
Storage.setPermissionPlugin(PermissionPlugin.LUCKPERMS);
|
||||
PROVIDER = LuckPermsProvider.get();
|
||||
EventBus eventBus = PROVIDER.getEventBus();
|
||||
|
||||
eventBus.subscribe(Storage.PLUGIN_OBJECT, NodeMutateEvent.class, LuckPermsAdapter::onNoteMutate);
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
eventBus.subscribe(Storage.PLUGIN_OBJECT, PreNetworkSyncEvent.class, event -> BukkitLoader.delayedPermissionsReload());
|
||||
|
||||
} else {
|
||||
|
||||
if (Reflection.isVelocityServer()) {
|
||||
eventBus.subscribe(Storage.PLUGIN_OBJECT, PreNetworkSyncEvent.class, event -> VelocityLoader.delayedPermissionsReload());
|
||||
}
|
||||
|
||||
Storage.getLoader().updateCommandCache();
|
||||
|
||||
}
|
||||
eventBus.subscribe(Storage.PLUGIN_OBJECT, PreNetworkSyncEvent.class, event -> Storage.getLoader().delayedPermissionsReload());
|
||||
}
|
||||
|
||||
|
||||
@@ -54,13 +44,6 @@ public class LuckPermsAdapter {
|
||||
return user.getCachedData().getPermissionData().getPermissionMap();
|
||||
}
|
||||
|
||||
public static boolean hasAnyPermissions(UUID uuid) {
|
||||
Map<String, Boolean> permissions = getPermissions(uuid);
|
||||
if (permissions == null) return false;
|
||||
|
||||
return !permissions.isEmpty();
|
||||
}
|
||||
|
||||
public static void setPermissions(UUID uuid) {
|
||||
Map<String, Boolean> permissions = getPermissions(uuid);
|
||||
if (permissions == null) return;
|
||||
@@ -104,15 +87,20 @@ public class LuckPermsAdapter {
|
||||
User user = (User) event.getTarget();
|
||||
UUID uuid = user.getUniqueId();
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
BukkitLoader.userPermissionsReload(user.getUniqueId());
|
||||
return;
|
||||
if (Reflection.isProxyServer()) {
|
||||
PermissionUtil.reloadPermissions(user.getUniqueId());
|
||||
Communicator.sendUpdateCommand(uuid);
|
||||
|
||||
if (Reflection.isVelocityServer()) {
|
||||
VelocityLoader.delayedPlayerReload(uuid);
|
||||
}
|
||||
|
||||
} else {
|
||||
PATScheduler.createScheduler(() -> {
|
||||
PermissionUtil.reloadPermissions(user.getUniqueId());
|
||||
});
|
||||
}
|
||||
|
||||
if (Reflection.isVelocityServer()) {
|
||||
PermissionUtil.reloadPermissions(user.getUniqueId());
|
||||
VelocityLoader.delayedPlayerReload(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.utils.adapter;
|
||||
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import com.viaversion.viaversion.api.*;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -9,8 +9,7 @@ public class ViaVersionAdapter {
|
||||
private static ViaAPI API;
|
||||
|
||||
public static void initialize() {
|
||||
Logger.info("Successfully hooked into ViaVersion for easier usage.");
|
||||
|
||||
Storage.USE_VIAVERSION = true;
|
||||
API = Via.getAPI();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,48 @@
|
||||
package de.rayzs.pat.utils.node;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
import com.mojang.brigadier.suggestion.SuggestionProvider;
|
||||
import com.mojang.brigadier.tree.*;
|
||||
import net.md_5.bungee.protocol.packet.Commands;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandNodeHelper<T> {
|
||||
|
||||
private static final Command DUMMY_COMMAND = (context) -> 0;
|
||||
private static SuggestionProvider DEFAULT_SUGGESTION_PROVIDER;
|
||||
|
||||
public static void setDefaultSuggestionProvider(SuggestionProvider<?> suggestionProvider) {
|
||||
DEFAULT_SUGGESTION_PROVIDER = suggestionProvider;
|
||||
}
|
||||
|
||||
public static CommandNode createDummyCommandNode(String command) {
|
||||
return LiteralArgumentBuilder
|
||||
.literal(command)
|
||||
.executes(DUMMY_COMMAND)
|
||||
.then(RequiredArgumentBuilder
|
||||
.argument("args", (ArgumentType) StringArgumentType.greedyString())
|
||||
.suggests(DEFAULT_SUGGESTION_PROVIDER)
|
||||
.executes(DUMMY_COMMAND))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandNode createEmptyDummyCommandNode(String command) {
|
||||
return LiteralArgumentBuilder
|
||||
.literal(command)
|
||||
.executes(DUMMY_COMMAND)
|
||||
.then(RequiredArgumentBuilder
|
||||
.argument("args", (ArgumentType) StringArgumentType.greedyString())
|
||||
.executes(DUMMY_COMMAND))
|
||||
.build();
|
||||
}
|
||||
|
||||
private final RootCommandNode<T> rootNode;
|
||||
|
||||
public CommandNodeHelper(RootCommandNode<T> rootNode) {
|
||||
@@ -76,27 +111,56 @@ public class CommandNodeHelper<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandNodeHelper<T> add(String commandPath) {
|
||||
if (commandPath.endsWith("_-"))
|
||||
commandPath = commandPath.substring(0, commandPath.length() - 3);
|
||||
|
||||
public CommandNodeHelper<T> add(String commandPath, boolean autoSuggestions) {
|
||||
String[] args = commandPath.split(" ");
|
||||
add(rootNode, args, 0);
|
||||
add(rootNode, args, 0, autoSuggestions);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void add(CommandNode<T> parent, String[] args, int index) {
|
||||
private void add(CommandNode<T> parent, String[] args, int index, boolean autoSuggestions) {
|
||||
if (index >= args.length) return;
|
||||
|
||||
String part = args[index];
|
||||
String next = index + 1 >= args.length ? null : args[index + 1];
|
||||
CommandNode<T> childNode = parent.getChild(part);
|
||||
|
||||
if (childNode == null) {
|
||||
LiteralCommandNode<T> newNode = LiteralArgumentBuilder.<T>literal(part).build();
|
||||
LiteralCommandNode newNode;
|
||||
|
||||
boolean cancel = next != null && (next.equals("_-"));
|
||||
boolean stop = next != null && next.startsWith("%") && next.endsWith("%");
|
||||
boolean skip = part.equals("-_");
|
||||
|
||||
if (index == 0 && part.charAt(0) == '!' && part.length() > 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skip) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!autoSuggestions || cancel || !stop && index != args.length - 1) {
|
||||
newNode = LiteralArgumentBuilder.literal(part)
|
||||
.then(RequiredArgumentBuilder
|
||||
.argument("args", StringArgumentType.string()))
|
||||
.build();
|
||||
} else {
|
||||
newNode = LiteralArgumentBuilder.literal(part)
|
||||
.then(RequiredArgumentBuilder
|
||||
.argument("args", (ArgumentType) StringArgumentType.greedyString())
|
||||
.suggests(Commands.SuggestionRegistry.ASK_SERVER))
|
||||
.build();
|
||||
}
|
||||
|
||||
parent.addChild(newNode);
|
||||
|
||||
if (stop || cancel) {
|
||||
return;
|
||||
}
|
||||
|
||||
childNode = newNode;
|
||||
}
|
||||
|
||||
add(childNode, args, index + 1);
|
||||
add(childNode, args, index + 1, autoSuggestions);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package de.rayzs.pat.utils.permission;
|
||||
|
||||
public enum PermissionPlugin {
|
||||
LUCKPERMS, GROUPMANAGER, NONE
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package de.rayzs.pat.utils.permission;
|
||||
import java.util.*;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.adapter.GroupManagerAdapter;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
@@ -39,10 +40,16 @@ public class PermissionUtil {
|
||||
}
|
||||
|
||||
public static String getPermissionsAsString(UUID uuid) {
|
||||
|
||||
if (Storage.getPermissionPlugin() == PermissionPlugin.NONE) {
|
||||
return "No permission plugin detected. Therefore, no permissions have been cached.";
|
||||
}
|
||||
|
||||
PermissionMap permissionMap = MAP.get(uuid);
|
||||
|
||||
if (permissionMap == null)
|
||||
if (permissionMap == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return Arrays.toString(permissionMap.getHashedPermissions().toArray()).replace("[", "").replace("]", "");
|
||||
}
|
||||
@@ -56,9 +63,9 @@ public class PermissionUtil {
|
||||
}
|
||||
|
||||
public static void setPlayerPermissions(CommandSender sender) {
|
||||
if (Storage.USE_LUCKPERMS) {
|
||||
if (Storage.getPermissionPlugin() == PermissionPlugin.LUCKPERMS) {
|
||||
LuckPermsAdapter.setPermissions(sender.getUniqueId());
|
||||
} else if (Storage.USE_GROUPMANAGER) {
|
||||
} else if (Storage.getPermissionPlugin() == PermissionPlugin.GROUPMANAGER) {
|
||||
GroupManagerAdapter.setPermissions(sender.getUniqueId());
|
||||
} else {
|
||||
GroupManager.getGroups().forEach(group -> group.hasPermission(sender));
|
||||
@@ -66,9 +73,9 @@ public class PermissionUtil {
|
||||
}
|
||||
|
||||
public static void setPlayerPermissions(UUID uuid) {
|
||||
if (Storage.USE_LUCKPERMS) {
|
||||
if (Storage.getPermissionPlugin() == PermissionPlugin.LUCKPERMS) {
|
||||
LuckPermsAdapter.setPermissions(uuid);
|
||||
} else if (Storage.USE_GROUPMANAGER) {
|
||||
} else if (Storage.getPermissionPlugin() == PermissionPlugin.GROUPMANAGER) {
|
||||
GroupManagerAdapter.setPermissions(uuid);
|
||||
} else {
|
||||
GroupManager.getGroups().forEach(group -> group.hasPermission(uuid));
|
||||
@@ -106,6 +113,29 @@ public class PermissionUtil {
|
||||
else
|
||||
sender = CommandSenderHandler.from(targetObj);
|
||||
|
||||
// No permission plugin found!
|
||||
if (Storage.getPermissionPlugin() == PermissionPlugin.NONE) {
|
||||
|
||||
if (sender == null) {
|
||||
try {
|
||||
throw new Exception("Unknown sender!");
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender.isConsole()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return sender.isOperator()
|
||||
|| sender.hasPermission("*")
|
||||
|| sender.hasPermission("proantitab.*")
|
||||
|| sender.hasPermission("proantitab." + permission);
|
||||
}
|
||||
|
||||
if (uuid == null) {
|
||||
if (sender == null || sender.isConsole())
|
||||
return true;
|
||||
@@ -113,16 +143,16 @@ public class PermissionUtil {
|
||||
uuid = sender.getUniqueId();
|
||||
}
|
||||
|
||||
if (!MAP.containsKey(uuid)) {
|
||||
MAP.put(uuid, new PermissionMap(uuid));
|
||||
return false;
|
||||
}
|
||||
|
||||
permissionMap = MAP.get(uuid);
|
||||
|
||||
if (permissionMap == null) {
|
||||
permissionMap = new PermissionMap(uuid);
|
||||
MAP.put(uuid, permissionMap);
|
||||
}
|
||||
|
||||
if (sender != null) {
|
||||
|
||||
if (!Storage.USE_LUCKPERMS) {
|
||||
if (Storage.getPermissionPlugin() != PermissionPlugin.LUCKPERMS) {
|
||||
|
||||
if (!permissionMap.hasPermissionState("*"))
|
||||
permissionMap.setState("*", sender.hasPermission("*"));
|
||||
@@ -135,29 +165,48 @@ public class PermissionUtil {
|
||||
|
||||
}
|
||||
|
||||
if (sender.isOperator() && !Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
if (sender.isOperator()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return permissionMap.isPermitted("*") || permissionMap.isPermitted("proantitab.*") || permissionMap.isPermitted("proantitab." + permission);
|
||||
}
|
||||
|
||||
public static boolean hasBypassPermission(Object targetObj) {
|
||||
|
||||
if (!Reflection.isProxyServer() && Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return hasPermission(targetObj, "bypass");
|
||||
}
|
||||
|
||||
public static boolean hasBypassPermission(Object targetObj, String command) {
|
||||
return hasBypassPermission(targetObj) || hasPermission(targetObj, "bypass." + command);
|
||||
|
||||
if (!Reflection.isProxyServer() && Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hasBypassPermission(targetObj)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Storage.getPermissionPlugin() == PermissionPlugin.NONE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return hasPermission(targetObj, "bypass." + command);
|
||||
}
|
||||
|
||||
public static boolean hasPermissionWithResponse(Object targetObj, String command) {
|
||||
boolean permitted = hasPermission(targetObj, command);
|
||||
|
||||
if (!permitted && targetObj instanceof CommandSender) {
|
||||
((CommandSender) targetObj).sendMessage(
|
||||
Storage.ConfigSections.Messages.NO_PERMISSION.MESSAGE
|
||||
.replace("%permission%", "proantitab." + command)
|
||||
);
|
||||
String message = Storage.ConfigSections.Messages.NO_PERMISSION.MESSAGE;
|
||||
message = message.replace("%permission%", "proantitab." + command);
|
||||
|
||||
((CommandSender) targetObj).sendMessage(message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,50 +25,56 @@ public class ResponseHandler {
|
||||
}
|
||||
|
||||
public static String replaceArgsVariables(String input, String command) {
|
||||
if (!input.contains(" "))
|
||||
return input;
|
||||
final String[] commandSplit = command.contains(" ") ? command.split(" ") : new String[] { command };
|
||||
final String[] inputSplit = input.contains(" ") ? input.split(" ") : new String[] { input };
|
||||
|
||||
String[] commandSplit = command.contains(" ") ? command.split(" ") : new String[]{command};
|
||||
String[] split = input.split(" ");
|
||||
final StringBuilder output = new StringBuilder();
|
||||
final int commandLength = commandSplit.length;
|
||||
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
String part = split[i];
|
||||
for (int i = 0; i < inputSplit.length; i++) {
|
||||
String part = inputSplit[i];
|
||||
|
||||
if (! (part.startsWith("%args[") && part.endsWith("]%")))
|
||||
if (i > 0) {
|
||||
output.append(" ");
|
||||
}
|
||||
|
||||
if (! (part.startsWith("%args[") && part.endsWith("]%"))) {
|
||||
output.append(part);
|
||||
continue;
|
||||
}
|
||||
|
||||
part = part.substring(part.indexOf('[') + 1, part.lastIndexOf(']'));
|
||||
|
||||
int length = commandSplit.length, fromIndex, toIndex;
|
||||
int fromIndex, toIndex;
|
||||
|
||||
if (part.contains("-")) {
|
||||
String[] indexSplit = part.split("-");
|
||||
try {
|
||||
if (part.contains("-")) {
|
||||
final String[] partSplit = part.split("-");
|
||||
fromIndex = Integer.parseInt(partSplit[0]);
|
||||
toIndex = Integer.parseInt(partSplit[1]);
|
||||
} else if (part.startsWith("_")) {
|
||||
final String[] partSplit = part.split("_");
|
||||
fromIndex = 0;
|
||||
toIndex = Integer.parseInt(partSplit[1]);
|
||||
} else if (part.endsWith("_")) {
|
||||
final String[] partSplit = part.split("_");
|
||||
fromIndex = Integer.parseInt(partSplit[0]);
|
||||
toIndex = commandLength + 1;
|
||||
} else {
|
||||
fromIndex = Integer.parseInt(part);
|
||||
toIndex = fromIndex;
|
||||
}
|
||||
|
||||
fromIndex = Integer.parseInt(indexSplit[0]) - 1;
|
||||
toIndex = Integer.parseInt(indexSplit[1]);
|
||||
} else {
|
||||
fromIndex = Integer.parseInt(part);
|
||||
toIndex = fromIndex;
|
||||
fromIndex = Math.max(0, fromIndex - 1);
|
||||
toIndex = Math.min(commandLength, toIndex);
|
||||
|
||||
output.append(String.join(" ", Arrays.copyOfRange(commandSplit, fromIndex, toIndex)));
|
||||
} catch (NumberFormatException exception) {
|
||||
Logger.warning("Failed to convert number! (" + part + ")");
|
||||
}
|
||||
|
||||
if (fromIndex < 0 || toIndex > length) {
|
||||
Logger.warning("Custom response contains an error! (" + input + ")");
|
||||
Logger.warning("Out of bounds! (Input: " + input + ", Possible: " + (length > 1 ? "1-" : "") + length + ")");
|
||||
continue;
|
||||
}
|
||||
|
||||
String replacement;
|
||||
|
||||
if (fromIndex == toIndex) {
|
||||
replacement = commandSplit[fromIndex - 1];
|
||||
} else {
|
||||
replacement = String.join(" ", Arrays.copyOfRange(commandSplit, fromIndex, toIndex));;
|
||||
}
|
||||
|
||||
split[i] = replacement;
|
||||
}
|
||||
|
||||
return String.join(" ", split);
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
public static List<String> getResponse(UUID uuid, String input) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.UUID;
|
||||
|
||||
public interface CommandSender {
|
||||
|
||||
void updateSenderObject(Object senderObj);
|
||||
Object getSenderObject();
|
||||
|
||||
boolean isConsole();
|
||||
|
||||
@@ -11,13 +11,18 @@ public abstract class CommandSenderAbstract implements CommandSender {
|
||||
|
||||
private static final byte KEY = (byte) 0;
|
||||
|
||||
private final Object senderObj;
|
||||
private final ExpireCache<Byte, List<Group>> groups = new ExpireCache<>(1, TimeUnit.HOURS);
|
||||
private Object senderObj;
|
||||
|
||||
public CommandSenderAbstract(Object senderObj) {
|
||||
this.senderObj = senderObj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSenderObject(Object senderObj) {
|
||||
this.senderObj = senderObj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSenderObject() {
|
||||
return senderObj;
|
||||
@@ -28,7 +33,7 @@ public abstract class CommandSenderAbstract implements CommandSender {
|
||||
final List<Group> groupList = groups.get(KEY);
|
||||
|
||||
if (groupList == null) {
|
||||
return groups.putAndGet(KEY, GroupManager.getPlayerGroups(getUniqueId()));
|
||||
return groups.putAndGet(KEY, GroupManager.getPlayerGroups(getSenderObject()));
|
||||
}
|
||||
|
||||
return groupList;
|
||||
|
||||
@@ -12,11 +12,12 @@ import java.util.UUID;
|
||||
|
||||
public class BukkitSender extends CommandSenderAbstract {
|
||||
|
||||
private final CommandSender sender;
|
||||
private final UUID uuid;
|
||||
private final String name;
|
||||
private final boolean console;
|
||||
|
||||
private CommandSender sender;
|
||||
|
||||
public BukkitSender(Object senderObj) {
|
||||
super(senderObj);
|
||||
|
||||
@@ -27,7 +28,7 @@ public class BukkitSender extends CommandSenderAbstract {
|
||||
this.uuid = player.getUniqueId();
|
||||
this.console = false;
|
||||
|
||||
updateGroups();
|
||||
//updateGroups();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -44,6 +45,17 @@ public class BukkitSender extends CommandSenderAbstract {
|
||||
this.console = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSenderObject(Object senderObj) {
|
||||
super.updateSenderObject(senderObj);
|
||||
|
||||
if (senderObj instanceof Player player) {
|
||||
this.sender = player;
|
||||
} else if (senderObj instanceof CommandSender commandSender) {
|
||||
this.sender = commandSender;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConsole() {
|
||||
return this.console;
|
||||
@@ -91,6 +103,6 @@ public class BukkitSender extends CommandSenderAbstract {
|
||||
|
||||
@Override
|
||||
public void updateGroups() {
|
||||
setGroups(GroupManager.getPlayerGroups(this.uuid));
|
||||
setGroups(GroupManager.getPlayerGroups(getSenderObject()));
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,11 @@ import java.util.UUID;
|
||||
|
||||
public class BungeeSender extends CommandSenderAbstract {
|
||||
|
||||
private final CommandSender sender;
|
||||
private final UUID uuid;
|
||||
private final String name;
|
||||
|
||||
private CommandSender sender;
|
||||
|
||||
private final boolean console;
|
||||
|
||||
public BungeeSender(Object senderObj) {
|
||||
@@ -27,8 +28,6 @@ public class BungeeSender extends CommandSenderAbstract {
|
||||
this.name = player.getName();
|
||||
this.uuid = player.getUniqueId();
|
||||
this.console = false;
|
||||
|
||||
updateGroups();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -45,6 +44,17 @@ public class BungeeSender extends CommandSenderAbstract {
|
||||
this.console = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSenderObject(Object senderObj) {
|
||||
super.updateSenderObject(senderObj);
|
||||
|
||||
if (senderObj instanceof ProxiedPlayer player) {
|
||||
sender = player;
|
||||
} else if (senderObj instanceof CommandSender commandSender) {
|
||||
sender = commandSender;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConsole() {
|
||||
return this.console;
|
||||
@@ -94,6 +104,6 @@ public class BungeeSender extends CommandSenderAbstract {
|
||||
|
||||
@Override
|
||||
public void updateGroups() {
|
||||
setGroups(GroupManager.getPlayerGroups(this.uuid));
|
||||
setGroups(GroupManager.getPlayerGroups(getSenderObject()));
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,12 @@ import java.util.UUID;
|
||||
|
||||
public class VelocitySender extends CommandSenderAbstract {
|
||||
|
||||
private final CommandSource sender;
|
||||
private final boolean console;
|
||||
|
||||
private final UUID uuid;
|
||||
private final String name;
|
||||
|
||||
private final boolean console;
|
||||
private CommandSource sender;
|
||||
|
||||
public VelocitySender(Object senderObj) {
|
||||
super(senderObj);
|
||||
@@ -27,8 +28,6 @@ public class VelocitySender extends CommandSenderAbstract {
|
||||
this.name = player.getUsername();
|
||||
this.uuid = player.getUniqueId();
|
||||
this.console = false;
|
||||
|
||||
updateGroups();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -45,6 +44,17 @@ public class VelocitySender extends CommandSenderAbstract {
|
||||
this.console = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSenderObject(Object senderObj) {
|
||||
super.updateSenderObject(senderObj);
|
||||
|
||||
if (senderObj instanceof Player player) {
|
||||
sender = player;
|
||||
} else if (senderObj instanceof CommandSource commandSource) {
|
||||
sender = commandSource;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConsole() {
|
||||
return this.console;
|
||||
@@ -89,6 +99,6 @@ public class VelocitySender extends CommandSenderAbstract {
|
||||
|
||||
@Override
|
||||
public void updateGroups() {
|
||||
setGroups(GroupManager.getPlayerGroups(this.uuid));
|
||||
setGroups(GroupManager.getPlayerGroups(getSenderObject()));
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ description: Hide more than just your plugins. Hide almost everything!
|
||||
website: https://www.rayzs.de/products/proantitab/page
|
||||
|
||||
author: Rayzs_YT
|
||||
version: 2.0.19
|
||||
version: 2.1.0
|
||||
main: de.rayzs.pat.plugin.BungeeLoader
|
||||
|
||||
softDepends: [LuckPerms, PAPIProxyBridge]
|
||||
@@ -66,15 +66,15 @@ base-command-case-sensitive: true
|
||||
|
||||
# (!) Warning:
|
||||
# Enabling this could lead to performance issues if many players
|
||||
# change worlds frequently in short amount of time.
|
||||
# change worlds frequently in a short amount of time.
|
||||
#
|
||||
# This decides whether PAT updates the commands for a player after changing worlds.
|
||||
# This decides whether PAT updates the commands for a player after switching worlds.
|
||||
# Enabling this allows you to make per-world commands using PAT's group system by
|
||||
# giving a user/group the PAT group permission using a LuckPerms world as context.
|
||||
#
|
||||
# Example command:
|
||||
# lp (...) permission set proantitab.group.<group> world=<world>
|
||||
update-commands-per-world: false
|
||||
update-groups-per-world: false
|
||||
|
||||
# Here you can customize the server version that is displayed on a ping. (The text at the player-count)
|
||||
# (!) Warning: It's required to use Paper or Purpur to use this feature!
|
||||
|
||||
@@ -35,11 +35,21 @@
|
||||
# Possible variable:
|
||||
# %args[from-to]% to get the command arguments
|
||||
# Example if you've typed: /shop open gui user
|
||||
# A:
|
||||
# %args[1]% = shop
|
||||
# %args[2]% = open
|
||||
# A-B:
|
||||
# %args[1-2]% = shop open
|
||||
# %args[1-3]% = shop open gui
|
||||
# %args[2-4]% = open gui user
|
||||
# A_:
|
||||
# %args[1_]% = shop open gui user
|
||||
# %args[2_]% = open gui user
|
||||
# %args[3_]% = gui user
|
||||
# _B:
|
||||
# %args[_1]% = shop
|
||||
# %args[_2]% = shop open
|
||||
# %args[_3]% = shop open gui
|
||||
|
||||
# Here are a few examples:
|
||||
|
||||
|
||||
@@ -29,11 +29,21 @@
|
||||
# Possible variable:
|
||||
# %args[from-to]% to get the command arguments
|
||||
# Example if you've typed: /shop open gui user
|
||||
# A:
|
||||
# %args[1]% = shop
|
||||
# %args[2]% = open
|
||||
# A-B:
|
||||
# %args[1-2]% = shop open
|
||||
# %args[1-3]% = shop open gui
|
||||
# %args[2-4]% = open gui user
|
||||
# A_:
|
||||
# %args[1_]% = shop open gui user
|
||||
# %args[2_]% = open gui user
|
||||
# %args[3_]% = gui user
|
||||
# _B:
|
||||
# %args[_1]% = shop
|
||||
# %args[_2]% = shop open
|
||||
# %args[_3]% = shop open gui
|
||||
|
||||
# Here are a few examples:
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ description: Hide more than just your plugins. Hide almost everything!
|
||||
website: https://www.rayzs.de/products/proantitab/page
|
||||
|
||||
author: Rayzs_YT
|
||||
version: 2.0.19
|
||||
version: 2.1.0
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
main: de.rayzs.pat.plugin.BukkitLoader
|
||||
|
||||
Reference in new issue
Block a user