mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-14 13:02:07 -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 |
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.21</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()));
|
||||
}
|
||||
|
||||
@@ -139,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();
|
||||
|
||||
@@ -156,16 +159,15 @@ public class BungeePacketAnalyzer {
|
||||
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
|
||||
boolean bypassPermissions = PermissionUtil.hasBypassPermission(player.getUniqueId());
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, serverName);
|
||||
|
||||
helper.removeIf(str -> !playerCommands.contains(str));
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.ALWAYS_TAB_COMPLETABLE && !bypassPermissions) {
|
||||
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 && !bypassPermissions) {
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
|
||||
|
||||
@@ -268,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
|
||||
|
||||
@@ -9,6 +9,7 @@ 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;
|
||||
@@ -71,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();
|
||||
@@ -239,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;
|
||||
}
|
||||
@@ -308,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() {}
|
||||
@@ -534,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();
|
||||
|
||||
@@ -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.21",
|
||||
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;
|
||||
@@ -23,16 +25,13 @@ public class BukkitAntiTabListener implements Listener {
|
||||
final Player player = event.getPlayer();
|
||||
final UUID uuid = player.getUniqueId();
|
||||
|
||||
final boolean noPermissionsPlugin = !Storage.USE_LUCKPERMS && !Storage.USE_GROUPMANAGER;
|
||||
|
||||
|
||||
if (Storage.USE_VELOCITY) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.isOp()) {
|
||||
|
||||
if (noPermissionsPlugin && !knownOperators.contains(uuid)) {
|
||||
if (!knownOperators.contains(uuid)) {
|
||||
knownOperators.add(uuid);
|
||||
}
|
||||
|
||||
@@ -44,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;
|
||||
@@ -54,19 +54,19 @@ public class BukkitAntiTabListener implements Listener {
|
||||
List<String> allCommands = getCommands();
|
||||
COMMANDS_CACHE.handleCommands(allCommands);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player)) {
|
||||
|
||||
if (noPermissionsPlugin && knownOperators.contains(uuid)) {
|
||||
PermissionUtil.reloadPermissions(uuid);
|
||||
knownOperators.remove(uuid);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (!player.isOp() && knownOperators.contains(uuid)) {
|
||||
knownOperators.remove(uuid);
|
||||
|
||||
CommandSender sender = CommandSenderHandler.getSenderFromUUID(uuid);
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
}
|
||||
|
||||
final List<String> playerCommands = COMMANDS_CACHE.getPlayerCommands(new ArrayList<>(event.getCommands()), player, player.getUniqueId());
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, playerCommands);
|
||||
if (PermissionUtil.hasBypassPermission(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<String> playerCommands = COMMANDS_CACHE.getPlayerCommands(new ArrayList<>(event.getCommands()), player);
|
||||
final FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, playerCommands);
|
||||
|
||||
event.getCommands().clear();
|
||||
|
||||
@@ -116,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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
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();
|
||||
@@ -41,9 +41,7 @@ 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, player.getUniqueId(), serverName);
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, serverName);
|
||||
event.getCommands().entrySet().removeIf(command -> {
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command.getKey()) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command.getKey())) {
|
||||
|
||||
@@ -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))
|
||||
@@ -57,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();
|
||||
@@ -71,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
|
||||
@@ -102,7 +107,7 @@ public class VelocityAntiTabListener {
|
||||
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,12 +106,12 @@ 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.USE_GROUPMANAGER)
|
||||
.append(Storage.getPermissionPlugin() == PermissionPlugin.GROUPMANAGER)
|
||||
.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.*;
|
||||
@@ -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) {
|
||||
Logger.warning("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();
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,10 @@ public class CommandNodeHelper<T> {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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.21
|
||||
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!
|
||||
|
||||
@@ -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.21
|
||||
version: 2.1.0
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
main: de.rayzs.pat.plugin.BukkitLoader
|
||||
|
||||
Reference in new issue
Block a user