mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-13 12:41:58 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fc23712e4 | ||
|
|
6b9c717ec4 | ||
|
|
0c3e82c01e | ||
|
|
8e6e544b60 | ||
|
|
a4196fc118 | ||
|
|
d5a9b99a7a | ||
|
|
6d850f9f07 | ||
|
|
c4987b7c5e | ||
|
|
3880738ed9 | ||
|
|
68c00b843b | ||
|
|
dc352275b6 | ||
|
|
b3362987e5 | ||
|
|
fb3ec45059 | ||
|
|
5100b4a852 | ||
|
|
e9ec801dc5 | ||
|
|
70c31b8597 | ||
|
|
a078de1fc3 | ||
|
|
a1d759451c | ||
|
|
8a9373963c | ||
|
|
d964d5b859 | ||
|
|
b468865041 | ||
|
|
d6fec721ad | ||
|
|
9256398fa2 | ||
|
|
4fed08a8f9 | ||
|
|
b650156e57 | ||
|
|
4737d15be5 | ||
|
|
aca6dd7e1d | ||
|
|
5aa0d000dd | ||
|
|
e2b238fb81 | ||
|
|
ebdb3edbc1 | ||
|
|
b9f4e46d65 | ||
|
|
287ebd4e9c | ||
|
|
befdc3de6a | ||
|
|
55d00876a7 | ||
|
|
be0ee15448 | ||
|
|
7f91b85d6e | ||
|
|
80beacaef9 | ||
|
|
9f0521f9de | ||
|
|
3e1fffcfbb | ||
|
|
c0e77efad6 | ||
|
|
490f6f420b | ||
|
|
228185291d | ||
|
|
ab17861e7c | ||
|
|
567ca5192c | ||
|
|
442a0797a2 | ||
|
|
c1be977abd | ||
|
|
a6f670dcfb | ||
|
|
1d3e72aae2 | ||
|
|
513fce2059 | ||
|
|
6247aee871 | ||
|
|
fc0e230ca5 | ||
|
|
d2972f602f | ||
|
|
0f3b858a75 | ||
|
|
70b449e83d | ||
|
|
2a58b6644e | ||
|
|
96f4386f7a | ||
|
|
3e9de4e859 | ||
|
|
dad2db500c | ||
|
|
9bd33477b1 | ||
|
|
01c680b69a | ||
|
|
d20c3c2820 | ||
|
|
dcb73b1672 | ||
|
|
389f006d02 | ||
|
|
0266a6c5f9 | ||
|
|
9b53123e92 | ||
|
|
9e21110011 | ||
|
|
5377c67614 | ||
|
|
32f8c61d43 | ||
|
|
2a16db32ba | ||
|
|
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 |
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.20</version>
|
||||
<version>2.2.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
@@ -291,6 +291,16 @@
|
||||
|
||||
<build>
|
||||
<finalName>IgnoreThisJar</finalName>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<excludes>
|
||||
<exclude>*.txt</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class BukkitPacketAnalyzer {
|
||||
}
|
||||
|
||||
public static boolean inject(Player player) {
|
||||
if (Storage.USE_VELOCITY)
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
return true;
|
||||
|
||||
try {
|
||||
@@ -81,7 +81,7 @@ public class BukkitPacketAnalyzer {
|
||||
}
|
||||
|
||||
public static void uninject(UUID uuid) {
|
||||
if (Storage.USE_VELOCITY)
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
return;
|
||||
|
||||
if (BukkitPacketAnalyzer.INJECTED_PLAYERS.containsKey(uuid)) {
|
||||
@@ -91,7 +91,7 @@ public class BukkitPacketAnalyzer {
|
||||
}
|
||||
|
||||
public static void uninject(Channel channel) {
|
||||
if (Storage.USE_VELOCITY)
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
return;
|
||||
|
||||
if (channel != null) {
|
||||
@@ -124,22 +124,25 @@ public class BukkitPacketAnalyzer {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext channel, Object packetObj) {
|
||||
try {
|
||||
if (packetObj.getClass() != null) {
|
||||
String packetName = packetObj.getClass().getSimpleName();
|
||||
|
||||
if (!packetName.equals("PacketPlayInTabComplete") && !packetName.equals("ServerboundCommandSuggestionPacket")) {
|
||||
super.channelRead(channel, packetObj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
|
||||
if (!PACKET_HANDLER.handleIncomingPacket(player, packetObj))
|
||||
return;
|
||||
|
||||
}
|
||||
if (packetObj.getClass() == null || Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
super.channelRead(channel, packetObj);
|
||||
return;
|
||||
}
|
||||
|
||||
String packetName = packetObj.getClass().getSimpleName();
|
||||
|
||||
if (!packetName.equals("PacketPlayInTabComplete") && !packetName.equals("ServerboundCommandSuggestionPacket")) {
|
||||
super.channelRead(channel, packetObj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
|
||||
if (!PACKET_HANDLER.handleIncomingPacket(player, packetObj))
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
super.channelRead(channel, packetObj);
|
||||
} catch (Throwable exception) { exception.printStackTrace(); }
|
||||
}
|
||||
@@ -148,30 +151,33 @@ public class BukkitPacketAnalyzer {
|
||||
public void write(ChannelHandlerContext channel, Object packetObj, ChannelPromise promise) {
|
||||
try {
|
||||
|
||||
if(packetObj.getClass() != null) {
|
||||
String packetName = packetObj.getClass().getSimpleName();
|
||||
if(packetObj.getClass() == null || Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
super.write(channel, packetObj, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!packetName.equals("PacketPlayOutTabComplete") && !packetName.equals("ClientboundCommandSuggestionsPacket")) {
|
||||
super.write(channel, packetObj, promise);
|
||||
return;
|
||||
}
|
||||
String packetName = packetObj.getClass().getSimpleName();
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
if (!packetName.equals("PacketPlayOutTabComplete") && !packetName.equals("ClientboundCommandSuggestionsPacket")) {
|
||||
super.write(channel, packetObj, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
Object sentPacketObj = SENT_PACKET.get(uuid);
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
|
||||
if (sentPacketObj != null) {
|
||||
if (sentPacketObj == packetObj) {
|
||||
SENT_PACKET.remove(uuid);
|
||||
super.write(channel, sentPacketObj, promise);
|
||||
return;
|
||||
}
|
||||
}
|
||||
UUID uuid = player.getUniqueId();
|
||||
Object sentPacketObj = SENT_PACKET.get(uuid);
|
||||
|
||||
if (!PACKET_HANDLER.handleOutgoingPacket(player, packetObj))
|
||||
if (sentPacketObj != null) {
|
||||
if (sentPacketObj == packetObj) {
|
||||
SENT_PACKET.remove(uuid);
|
||||
super.write(channel, sentPacketObj, promise);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!PACKET_HANDLER.handleOutgoingPacket(player, packetObj))
|
||||
return;
|
||||
}
|
||||
|
||||
super.write(channel, packetObj, promise);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
}
|
||||
|
||||
if (!cancelsBeforeHand) {
|
||||
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(input) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(input);
|
||||
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(input) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input);
|
||||
}
|
||||
|
||||
for (Field field : Reflection.getFields(packetObj)) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package de.rayzs.pat.api.netty.proxy;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
@@ -10,12 +11,15 @@ 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.ExpireCache;
|
||||
import de.rayzs.pat.utils.node.CommandNodeHelper;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
@@ -31,6 +35,7 @@ import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import net.md_5.bungee.protocol.packet.Commands;
|
||||
import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
||||
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||
|
||||
public class BungeePacketAnalyzer {
|
||||
@@ -39,9 +44,7 @@ public class BungeePacketAnalyzer {
|
||||
|
||||
private static final String HANDLER_NAME = "pat-bungee-handler", PIPELINE_NAME = "packet-decoder";
|
||||
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 ExpireCache<UUID, String> PLAYER_INPUT_CACHE = new ExpireCache<>(5, TimeUnit.SECONDS);
|
||||
|
||||
private static final List<String> PLUGIN_COMMANDS = new ArrayList<>();
|
||||
|
||||
@@ -50,6 +53,7 @@ public class BungeePacketAnalyzer {
|
||||
private static List<String> PROXY_COMMANDS;
|
||||
|
||||
static {
|
||||
CommandNodeHelper.setDefaultSuggestionProvider(Commands.SuggestionRegistry.ASK_SERVER);
|
||||
loadProxyCommands();
|
||||
}
|
||||
|
||||
@@ -114,7 +118,7 @@ public class BungeePacketAnalyzer {
|
||||
}
|
||||
|
||||
public static void uninject(ProxiedPlayer player) {
|
||||
BungeePacketAnalyzer.PLAYER_INPUT_CACHE.remove(player);
|
||||
BungeePacketAnalyzer.PLAYER_INPUT_CACHE.remove(player.getUniqueId());
|
||||
BungeePacketAnalyzer.PLAYER_MODIFIED.remove(player);
|
||||
|
||||
if(BungeePacketAnalyzer.INJECTED_PLAYERS.containsKey(player)) {
|
||||
@@ -131,9 +135,13 @@ public class BungeePacketAnalyzer {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setPlayerInput(ProxiedPlayer player, String input) {
|
||||
PLAYER_INPUT_CACHE.putIgnoreIfContains(player.getUniqueId(), input);
|
||||
}
|
||||
|
||||
public static String getPlayerInput(ProxiedPlayer player) {
|
||||
String input = PLAYER_INPUT_CACHE.get(player);
|
||||
PLAYER_INPUT_CACHE.remove(player);
|
||||
String input = PLAYER_INPUT_CACHE.get(player.getUniqueId());
|
||||
PLAYER_INPUT_CACHE.remove(player.getUniqueId());
|
||||
return input;
|
||||
}
|
||||
|
||||
@@ -141,23 +149,38 @@ public class BungeePacketAnalyzer {
|
||||
ServerInfo serverInfo = player.getServer().getInfo();
|
||||
String serverName = serverInfo.getName();
|
||||
|
||||
final boolean ignore = PermissionUtil.hasBypassPermission(player) || Storage.Blacklist.isDisabledServer(serverName);
|
||||
|
||||
CommandNodeHelper helper = new CommandNodeHelper<CommandNode>(commands.getRoot());
|
||||
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
|
||||
if (!cache.containsKey(serverName))
|
||||
cache.put(serverName, new CommandsCache());
|
||||
|
||||
CommandsCache commandsCache = cache.get(serverName);
|
||||
|
||||
List<String> commandsAsString = new ArrayList<>(PROXY_COMMANDS);
|
||||
commandsAsString.addAll(helper.getChildrenNames());
|
||||
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
List<String> playerCommands = new ArrayList<>();
|
||||
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
|
||||
if (!ignore) {
|
||||
|
||||
helper.removeIf(str -> !playerCommands.contains(str));
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
if (!cache.containsKey(serverName)) {
|
||||
cache.put(serverName, new CommandsCache());
|
||||
}
|
||||
|
||||
CommandsCache commandsCache = cache.get(serverName);
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
List<String> tmpPlayerCommands = commandsCache.getPlayerCommands(commandsAsString, player, serverName);
|
||||
helper.removeIf(str -> !tmpPlayerCommands.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));
|
||||
}
|
||||
|
||||
playerCommands = tmpPlayerCommands;
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Command> command : ProxyServer.getInstance().getPluginManager().getCommands()) {
|
||||
|
||||
@@ -174,28 +197,42 @@ public class BungeePacketAnalyzer {
|
||||
String commandName = command.getKey();
|
||||
commandName = commandName.startsWith("/") ? commandName.substring(1) : commandName;
|
||||
|
||||
if (!playerCommands.contains(commandName)) {
|
||||
continue;
|
||||
if (!ignore) {
|
||||
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);
|
||||
|
||||
for (String command : PROXY_COMMANDS) {
|
||||
if (ignore || playerCommands.contains(command)) {
|
||||
helper.add(command, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ignore) {
|
||||
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()) {
|
||||
if (player.getPendingConnection().getVersion() < 754)
|
||||
continue;
|
||||
|
||||
RootCommandNode root = new RootCommandNode();
|
||||
Commands packet = new Commands(root);
|
||||
|
||||
modifyCommands(player, packet);
|
||||
player.unsafe().sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
private static class PacketDecoder extends MessageToMessageDecoder<PacketWrapper> {
|
||||
@@ -213,7 +250,7 @@ public class BungeePacketAnalyzer {
|
||||
return;
|
||||
}
|
||||
|
||||
if(wrapper.packet instanceof PluginMessage) {
|
||||
if (wrapper.packet instanceof PluginMessage) {
|
||||
PluginMessage pluginMessage = (PluginMessage) wrapper.packet;
|
||||
if(CustomServerBrand.isEnabled() && CustomServerBrand.isBrandTag(pluginMessage.getTag()))
|
||||
return;
|
||||
@@ -225,29 +262,37 @@ public class BungeePacketAnalyzer {
|
||||
player.unsafe().sendPacket(response);
|
||||
return;
|
||||
|
||||
/*
|
||||
} else if (wrapper.packet instanceof TabCompleteResponse) {
|
||||
TabCompleteResponse response = (TabCompleteResponse) wrapper.packet;
|
||||
String serverName = player.getServer().getInfo().getName();
|
||||
|
||||
if(player.getPendingConnection().getVersion() < 754) {
|
||||
if(!PermissionUtil.hasBypassPermission(player)) {
|
||||
System.out.println("damn");
|
||||
|
||||
ClientInfo clientInfo = Communicator.getClientByName(player.getServer().getInfo().getName());
|
||||
if (clientInfo == null || !PLAYER_INPUT_CACHE.containsKey(player))
|
||||
if (!Storage.Blacklist.isDisabledServer(serverName) && player.getPendingConnection().getVersion() < 754) {
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
|
||||
System.out.println("Further!");
|
||||
System.out.println("Got: " + PLAYER_INPUT_CACHE.get(player.getUniqueId()));
|
||||
|
||||
if (!PLAYER_INPUT_CACHE.contains(player.getUniqueId()))
|
||||
return;
|
||||
|
||||
boolean cancelsBeforeHand = false;
|
||||
|
||||
String rawPlayerInput = getPlayerInput(player);
|
||||
String rawPlayerInput = PLAYER_INPUT_CACHE.get(player.getUniqueId());
|
||||
int spaces = rawPlayerInput.contains(" ") ? rawPlayerInput.split(" ").length : 0;
|
||||
|
||||
String playerInput = StringUtils.getFirstArg(rawPlayerInput),
|
||||
server = player.getServer().getInfo().getName();
|
||||
|
||||
System.out.println("NETTY -> " + playerInput);
|
||||
|
||||
if (!playerInput.equals("/")) {
|
||||
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;
|
||||
@@ -300,7 +345,7 @@ public class BungeePacketAnalyzer {
|
||||
player.unsafe().sendPacket(new TabCompleteResponse(response.getCommands()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
list.add(wrapper);
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package de.rayzs.pat.api.netty.proxy;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
@@ -73,20 +70,27 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
channel = (Channel) Reflection.getMethodsByName(minecraftConnectionClass, "getChannel").get(0).invoke(minecraftConnectionObj);
|
||||
|
||||
if(channel == null) {
|
||||
if (channel == null) {
|
||||
Logger.warning("Failed to inject " + player.getUsername() + "! Channel is null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(channel.pipeline().names().contains(VelocityPacketAnalyzer.PIPELINE_NAME))
|
||||
if (channel.pipeline().names().contains(VelocityPacketAnalyzer.PIPELINE_NAME))
|
||||
uninject(player);
|
||||
|
||||
channel.pipeline().addBefore(VelocityPacketAnalyzer.HANDLER_NAME, VelocityPacketAnalyzer.PIPELINE_NAME, new PacketDecoder(player));
|
||||
VelocityPacketAnalyzer.INJECTED_PLAYERS.put(player, channel);
|
||||
|
||||
} catch (NoSuchElementException e) {
|
||||
Logger.warning("Failed to find 'handler' inside player pipeline! (name=" + player.getUsername() + ", uuid=" + player.getUniqueId() + ", version=" + player.getProtocolVersion() + ", brand=" + player.getClientBrand() + " )");
|
||||
return false;
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
return false;
|
||||
} return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void uninject(Player player) {
|
||||
@@ -190,6 +194,13 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
} else if (packet instanceof TabCompleteResponsePacket) {
|
||||
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName)) {
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player) && player.getCurrentServer().isPresent()) {
|
||||
TabCompleteResponsePacket response = (TabCompleteResponsePacket) packet;
|
||||
|
||||
@@ -222,6 +233,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 +252,7 @@ public class VelocityPacketAnalyzer {
|
||||
}
|
||||
|
||||
response.getOffers().removeIf(offer -> !filteredTabCompletionEvent.getCompletion().contains(offer.getText()));
|
||||
|
||||
if (response.getOffers().isEmpty()) return;
|
||||
}
|
||||
}
|
||||
@@ -245,10 +261,17 @@ public class VelocityPacketAnalyzer {
|
||||
} else if (packet instanceof AvailableCommandsPacket) {
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player) && player.getCurrentServer().isPresent()) {
|
||||
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName)) {
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
AvailableCommandsPacket commands = (AvailableCommandsPacket) packet;
|
||||
|
||||
if(!commands.getRootNode().getChildren().isEmpty()) {
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
|
||||
if (!cache.containsKey(serverName))
|
||||
@@ -263,7 +286,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 +303,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());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,32 +3,23 @@ package de.rayzs.pat.api.storage;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.api.storage.config.messages.*;
|
||||
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.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.utils.permission.PermissionPlugin;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.blacklist.BlacklistCreator;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralIgnoredServers;
|
||||
import de.rayzs.pat.api.storage.config.messages.BlacklistSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.CommandFailedSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.GroupSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.HelpSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.InfoSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.NoPermissionSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.NotificationSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.OnlyForProxySection;
|
||||
import de.rayzs.pat.api.storage.config.messages.PermsCheckSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.PostDebugSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.PrefixSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.ReloadSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.ServerListSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.StatsSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.UpdatePermissionsSection;
|
||||
import de.rayzs.pat.api.storage.placeholders.commands.general.ListCommandsPlaceholder;
|
||||
import de.rayzs.pat.api.storage.placeholders.commands.general.ListReversedCommandsPlaceholder;
|
||||
import de.rayzs.pat.api.storage.placeholders.commands.general.ListSizeCommandsPlaceholder;
|
||||
@@ -70,14 +61,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();
|
||||
@@ -94,6 +108,7 @@ public class Storage {
|
||||
}
|
||||
|
||||
public static void loadToken() {
|
||||
Files.TOKEN.reload();
|
||||
|
||||
boolean invalidEnv = false;
|
||||
|
||||
@@ -149,6 +164,30 @@ public class Storage {
|
||||
ConfigSections.PLACEHOLDERS.forEach(PlaceholderStorage::load);
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
boolean proxy = Reflection.isProxyServer();
|
||||
boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !proxy;
|
||||
|
||||
ConfigUpdater.initialize();
|
||||
Storage.loadAll(Reflection.isProxyServer() || !backend);
|
||||
|
||||
CustomServerBrand.initialize();
|
||||
GroupManager.clearAllGroups();
|
||||
GroupManager.initialize();
|
||||
|
||||
if (!proxy) {
|
||||
BackendUpdater.stop();
|
||||
BackendUpdater.start();
|
||||
}
|
||||
|
||||
if (!backend) {
|
||||
Storage.handleChange();
|
||||
}
|
||||
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
Storage.getLoader().handleReload();
|
||||
}
|
||||
|
||||
public static void handleChange() {
|
||||
handleChange(null);
|
||||
}
|
||||
@@ -212,9 +251,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 +277,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;
|
||||
}
|
||||
@@ -288,6 +341,7 @@ public class Storage {
|
||||
|
||||
public static class Settings {
|
||||
|
||||
public static AllowGroupOverrulingSection ALLOW_GROUP_OVERRULING = new AllowGroupOverrulingSection();
|
||||
public static AutoLowercaseCommandsSection AUTO_LOWERCASE_COMMANDS = new AutoLowercaseCommandsSection();
|
||||
public static BlockNamespaceCommandsSection BLOCK_NAMESPACE_COMMANDS = new BlockNamespaceCommandsSection();
|
||||
public static HandleThroughProxySection HANDLE_THROUGH_PROXY = new HandleThroughProxySection();
|
||||
@@ -301,7 +355,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() {}
|
||||
@@ -312,6 +368,8 @@ public class Storage {
|
||||
public static PrefixSection PREFIX = new PrefixSection();
|
||||
public static BlacklistSection BLACKLIST = new BlacklistSection();
|
||||
public static CommandFailedSection COMMAND_FAILED = new CommandFailedSection();
|
||||
public static ConvertSection CONVERT = new ConvertSection();
|
||||
public static ExtractSection EXTRACT = new ExtractSection();
|
||||
public static GroupSection GROUP = new GroupSection();
|
||||
public static HelpSection HELP = new HelpSection();
|
||||
public static InfoSection INFO = new InfoSection();
|
||||
@@ -521,18 +579,69 @@ public class Storage {
|
||||
}
|
||||
|
||||
public static boolean canPlayerAccess(Object player, String command, BlockType type, String server) {
|
||||
boolean blocked = isBlocked(command, type, server);
|
||||
final boolean allowGroupOverruling = ConfigSections.Settings.ALLOW_GROUP_OVERRULING.ENABLED;
|
||||
final boolean blocked = isBlocked(command, type, server);
|
||||
|
||||
if (allowGroupOverruling) {
|
||||
GroupManager.AccessResult groupResult = GroupManager.canAccessCommand(player, command, type, server);
|
||||
if (groupResult == GroupManager.AccessResult.NEGATED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!blocked) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Storage.getPermissionPlugin() != PermissionPlugin.NONE) {
|
||||
if (PermissionUtil.hasBypassPermission(player, command)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return groupResult.asBoolean();
|
||||
}
|
||||
|
||||
|
||||
if (!blocked) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command)) {
|
||||
if (Storage.getPermissionPlugin() != PermissionPlugin.NONE) {
|
||||
if (PermissionUtil.hasBypassPermission(player, command)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return GroupManager.canAccessCommand(player, command, type, server).asBoolean();
|
||||
}
|
||||
|
||||
/*
|
||||
Experimental:
|
||||
|
||||
It allows to negate commands inside a PAT group to block them off,
|
||||
even though it is allowed inside the global section.
|
||||
|
||||
public static boolean canPlayerAccess(Object player, String command, BlockType type, String server) {
|
||||
boolean blocked = isBlocked(command, type, server);
|
||||
GroupManager.AccessResult groupResult = GroupManager.canAccessCommand(player, command, type, server);
|
||||
|
||||
if (groupResult == GroupManager.AccessResult.NEGATED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!blocked) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return GroupManager.canAccessCommand(player, command, type, server);
|
||||
if (Storage.getPermissionPlugin() != PermissionPlugin.NONE) {
|
||||
if (PermissionUtil.hasBypassPermission(player, command)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return groupResult.asBoolean();
|
||||
}
|
||||
*/
|
||||
|
||||
public static boolean isBlockedChat(String command) {
|
||||
return isBlocked(command, BlockType.CHAT, null);
|
||||
@@ -559,34 +668,45 @@ public class Storage {
|
||||
BlockType negation = BlockType.NEGATE;
|
||||
String negatedCommand = negation + command;
|
||||
|
||||
boolean listed = isListed(command, type, server),
|
||||
boolean all = isListed("*", type, server),
|
||||
listed = isListed(command, type, server),
|
||||
negatedListed = isListed(negatedCommand, type, server),
|
||||
turn = ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
|
||||
if (all) {
|
||||
// Only listens to negated commands
|
||||
if (negatedListed) {
|
||||
return turn;
|
||||
}
|
||||
|
||||
if (!turn && negatedListed) {
|
||||
listed = !listed;
|
||||
return !turn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if (turn) {
|
||||
return !listed;
|
||||
} else {
|
||||
return listed;
|
||||
}
|
||||
*/
|
||||
|
||||
return turn != listed; // Shorter version of above's code
|
||||
|
||||
}
|
||||
|
||||
private static boolean isListed(String unmodifiedCommand, BlockType type, String server) {
|
||||
if (server != null && isDisabledServer(server))
|
||||
if (server != null && isDisabledServer(server)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
boolean listed = false;
|
||||
|
||||
String command = type.toString() + unmodifiedCommand;
|
||||
|
||||
if (server == null || !isIgnoredServer(server)) {
|
||||
listed = BLACKLIST.isListed(command, !turn);
|
||||
listed = BLACKLIST.isListed(command, false);
|
||||
}
|
||||
|
||||
if (server == null) {
|
||||
@@ -603,11 +723,11 @@ public class Storage {
|
||||
blacklists.add(BLACKLIST);
|
||||
|
||||
for (GeneralBlacklist blacklist : blacklists) {
|
||||
if (listed/* && turn*/) {
|
||||
if (listed) {
|
||||
break;
|
||||
}
|
||||
|
||||
listed = blacklist.isListed(command, turn);
|
||||
listed = blacklist.isListed(command, false);
|
||||
}
|
||||
|
||||
if (!listed && type != BlockType.BOTH) {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package de.rayzs.pat.api.storage.config.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper;
|
||||
|
||||
public class ConvertSection extends ConfigStorage {
|
||||
|
||||
public MultipleMessagesHelper MESSAGE;
|
||||
|
||||
public ConvertSection() {
|
||||
super("convert");
|
||||
}
|
||||
|
||||
public String INVALID_CONVERTER, SUCCESS;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
INVALID_CONVERTER = new ConfigSectionHelper<String>(this, "converter-not-found", "&cConverter or necessary files could not be found!").getOrSet();
|
||||
SUCCESS = new ConfigSectionHelper<String>(this, "success", "&aSuccessfully converted &e%converter% &ainto the PAT storage.yml!").getOrSet();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package de.rayzs.pat.api.storage.config.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper;
|
||||
|
||||
public class ExtractSection extends ConfigStorage {
|
||||
|
||||
public MultipleMessagesHelper MESSAGE;
|
||||
|
||||
public ExtractSection() {
|
||||
super("extract");
|
||||
}
|
||||
|
||||
public String USAGE, PLUGIN_NOT_FOUND, SUCCESS;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
USAGE = new ConfigSectionHelper<String>(this, "usage", "&7Usage: &f/pat extract [plugin] <use-colon> &7or &f<group> <use-colon>").getOrSet();
|
||||
PLUGIN_NOT_FOUND = new ConfigSectionHelper<String>(this, "plugin-not-found", "&cPlugin %plugin% not found!").getOrSet();
|
||||
SUCCESS = new ConfigSectionHelper<String>(this, "success", "&aSuccessfully extracted &e%amount% &anew commands from %plugin%!").getOrSet();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public class HelpSection extends ConfigStorage {
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
MESSAGE = new MultipleMessagesHelper(this, null, Reflection.isProxyServer() ?
|
||||
Arrays.asList(
|
||||
"&7Available commands are: &f/%label%&7..."
|
||||
@@ -26,6 +27,8 @@ public class HelpSection extends ConfigStorage {
|
||||
, "&f postdebug &7to post the PAT logs"
|
||||
, "&f update <player> &7to update player(s) permissions"
|
||||
, "&f perms <player> &7to check a player's permissions"
|
||||
, "&f extract (plugin) &7to extract all plugin commands"
|
||||
, "&f convert (plugin) &7converts into a PAT storage.yml"
|
||||
, "&f creategroup (group) &7Create a group"
|
||||
, "&f deletegroup (group) &7Delete a group"
|
||||
, "&f setpriority (group) (priority) &7to set the priority"
|
||||
@@ -44,6 +47,7 @@ public class HelpSection extends ConfigStorage {
|
||||
, "&f postdebug &7to post the PAT logs"
|
||||
, "&f update <player> &7to update player(s) permissions"
|
||||
, "&f perms <player> &7to check a player's permissions"
|
||||
, "&f extract (plugin) &7to extract all plugin commands"
|
||||
, "&f creategroup (group) &7Create a group"
|
||||
, "&f deletegroup (group) &7Delete a group"
|
||||
, "&f setpriority (group) (priority) &7to set the priority"
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
|
||||
public class AllowGroupOverrulingSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
|
||||
public AllowGroupOverrulingSection() {
|
||||
super("allow-group-overruling");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
}
|
||||
}
|
||||
+10
-4
@@ -1,6 +1,5 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
@@ -8,7 +7,7 @@ import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
|
||||
public class BlockNamespaceCommandsSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
public boolean ENABLED, ALWAYS_BLOCK_COMMAND;
|
||||
|
||||
public BlockNamespaceCommandsSection() {
|
||||
super("block-namespace-commands");
|
||||
@@ -18,15 +17,22 @@ public class BlockNamespaceCommandsSection extends ConfigStorage {
|
||||
public void load() {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
ALWAYS_BLOCK_COMMAND = new ConfigSectionHelper<Boolean>(this, "always-block-command", true).getOrSet();
|
||||
}
|
||||
|
||||
public boolean doesAlwaysBlock(String command) {
|
||||
return ALWAYS_BLOCK_COMMAND && isCommand(command);
|
||||
}
|
||||
|
||||
public boolean isCommand(String command) {
|
||||
if(!ENABLED || Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) return false;
|
||||
if (!ENABLED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return StringUtils.getFirstArg(command).contains(":");
|
||||
}
|
||||
|
||||
public boolean doesBypass(Object targetObj) {
|
||||
|
||||
return !ENABLED || PermissionUtil.hasPermission(targetObj, "namespace");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.*;
|
||||
import java.util.*;
|
||||
|
||||
@@ -31,13 +32,8 @@ public class CustomPluginsSection extends ConfigStorage {
|
||||
|
||||
public boolean isCommand(String command) {
|
||||
if(!ENABLED) return false;
|
||||
command = StringUtils.getFirstArg(command);
|
||||
|
||||
if (command.contains(" ")) {
|
||||
String[] split = command.split(" ");
|
||||
if (split.length > 0)
|
||||
command = split[0];
|
||||
command = command.split(" ")[0];
|
||||
}
|
||||
for (String currentCommand : COMMANDS.getLines()) {
|
||||
if (currentCommand.equalsIgnoreCase(command))
|
||||
return true;
|
||||
|
||||
+1
-1
@@ -26,6 +26,6 @@ public class HandleThroughProxySection extends ConfigStorage {
|
||||
TOKEN = new ConfigSectionHelper<String>(this, "token", "insert-token-of-proxy-here").getOrSet();
|
||||
|
||||
LOAD_FROM_ENV = new ConfigSectionHelper<Boolean>(this, "load-from-env.enabled", false).getOrSet();
|
||||
ENV_NAME = new ConfigSectionHelper<String>(this, "load-from-env.name", false).getOrSet();
|
||||
ENV_NAME = new ConfigSectionHelper<String>(this, "load-from-env.name", "PAT_TOKEN").getOrSet();
|
||||
}
|
||||
}
|
||||
+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
|
||||
@@ -1,8 +1,6 @@
|
||||
package de.rayzs.pat.api.storage.storages;
|
||||
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.api.storage.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -11,13 +9,14 @@ import java.util.*;
|
||||
public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
|
||||
private List<String> commands = new ArrayList<>();
|
||||
private List<String> hiddenCommands = new ArrayList<>();
|
||||
|
||||
public BlacklistStorage(String navigatePath) {
|
||||
super(Storage.Files.STORAGE, navigatePath);
|
||||
}
|
||||
|
||||
public boolean isListed(String command) {
|
||||
return isListed(command, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
|
||||
return isListed(command, false);
|
||||
}
|
||||
|
||||
public boolean isListed(String command, boolean ignoreColons) {
|
||||
@@ -27,11 +26,19 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
if (!isNegated(command) && commands.contains("*")) {
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
for (String listedCommand : commands) {
|
||||
boolean isNegated = isNegated(command);
|
||||
|
||||
if (!isNegated) {
|
||||
command = StringUtils.getFirstArg(command);
|
||||
}
|
||||
|
||||
for (String listedCommand : hiddenCommands) {
|
||||
if (listedCommand == null)
|
||||
continue;
|
||||
|
||||
@@ -42,14 +49,14 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
command = command.substring(command.indexOf(':'));
|
||||
}
|
||||
|
||||
if (caseSensitive) {
|
||||
if (StringUtils.getFirstArg(listedCommand).equals(StringUtils.getFirstArg(command))) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (StringUtils.getFirstArg(listedCommand).equalsIgnoreCase(StringUtils.getFirstArg(command))) {
|
||||
return true;
|
||||
}
|
||||
if (!isNegated) {
|
||||
listedCommand = StringUtils.getFirstArg(listedCommand);
|
||||
}
|
||||
|
||||
if (caseSensitive && listedCommand.equals(command)) {
|
||||
return true;
|
||||
} else if (!caseSensitive && listedCommand.equalsIgnoreCase(command)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,14 +68,17 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
}
|
||||
|
||||
public BlacklistStorage add(String command) {
|
||||
if (!commands.contains(command))
|
||||
if (!commands.contains(command)) {
|
||||
commands.add(command);
|
||||
hiddenCommands.add(command);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public BlacklistStorage remove(String command) {
|
||||
commands.remove(command);
|
||||
hiddenCommands.remove(command);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -81,6 +91,10 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
return commands;
|
||||
}
|
||||
|
||||
public List<String> getHiddenCommands() {
|
||||
return hiddenCommands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
getConfig().setAndSave(getNavigatePath(), commands);
|
||||
@@ -89,7 +103,35 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
@Override
|
||||
public void load() {
|
||||
getConfig().reload();
|
||||
|
||||
commands = (ArrayList<String>) getConfig().getOrSet(getNavigatePath(), commands);
|
||||
|
||||
List<String> tmpCommands = commands != null ? new ArrayList<>(commands) : new ArrayList<>();
|
||||
Set<String> pluginListCommands = new HashSet<>();
|
||||
|
||||
final String pluginCommandPrefix = "plugin=";
|
||||
|
||||
for (String command : tmpCommands) {
|
||||
if (command.startsWith(pluginCommandPrefix)) {
|
||||
pluginListCommands.add(command);
|
||||
}
|
||||
}
|
||||
|
||||
tmpCommands.removeAll(pluginListCommands);
|
||||
|
||||
for (String pluginListCommand : pluginListCommands) {
|
||||
pluginListCommand = pluginListCommand.substring(pluginCommandPrefix.length());
|
||||
|
||||
List<String> pluginCommands = Storage.getLoader().getPluginCommands(pluginListCommand, false);
|
||||
|
||||
for (String pluginCommand : pluginCommands) {
|
||||
if (!commands.contains(Storage.Blacklist.BlockType.NEGATE + pluginCommand)) {
|
||||
tmpCommands.add(pluginCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hiddenCommands = tmpCommands;
|
||||
}
|
||||
|
||||
private boolean isNegated(String command) {
|
||||
|
||||
@@ -17,8 +17,11 @@ public class DisabledServersStorage extends StorageTemplate {
|
||||
|
||||
public DisabledServersStorage add(String server) {
|
||||
server = server.toLowerCase();
|
||||
if(!servers.contains(server))
|
||||
|
||||
if (!servers.contains(server)) {
|
||||
servers.add(server);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -29,7 +32,10 @@ public class DisabledServersStorage extends StorageTemplate {
|
||||
}
|
||||
|
||||
public boolean isListed(String server) {
|
||||
if(servers.isEmpty()) return false;
|
||||
if (servers.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Storage.isServer(server, servers);
|
||||
}
|
||||
|
||||
@@ -42,7 +48,11 @@ public class DisabledServersStorage extends StorageTemplate {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
if(!Reflection.isProxyServer()) return;
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
getConfig().reload();
|
||||
servers = (ArrayList<String>) getConfig().getOrSet(getNavigatePath(), servers);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.rayzs.pat.plugin;
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
@@ -22,6 +23,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 +116,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,11 +131,18 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
Logger.warning("Detected SimpleCloud. Therefore, MiniMessages are disabled!");
|
||||
}
|
||||
|
||||
Storage.broadcastPermissionsPluginNotice();
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.initialize();
|
||||
|
||||
PATScheduler.createScheduler(this::loadAllCommands);
|
||||
StorageConverter.initialize();
|
||||
|
||||
PATScheduler.createScheduler(() -> {
|
||||
Storage.reload();
|
||||
loadAllCommands();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -255,14 +265,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 +282,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 +354,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();
|
||||
@@ -357,17 +382,44 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginNames() {
|
||||
public List<String> getPluginNames(String format) {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
PluginDescriptionFile description = plugin.getDescription();
|
||||
pluginNames.add(description.getName() + " (" + description.getVersion() + ")");
|
||||
|
||||
pluginNames.add(
|
||||
format.replace("%n", description.getName())
|
||||
.replace("%v", description.getVersion())
|
||||
);
|
||||
}
|
||||
|
||||
return pluginNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginCommands(String pluginName, boolean useColons) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
|
||||
if (pluginName.isBlank()) return commands;
|
||||
|
||||
pluginName = pluginName.toLowerCase();
|
||||
|
||||
for (Map.Entry<String, Command> entry : BukkitLoader.getCommandsMap().entrySet()) {
|
||||
if (entry.getKey().toLowerCase().startsWith(pluginName + ":")) {
|
||||
String command = entry.getKey().substring(pluginName.length() + 1);
|
||||
|
||||
commands.add(command);
|
||||
|
||||
if (useColons) {
|
||||
commands.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
private void loadCommandMap() {
|
||||
try {
|
||||
if (Bukkit.getPluginManager() instanceof SimplePluginManager) {
|
||||
@@ -421,13 +473,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();
|
||||
@@ -437,6 +484,10 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
BukkitLoader.disallowedCommands = commands.stream().filter(command -> !allowedCommands.contains(command)).toList();
|
||||
}
|
||||
|
||||
public static Map<String, Command> getCommandsMap() {
|
||||
return commandsMap;
|
||||
}
|
||||
|
||||
public static boolean useSuggestions() {
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.rayzs.pat.plugin;
|
||||
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
@@ -10,6 +11,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,10 +96,15 @@ 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();
|
||||
|
||||
StorageConverter.initialize();
|
||||
|
||||
// Reload proxy commands after 1, 5, and 15 seconds.
|
||||
for (int i : new Integer[] { 1, 5, 15 }) {
|
||||
ProxyServer.getInstance().getScheduler().schedule(this, BungeePacketAnalyzer::loadProxyCommands, i, TimeUnit.SECONDS);
|
||||
@@ -122,6 +129,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;
|
||||
@@ -240,17 +257,26 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginNames() {
|
||||
public List<String> getPluginNames(String format) {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
|
||||
for (Plugin plugin : ProxyServer.getInstance().getPluginManager().getPlugins()) {
|
||||
PluginDescription description = plugin.getDescription();
|
||||
pluginNames.add(description.getName() + " (" + description.getVersion() + ")");
|
||||
|
||||
pluginNames.add(
|
||||
format.replace("%n", description.getName())
|
||||
.replace("%v", description.getVersion())
|
||||
);
|
||||
}
|
||||
|
||||
return pluginNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginCommands(String pluginName, boolean useColons) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
public void startUpdaterTask() {
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED)
|
||||
return;
|
||||
|
||||
@@ -13,6 +13,8 @@ public interface PluginLoader {
|
||||
|
||||
HashMap<String, CommandsCache> getCommandsCacheMap();
|
||||
|
||||
void delayedPermissionsReload();
|
||||
|
||||
void updateCommandCache();
|
||||
|
||||
List<String> getServerNames();
|
||||
@@ -39,5 +41,12 @@ public interface PluginLoader {
|
||||
List<String> getOnlinePlayerNames();
|
||||
List<String> getOfflinePlayerNames();
|
||||
|
||||
List<String> getPluginNames();
|
||||
List<String> getPluginCommands(String pluginName, boolean useColons);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* %n = Plugin name
|
||||
* %v = Plugin version
|
||||
*/
|
||||
List<String> getPluginNames(String format);
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
@@ -37,7 +38,7 @@ import java.util.*;
|
||||
|
||||
@Plugin(name = "ProAntiTab",
|
||||
id = "proantitab",
|
||||
version = "2.0.20",
|
||||
version = "2.2.0",
|
||||
authors = "Rayzs_YT",
|
||||
description = "Hide more than just your plugins. Hide almost everything!",
|
||||
url = "https://www.rayzs.de/products/proantitab/page",
|
||||
@@ -116,16 +117,21 @@ 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();
|
||||
|
||||
StorageConverter.initialize();
|
||||
}
|
||||
|
||||
public static org.slf4j.Logger getPluginLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
public static void delayedPermissionsReload() {
|
||||
@Override
|
||||
public void delayedPermissionsReload() {
|
||||
server.getScheduler().buildTask(VelocityLoader.instance, () -> {
|
||||
PermissionUtil.reloadPermissions();
|
||||
Storage.getLoader().updateCommandCache();
|
||||
@@ -274,7 +280,7 @@ public class VelocityLoader implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginNames() {
|
||||
public List<String> getPluginNames(String format) {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
for (PluginContainer plugin : server.getPluginManager().getPlugins()) {
|
||||
PluginDescription description = plugin.getDescription();
|
||||
@@ -282,12 +288,20 @@ public class VelocityLoader implements PluginLoader {
|
||||
String pluginName = description.getName().orElse("/");
|
||||
String version = description.getVersion().orElse("/");
|
||||
|
||||
pluginNames.add(pluginName + " (" + version + ")");
|
||||
pluginNames.add(
|
||||
format.replace("%n", pluginName)
|
||||
.replace("%v", version)
|
||||
);
|
||||
}
|
||||
|
||||
return pluginNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginCommands(String pluginName, boolean useColons) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
public void startUpdaterTask() {
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED) return;
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package de.rayzs.pat.plugin.converter;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.utils.configuration.ConfigurationBuilder;
|
||||
import de.rayzs.pat.utils.configuration.Configurator;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Converter {
|
||||
|
||||
private final String pluginName, fileName, folderPath;
|
||||
protected final ConfigurationBuilder config;
|
||||
|
||||
public Converter(String pluginName, String folderName, String fileName) {
|
||||
this.pluginName = pluginName;
|
||||
this.fileName = fileName;
|
||||
this.folderPath = "./plugins/" + folderName;
|
||||
this.config = exists() ? Configurator.get(fileName, folderPath) : null;
|
||||
}
|
||||
|
||||
public String getPluginName() {
|
||||
return pluginName;
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
return new File(folderPath, fileName + ".yml").exists();
|
||||
}
|
||||
|
||||
protected void applyStorage(BlacklistStorage storage, List<String> commands) {
|
||||
for (String command : commands) {
|
||||
boolean exist = command.contains(" ")
|
||||
? storage.getCommands().contains(command)
|
||||
: storage.isListed(command);
|
||||
|
||||
if (exist) continue;
|
||||
|
||||
storage.add(command);
|
||||
}
|
||||
|
||||
storage.save();
|
||||
}
|
||||
|
||||
public abstract void apply(CommandSender sender);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package de.rayzs.pat.plugin.converter;
|
||||
|
||||
import de.rayzs.pat.plugin.converter.converters.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.*;
|
||||
|
||||
public class StorageConverter {
|
||||
|
||||
private StorageConverter() {}
|
||||
|
||||
private static final Map<String, Converter> converters = new HashMap<>();
|
||||
|
||||
|
||||
public static void initialize() {
|
||||
|
||||
if (!converters.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
registerConverter(new AdvancedPlHideConverter());
|
||||
registerConverter(new CommandWhitelistConverter());
|
||||
registerConverter(new PluginHiderPlus());
|
||||
registerConverter(new PlHideFree());
|
||||
registerConverter(new PlHidePro());
|
||||
}
|
||||
|
||||
public static Set<String> getConverters() {
|
||||
return converters.keySet();
|
||||
}
|
||||
|
||||
public static Converter getConverter(@NotNull String name) {
|
||||
return converters.get(name);
|
||||
}
|
||||
|
||||
public static void registerConverter(@NotNull Converter converter) {
|
||||
if (!converter.exists()) return;
|
||||
|
||||
converters.putIfAbsent(converter.getPluginName(), converter);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package de.rayzs.pat.plugin.converter.converters;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AdvancedPlHideConverter extends Converter {
|
||||
|
||||
public AdvancedPlHideConverter() {
|
||||
super("AdvancedPlHide", "AdvancedPlHide", "config");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(CommandSender sender) {
|
||||
List<String> groups = config.getKeys("groups", false).stream().toList();
|
||||
|
||||
for (String groupName : groups) {
|
||||
List<String> commands = (ArrayList<String>) config.get("groups."+ groupName + ".tabcomplete");
|
||||
BlacklistStorage storage;
|
||||
|
||||
if (groupName.equalsIgnoreCase("default")) {
|
||||
storage = Storage.Blacklist.getBlacklist();
|
||||
} else {
|
||||
Group group = GroupManager.registerAndGetGroup(groupName);
|
||||
storage = group.getGeneralGroupBlacklist();
|
||||
}
|
||||
|
||||
applyStorage(storage, commands);
|
||||
|
||||
}
|
||||
|
||||
sender.sendMessage("&e&lNotice: &7AdvanedPlHide works based on permissions whether to whitelist or blacklist commands from a group. Due to the fact that this cannot be detected by PAT and formatted in the exact way, all commands have been interpreted as whitelisted commands instead. Also, since PAT groups are only intended to whitelist commands, all created groups based on AdvancedPlHide have been created with the intention of whitelisting commands instead. If you wish to change that, please check out the GitHub wiki on how to use the storage.yml of PAT the intended way. (https://github.com/RayzsYT/ProAntiTab/wiki/How-to#introduction)");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package de.rayzs.pat.plugin.converter.converters;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandWhitelistConverter extends Converter {
|
||||
|
||||
public CommandWhitelistConverter() {
|
||||
super("CommandWhitelist", "CommandWhitelist", "config");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(CommandSender sender) {
|
||||
List<String> groups = config.getKeys("groups", false).stream().toList();
|
||||
|
||||
for (String groupName : groups) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
|
||||
final List<String> l1 = (ArrayList<String>) config.get("groups." + groupName + ".commands");
|
||||
final List<String> l2 = (ArrayList<String>) config.get("groups." + groupName + ".subcommands");
|
||||
|
||||
commands.addAll(l1);
|
||||
commands.addAll(l2);
|
||||
|
||||
BlacklistStorage storage;
|
||||
|
||||
if (groupName.equalsIgnoreCase("default")) {
|
||||
storage = Storage.Blacklist.getBlacklist();
|
||||
} else {
|
||||
Group group = GroupManager.registerAndGetGroup(groupName);
|
||||
storage = group.getGeneralGroupBlacklist();
|
||||
}
|
||||
|
||||
applyStorage(storage, commands);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package de.rayzs.pat.plugin.converter.converters;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlHideFree extends Converter {
|
||||
|
||||
public PlHideFree() {
|
||||
super("PlHide", "Pl-Hide-Free", "config");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(CommandSender sender) {
|
||||
List<String> groups = config.getKeys("groups", false).stream().toList();
|
||||
|
||||
for (String groupName : groups) {
|
||||
List<String> execution = (ArrayList<String>) config.get("groups." + groupName + ".commands");
|
||||
List<String> commands = execution.stream().filter(s -> !s.startsWith("!") && !s.equalsIgnoreCase("*")).map(this::translate).toList();
|
||||
|
||||
BlacklistStorage storage;
|
||||
|
||||
if (groupName.equalsIgnoreCase("default")) {
|
||||
storage = Storage.Blacklist.getBlacklist();
|
||||
} else {
|
||||
Group group = GroupManager.registerAndGetGroup(groupName);
|
||||
storage = group.getGeneralGroupBlacklist();
|
||||
}
|
||||
|
||||
applyStorage(storage, commands);
|
||||
|
||||
}
|
||||
|
||||
sender.sendMessage("§e§lNotice: §7Since PAT is mainly focussed on either blocking or whitelisting commands entirely, PAT is viewing and converting the file such that commands are only working in whitelist mode. If you wish to use ProAntiTab in blacklist mode instead, then please checkout the wiki! (https://github.com/RayzsYT/ProAntiTab/wiki/How-to#introduction)");
|
||||
}
|
||||
|
||||
private String translate(String input) {
|
||||
if (input.contains(" ")) {
|
||||
if (input.endsWith("~")) {
|
||||
return translate(input.substring(0, input.length() - 1) + "_-");
|
||||
}
|
||||
|
||||
if (input.endsWith("*")) {
|
||||
return input.substring(0, input.length() - 2);
|
||||
} else if (input.contains("*")) {
|
||||
return input.substring(0, input.indexOf('*') - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package de.rayzs.pat.plugin.converter.converters;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PlHidePro extends Converter {
|
||||
|
||||
public PlHidePro() {
|
||||
super("PlHidePro", "Pl-Hide-Pro", "config");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(CommandSender sender) {
|
||||
|
||||
boolean updateGroupPerWorld = (boolean) config.get("per_world_group_updates");
|
||||
Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_WORLD.getConfig().setAndSave("update-groups-per-world", updateGroupPerWorld);
|
||||
|
||||
boolean autoLowercaseCommands = (boolean) config.get("auto_lowercase_base_commands");
|
||||
Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.getConfig().setAndSave("auto-lowercase-commands.enabled", autoLowercaseCommands);
|
||||
|
||||
boolean f3brand = (boolean) config.get("replace-f3-server-brand");
|
||||
String f3brandString = (String) config.get("f3-server-brand");
|
||||
Storage.ConfigSections.Settings.CUSTOM_BRAND.getConfig().setAndSave("custom-server-brand.enabled", f3brand);
|
||||
|
||||
if (f3brand) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_BRAND.getConfig().setAndSave("custom-server-brand.repeat-delay", -1);
|
||||
Storage.ConfigSections.Settings.CUSTOM_BRAND.getConfig().setAndSave("custom-server-brand.brands", new ArrayList<>(Collections.singletonList(f3brandString.replace("§", "&"))));
|
||||
}
|
||||
|
||||
List<String> groups = config.getKeys("groups", false).stream().toList();
|
||||
|
||||
for (String groupName : groups) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
|
||||
final List<String> execution = (ArrayList<String>) config.get("groups." + groupName + ".commands");
|
||||
final List<String> tabCompletion = (ArrayList<String>) config.get("groups." + groupName + ".tabcomplete");
|
||||
|
||||
for (String s : execution) {
|
||||
if (s.equalsIgnoreCase("*")) {
|
||||
tabCompletion.remove("*");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!s.contains(" ") && s.startsWith("!")) {
|
||||
tabCompletion.remove(s);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tabCompletion.contains(s)) {
|
||||
commands.add(s);
|
||||
tabCompletion.remove(s);
|
||||
continue;
|
||||
}
|
||||
|
||||
commands.add("[CMD]" + s);
|
||||
}
|
||||
|
||||
commands.addAll(tabCompletion.stream().map(s -> "[TAB]" + s).toList());
|
||||
commands = commands.stream().map(this::translate).toList();
|
||||
|
||||
BlacklistStorage storage;
|
||||
|
||||
if (groupName.equalsIgnoreCase("default")) {
|
||||
storage = Storage.Blacklist.getBlacklist();
|
||||
} else {
|
||||
Group group = GroupManager.registerAndGetGroup(groupName);
|
||||
storage = group.getGeneralGroupBlacklist();
|
||||
}
|
||||
|
||||
applyStorage(storage, commands);
|
||||
}
|
||||
|
||||
sender.sendMessage("§e§lNotice: §7Since PAT is mainly focussed on either blocking or whitelisting commands entirely, PAT is viewing and converting the file such that commands are only working in whitelist mode. If you wish to use ProAntiTab in blacklist mode instead, then please checkout the wiki! (https://github.com/RayzsYT/ProAntiTab/wiki/How-to#introduction)");
|
||||
}
|
||||
|
||||
private String translate(String input) {
|
||||
if (input.contains(" ")) {
|
||||
if (input.endsWith("~")) {
|
||||
return translate(input.substring(0, input.length() - 1) + "_-");
|
||||
}
|
||||
|
||||
if (input.endsWith("*")) {
|
||||
return input.substring(0, input.length() - 2);
|
||||
} else if (input.contains("*")) {
|
||||
return input.substring(0, input.indexOf('*') - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package de.rayzs.pat.plugin.converter.converters;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PluginHiderPlus extends Converter {
|
||||
|
||||
public PluginHiderPlus() {
|
||||
super("PluginHider+", "PluginHiderPlus", "config");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(CommandSender sender) {
|
||||
|
||||
boolean blacklist = (boolean) config.get("reverse-suggestionsWhitelist");
|
||||
Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.getConfig().setAndSave("turn-blacklist-to-whitelist", !blacklist);
|
||||
|
||||
List<String> commands = (ArrayList<String>) config.get("suggestionsWhitelist");
|
||||
|
||||
if (blacklist) {
|
||||
List<String> blockedCommands = (ArrayList<String>) config.get("blockedCommands.everyone.commands");
|
||||
commands.addAll(blockedCommands);
|
||||
}
|
||||
|
||||
applyStorage(Storage.Blacklist.getBlacklist(), commands);
|
||||
sender.sendMessage("&e&lNotice: &7Since PluginHider+ both blocks certain commands and whitelist a few, the conversion into PAT's storage.yml format won't be accurate. Only whitelisted commands have been added, and blocked commands for everyone if the plugin was used in blacklist mode.");
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
+75
-14
@@ -2,6 +2,8 @@ package de.rayzs.pat.plugin.listeners.bukkit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -45,7 +47,9 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandProcess(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
final String commandFirstArg = StringUtils.getFirstArg(event.getMessage());
|
||||
|
||||
if (Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.isCommand(commandFirstArg)) {
|
||||
@@ -68,30 +72,87 @@ 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();
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command)) {
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
return;
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
|
||||
return;
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
return;
|
||||
MessageTranslator.send(
|
||||
player,
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE,
|
||||
"%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
if (!Storage.Blacklist.canPlayerAccessChat(player, command)) {
|
||||
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;
|
||||
}
|
||||
|
||||
final boolean cancelBlockedCommand = Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED;
|
||||
|
||||
boolean allowed = Storage.Blacklist.canPlayerAccessChat(player, command);
|
||||
boolean blockedNamespace = false;
|
||||
|
||||
if (!Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender)) {
|
||||
blockedNamespace = cancelBlockedCommand
|
||||
? Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command)
|
||||
: Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesAlwaysBlock(command);
|
||||
|
||||
if (blockedNamespace) allowed = false;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED && !blockedNamespace) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!allowed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
player,
|
||||
event.getMessage(),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -2,7 +2,9 @@ package de.rayzs.pat.plugin.listeners.bungee;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@@ -10,19 +12,32 @@ import net.md_5.bungee.api.event.TabCompleteEvent;
|
||||
import net.md_5.bungee.api.event.TabCompleteResponseEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class BungeeAntiTabListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onTabComplete(TabCompleteEvent event) {
|
||||
if(!(event.getSender() instanceof ProxiedPlayer)) return;
|
||||
public void onTabCompleteResponse(TabCompleteResponseEvent event) {
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
|
||||
if(!(event.getReceiver() instanceof ProxiedPlayer)) return;
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
|
||||
ServerInfo serverInfo = player.getServer().getInfo();
|
||||
String serverName = serverInfo.getName();
|
||||
String cursor = event.getCursor().substring(1);
|
||||
|
||||
String rawCursor = BungeePacketAnalyzer.getPlayerInput(player);
|
||||
|
||||
if (rawCursor == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!rawCursor.startsWith("/")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String cursor = rawCursor.substring(1);
|
||||
|
||||
if (event.getSuggestions().isEmpty())
|
||||
return;
|
||||
@@ -33,35 +48,59 @@ public class BungeeAntiTabListener implements Listener {
|
||||
if (PermissionUtil.hasBypassPermission(player))
|
||||
return;
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player, cursor, event.getSuggestions());
|
||||
List<String> suggestions = filteredTabCompletionEvent.getCompletion();
|
||||
|
||||
event.getSuggestions().removeIf(suggestion -> !suggestions.contains(suggestion));
|
||||
|
||||
final boolean doesBypassNamespace = Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player);
|
||||
final boolean spaces = cursor.contains(" ");
|
||||
|
||||
boolean cancelsBeforeHand = false;
|
||||
|
||||
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(cursor) && !doesBypassNamespace) {
|
||||
cancelsBeforeHand = true;
|
||||
}
|
||||
|
||||
if (!cancelsBeforeHand && !cursor.isEmpty()) {
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(player, StringUtils.getFirstArg(cursor), serverName);
|
||||
}
|
||||
|
||||
if (!cancelsBeforeHand) {
|
||||
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(cursor) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(cursor);
|
||||
}
|
||||
|
||||
if (spaces) {
|
||||
if (cancelsBeforeHand) {
|
||||
event.getSuggestions().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawCursor, new ArrayList<>(event.getSuggestions()));
|
||||
|
||||
if (filteredTabCompletionEvent.isCancelled()) {
|
||||
event.getSuggestions().clear();
|
||||
} else {
|
||||
event.getSuggestions().removeIf(s -> !filteredTabCompletionEvent.getCompletion().contains(s));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
event.getSuggestions().removeIf(s -> {
|
||||
String cpy = s;
|
||||
if (cpy.startsWith("/")) {
|
||||
cpy = cpy.substring(1);
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(cpy) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(cpy)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !Storage.Blacklist.canPlayerAccessTab(player, cpy, serverName);
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTabComplete(TabCompleteResponseEvent event) {
|
||||
// Ignoring this at first, due to transfer to the packet-based solution only. Hehe
|
||||
|
||||
/*
|
||||
if (!(event.getSender() instanceof ProxiedPlayer))
|
||||
return;
|
||||
|
||||
public void onTabComplete(TabCompleteEvent event) {
|
||||
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();
|
||||
*/
|
||||
BungeePacketAnalyzer.setPlayerInput(player, event.getCursor());
|
||||
}
|
||||
}
|
||||
+69
-10
@@ -3,6 +3,8 @@ package de.rayzs.pat.plugin.listeners.bungee;
|
||||
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
|
||||
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.event.ChatEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
@@ -20,17 +22,17 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
public void onChat(ChatEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
Connection connection = event.getSender();
|
||||
final Connection connection = event.getSender();
|
||||
if (! (connection instanceof ProxiedPlayer) || !event.getMessage().startsWith("/"))
|
||||
return;
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) connection;
|
||||
String serverName = player.getServer().getInfo().getName();
|
||||
final ProxiedPlayer player = (ProxiedPlayer) connection;
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final String serverName = player.getServer().getInfo().getName();
|
||||
|
||||
String command = event.getMessage();
|
||||
|
||||
boolean bypassPermission = PermissionUtil.hasBypassPermission(player, command);
|
||||
|
||||
if (bypassPermission)
|
||||
if (PermissionUtil.hasBypassPermission(player, command) || Storage.Blacklist.isDisabledServer(serverName))
|
||||
return;
|
||||
|
||||
command = command.startsWith("/") ? command.substring(1) : command;
|
||||
@@ -38,7 +40,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,10 +47,68 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
"%command%", displayCommand,
|
||||
"%server%", serverName);
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
|
||||
return;
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
|
||||
if (!Storage.Blacklist.canPlayerAccessChat(player, command, serverName)) {
|
||||
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;
|
||||
}
|
||||
|
||||
final boolean cancelBlockedCommand = Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED;
|
||||
|
||||
boolean allowed = Storage.Blacklist.canPlayerAccessChat(player, command, serverName);
|
||||
boolean blockedNamespace = false;
|
||||
|
||||
if (!Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender)) {
|
||||
blockedNamespace = cancelBlockedCommand
|
||||
? Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command)
|
||||
: Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesAlwaysBlock(command);
|
||||
|
||||
if (blockedNamespace) allowed = false;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED && !blockedNamespace) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!allowed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
player,
|
||||
event.getMessage(),
|
||||
|
||||
+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,8 +62,16 @@ public class VelocityAntiTabListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
|
||||
if (!cache.containsKey(serverName)) {
|
||||
@@ -64,12 +84,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 +104,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();
|
||||
}
|
||||
}
|
||||
|
||||
+72
-14
@@ -10,6 +10,9 @@ import com.velocitypowered.api.proxy.Player;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.api.event.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class VelocityBlockCommandListener {
|
||||
@@ -27,28 +30,25 @@ public class VelocityBlockCommandListener {
|
||||
if(!event.getResult().isAllowed())
|
||||
return event;
|
||||
|
||||
CommandSource commandSource = event.getCommandSource();
|
||||
Object consoleSender = Storage.getLoader().getConsoleSender();
|
||||
final CommandSource commandSource = event.getCommandSource();
|
||||
final Object consoleSender = Storage.getLoader().getConsoleSender();
|
||||
|
||||
if(! (commandSource instanceof Player))
|
||||
return event;
|
||||
|
||||
Player player = (Player) commandSource;
|
||||
String command = StringUtils.getFirstArg(event.getCommand());
|
||||
|
||||
String serverName = player.getCurrentServer().isPresent()
|
||||
final Player player = (Player) commandSource;
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final String serverName = player.getCurrentServer().isPresent()
|
||||
? player.getCurrentServer().get().getServerInfo().getName()
|
||||
: "unknown";
|
||||
|
||||
boolean bypassPermission = PermissionUtil.hasBypassPermission(player, command);
|
||||
String command = StringUtils.getFirstArg(event.getCommand());
|
||||
|
||||
if (bypassPermission)
|
||||
if (PermissionUtil.hasBypassPermission(player, command) || Storage.Blacklist.isDisabledServer(serverName))
|
||||
return event;
|
||||
|
||||
final String displayCommand = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
|
||||
//command = command.toLowerCase();
|
||||
|
||||
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
|
||||
@@ -57,10 +57,68 @@ public class VelocityBlockCommandListener {
|
||||
"%server%", serverName
|
||||
);
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
|
||||
return event;
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
|
||||
if (!Storage.Blacklist.canPlayerAccessChat(player, command, serverName)) {
|
||||
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;
|
||||
}
|
||||
|
||||
final boolean cancelBlockedCommand = Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED;
|
||||
|
||||
boolean allowed = Storage.Blacklist.canPlayerAccessChat(player, command, serverName);
|
||||
boolean blockedNamespace = false;
|
||||
|
||||
if (!Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender)) {
|
||||
blockedNamespace = cancelBlockedCommand
|
||||
? Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command)
|
||||
: Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesAlwaysBlock(command);
|
||||
|
||||
if (blockedNamespace) allowed = false;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED && !blockedNamespace) {
|
||||
return event;
|
||||
}
|
||||
|
||||
if (!allowed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
player,
|
||||
event.getCommand(),
|
||||
@@ -76,7 +134,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);
|
||||
|
||||
+36
-5
@@ -5,6 +5,7 @@ import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.api.netty.proxy.VelocityPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
@@ -12,6 +13,10 @@ 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 net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class VelocityConnectionListener {
|
||||
@@ -26,7 +31,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 +42,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 +57,32 @@ public class VelocityConnectionListener {
|
||||
public void onServerSwitch(ServerConnectedEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(!VelocityPacketAnalyzer.isInjected(player))
|
||||
VelocityPacketAnalyzer.inject(player);
|
||||
if (!VelocityPacketAnalyzer.isInjected(player)) {
|
||||
|
||||
if (!VelocityPacketAnalyzer.inject(player)) {
|
||||
Logger.warning("Attempting delayed injection for " + player.getUsername());
|
||||
server.getScheduler().buildTask(loader, () -> {
|
||||
|
||||
if (!VelocityPacketAnalyzer.inject(player)) {
|
||||
Logger.warning("Second injection for " + player.getUsername() + " failed as well!");
|
||||
player.disconnect(Component.text("Failed to inject player!"));
|
||||
}
|
||||
|
||||
}).delay(1, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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.*;
|
||||
@@ -89,28 +90,30 @@ public class Logger {
|
||||
.append(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED ? "WHITELIST" : "BLACKLIST")
|
||||
.append("\n");
|
||||
|
||||
builder.append("Detected Software-API: ")
|
||||
.append(Reflection.isProxyServer()
|
||||
? Reflection.isPaper() ? "Waterfall" :
|
||||
Reflection.isVelocityServer() ? "Velocity" : "Bungeecord"
|
||||
: Reflection.isFoliaServer() ? "Folia"
|
||||
: Reflection.isPaper() ? "Paper" : "Spigot")
|
||||
.append("\n");
|
||||
builder.append("Detected Software-API: ");
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
builder.append(Reflection.isPaper() ? "Waterfall" : Reflection.isVelocityServer() ? "Velocity" : "Bungeecord");
|
||||
} else {
|
||||
builder.append(Reflection.isFoliaServer() ? "Folia" : Reflection.isPaper() ? "Paper" : "Spigot");
|
||||
}
|
||||
|
||||
builder.append("\n");
|
||||
|
||||
builder.append("Installed plugins: \n ")
|
||||
.append(String.join("\n ", Storage.getLoader().getPluginNames()))
|
||||
.append(String.join("\n ", Storage.getLoader().getPluginNames("%n (%v)")))
|
||||
.append("\n\n");
|
||||
|
||||
builder.append("Detected supported plugins:")
|
||||
.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");
|
||||
}
|
||||
|
||||
@@ -128,7 +131,7 @@ public class Logger {
|
||||
.append("\n");
|
||||
|
||||
builder.append("last-received-sync: ")
|
||||
.append(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ? Storage.LAST_SYNC : "Deactivated")
|
||||
.append(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ? TimeConverter.calcAndGetTime(Storage.LAST_SYNC) : "Deactivated")
|
||||
.append("\n");
|
||||
}
|
||||
|
||||
@@ -142,7 +145,7 @@ public class Logger {
|
||||
.append("\n");
|
||||
|
||||
builder.append("last-sent-sync: ")
|
||||
.append(Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED ? "Deactivated" : (System.currentTimeMillis() - Storage.LAST_SYNC))
|
||||
.append(Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED ? "Deactivated" : (TimeConverter.calcAndGetTime(Storage.LAST_SYNC)))
|
||||
.append("\n\n");
|
||||
|
||||
for (ClientInfo client : Communicator.CLIENTS) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -35,6 +35,12 @@ public class CommandProcess {
|
||||
COMMANDS.add(new RemoveCommand());
|
||||
COMMANDS.add(new ClearCommand());
|
||||
|
||||
COMMANDS.add(new ConvertCommand());
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
COMMANDS.add(new ExtractCommand());
|
||||
}
|
||||
|
||||
COMMANDS.add(new CreateGroupCommand());
|
||||
COMMANDS.add(new DeleteGroupCommand());
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ public class AddCommand extends ProCommand {
|
||||
if (command.isEmpty())
|
||||
return false;
|
||||
|
||||
final boolean loadBlacklist = command.startsWith("plugin=") || command.startsWith("!");
|
||||
final int length = args.length;
|
||||
|
||||
if (length == 1) {
|
||||
@@ -67,6 +68,8 @@ public class AddCommand extends ProCommand {
|
||||
|
||||
if (!exist) {
|
||||
Storage.Blacklist.getBlacklist().add(command).save();
|
||||
if (loadBlacklist) Storage.Blacklist.getBlacklist().load();
|
||||
|
||||
Storage.handleChange();
|
||||
}
|
||||
|
||||
@@ -107,7 +110,9 @@ public class AddCommand extends ProCommand {
|
||||
if (Reflection.isProxyServer())
|
||||
return null;
|
||||
|
||||
return BukkitLoader.getDisallowedCommands();
|
||||
return Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
? BukkitLoader.getDisallowedCommands()
|
||||
: BukkitLoader.getAllowedCommands();
|
||||
}
|
||||
|
||||
String fullString = String.join(" ", args);
|
||||
|
||||
@@ -34,6 +34,7 @@ public class ClearCommand extends ProCommand {
|
||||
}
|
||||
|
||||
Storage.Blacklist.getBlacklist().clear().save();
|
||||
Storage.Blacklist.getBlacklist().load();
|
||||
Storage.handleChange();
|
||||
|
||||
CONFIRMATION.remove(sender.getUniqueId());
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ConvertCommand extends ProCommand {
|
||||
|
||||
public ConvertCommand() {
|
||||
super(
|
||||
"convert",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
|
||||
if (args.length != 1)
|
||||
return false;
|
||||
|
||||
String converterName = args[0];
|
||||
Converter converter = StorageConverter.getConverter(converterName);
|
||||
if (converter == null) {
|
||||
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.CONVERT.INVALID_CONVERTER,
|
||||
"%converter%", converterName)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
converterName = converter.getPluginName();
|
||||
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.CONVERT.SUCCESS,
|
||||
"%converter%", converterName)
|
||||
);
|
||||
|
||||
converter.apply(sender);
|
||||
Storage.reload();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||
return StorageConverter.getConverters().stream().toList();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ExtractCommand extends ProCommand {
|
||||
|
||||
public ExtractCommand() {
|
||||
super(
|
||||
"extract",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
|
||||
if (args.length < 1) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.EXTRACT.USAGE);
|
||||
return true;
|
||||
}
|
||||
|
||||
String pluginName = args[0].toLowerCase();
|
||||
boolean failed = false, useColons = false;
|
||||
Group group = null;
|
||||
|
||||
if (args.length == 2) {
|
||||
|
||||
group = GroupManager.getGroupByName(args[1]);
|
||||
if (group == null) {
|
||||
useColons = Boolean.parseBoolean(args[1]);
|
||||
|
||||
if (!useColons && !args[1].equalsIgnoreCase("false")) {
|
||||
failed = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
useColons = Boolean.parseBoolean(args[1]);
|
||||
} catch (Exception exception) {
|
||||
group = GroupManager.getGroupByName(args[1]);
|
||||
failed = group == null;
|
||||
}
|
||||
|
||||
} else if (args.length == 3) {
|
||||
group = GroupManager.getGroupByName(args[1]);
|
||||
|
||||
if (group == null) {
|
||||
failed = true;
|
||||
} else {
|
||||
try {
|
||||
useColons = Boolean.parseBoolean(args[2]);
|
||||
} catch (Exception exception) {
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (failed) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.EXTRACT.USAGE);
|
||||
return true;
|
||||
}
|
||||
|
||||
List<String> pluginNames = Storage.getLoader().getPluginNames("%n");
|
||||
boolean pluginFound = false;
|
||||
|
||||
for (String name : pluginNames) {
|
||||
if (name.equalsIgnoreCase(pluginName)) {
|
||||
pluginFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pluginFound) {
|
||||
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.EXTRACT.PLUGIN_NOT_FOUND,
|
||||
"%plugin%", pluginName)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
List<String> commands = Storage.getLoader().getPluginCommands(args[0], useColons);
|
||||
|
||||
BlacklistStorage storage = group == null
|
||||
? Storage.Blacklist.getBlacklist()
|
||||
: group.getGeneralGroupBlacklist();
|
||||
|
||||
commands = commands.stream().filter(command -> !storage.isListed(command)).toList();
|
||||
commands.forEach(storage::add);
|
||||
|
||||
storage.save();
|
||||
|
||||
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.EXTRACT.SUCCESS,
|
||||
"%amount%", String.valueOf(commands.size()),
|
||||
"%plugin%", pluginName
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||
final int length = args.length;
|
||||
|
||||
if (length <= 1) {
|
||||
return Storage.getLoader().getPluginNames("%n");
|
||||
}
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
if (length == 2 || length == 3 && GroupManager.getGroupByName(args[1]) != null) {
|
||||
result.add("true");
|
||||
result.add("false");
|
||||
}
|
||||
|
||||
if (length == 2) {
|
||||
result.addAll(GroupManager.getGroupNames());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ public class RemoveCommand extends ProCommand {
|
||||
if (command.isEmpty())
|
||||
return false;
|
||||
|
||||
final boolean loadBlacklist = command.startsWith("plugin=") || command.startsWith("!");
|
||||
final int length = args.length;
|
||||
|
||||
if (length == 1) {
|
||||
@@ -64,6 +65,8 @@ public class RemoveCommand extends ProCommand {
|
||||
|
||||
if (exist) {
|
||||
Storage.Blacklist.getBlacklist().remove(command).save();
|
||||
if (loadBlacklist) Storage.Blacklist.getBlacklist().load();
|
||||
|
||||
Storage.handleChange();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ListCommand extends ProCommand {
|
||||
String message = Storage.ConfigSections.Messages.GROUP.LIST_MESSAGE;
|
||||
message = StringUtils.replace(message,
|
||||
"%group%", groupName,
|
||||
"%size%", String.valueOf(Storage.Blacklist.getBlacklist().getCommands().size()),
|
||||
"%size%", String.valueOf(group.getCommands().size()),
|
||||
"%commands%", commandsListMessage
|
||||
);
|
||||
|
||||
|
||||
+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
|
||||
);
|
||||
|
||||
|
||||
@@ -22,30 +22,8 @@ public class ReloadCommand extends ProCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
boolean proxy = Reflection.isProxyServer();
|
||||
boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !proxy;
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.RELOAD.LOADING);
|
||||
|
||||
ConfigUpdater.initialize();
|
||||
Storage.loadAll(Reflection.isProxyServer() || !backend);
|
||||
|
||||
CustomServerBrand.initialize();
|
||||
GroupManager.clearAllGroups();
|
||||
GroupManager.initialize();
|
||||
|
||||
if (!proxy) {
|
||||
BackendUpdater.stop();
|
||||
BackendUpdater.start();
|
||||
}
|
||||
|
||||
if (!backend) {
|
||||
Storage.handleChange();
|
||||
}
|
||||
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
Storage.getLoader().handleReload();
|
||||
|
||||
Storage.reload();
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.RELOAD.DONE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,15 @@ public class ServAddCommand extends ProCommand {
|
||||
Group group = GroupManager.getGroupByName(groupName);
|
||||
|
||||
if (group == null) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER.replace("%group%", groupName));
|
||||
|
||||
String message = Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%group%", groupName,
|
||||
"%server%", serverName
|
||||
);
|
||||
|
||||
sender.sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.rayzs.pat.plugin.process.impl.server;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
@@ -66,12 +67,14 @@ public class ServClearCommand extends ProCommand {
|
||||
|
||||
if (group == null) {
|
||||
|
||||
sender.sendMessage(
|
||||
Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER
|
||||
.replace("%group%", groupName)
|
||||
.replace("%server%", serverName)
|
||||
String message = Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%group%", groupName,
|
||||
"%server%", serverName
|
||||
);
|
||||
|
||||
sender.sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,12 +95,14 @@ public class ServRemoveCommand extends ProCommand {
|
||||
|
||||
if (group == null) {
|
||||
|
||||
sender.sendMessage(
|
||||
Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER
|
||||
.replace("%group%", groupName)
|
||||
.replace("%server%", serverName)
|
||||
String message = Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%group%", groupName,
|
||||
"%server%", serverName
|
||||
);
|
||||
|
||||
sender.sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ public class ServListCommand extends ProCommand {
|
||||
);
|
||||
|
||||
String message = Storage.ConfigSections.Messages.BLACKLIST.LIST_SERVER_MESSAGE;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%size%", String.valueOf(blacklist.getCommands().size()),
|
||||
"%commands%", commandsListMessage,
|
||||
@@ -57,7 +58,15 @@ public class ServListCommand extends ProCommand {
|
||||
Group group = GroupManager.getGroupByName(groupName);
|
||||
|
||||
if (group == null) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER.replace("%group%", groupName));
|
||||
|
||||
String message = Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%group%", groupName,
|
||||
"%server%", serverName
|
||||
);
|
||||
|
||||
sender.sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,18 @@ 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 {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* RECODE PLANNED
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
private List<String> filteredCommands = null, allCommands = null;
|
||||
private boolean change = false;
|
||||
|
||||
@@ -41,37 +50,41 @@ public class CommandsCache {
|
||||
}
|
||||
|
||||
public void handleCommands(List<String> commands, String server) {
|
||||
if(!isOutdated(commands))
|
||||
if (!isOutdated(commands))
|
||||
return;
|
||||
|
||||
LinkedList<String> tmpFilteredCommands = new LinkedList<>();
|
||||
allCommands = new ArrayList<>(commands);
|
||||
List<String> tmpAllCommands = new ArrayList<>(commands);
|
||||
allCommands = tmpAllCommands;
|
||||
|
||||
for (String command : allCommands) {
|
||||
command = StringUtils.getFirstArg(command);
|
||||
final int length = allCommands.size();
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (i >= tmpAllCommands.size())
|
||||
break;
|
||||
|
||||
String command = StringUtils.getFirstArg(tmpAllCommands.get(i));
|
||||
Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(command);
|
||||
|
||||
if (type != Storage.Blacklist.BlockType.BOTH && type != Storage.Blacklist.BlockType.TAB)
|
||||
continue;
|
||||
|
||||
if (isFilterListAvailable()) {
|
||||
if (filteredCommands.contains(command))
|
||||
if (filteredCommands.contains(command))
|
||||
continue;
|
||||
|
||||
if (!Storage.Blacklist.isBlockedTab(command, server))
|
||||
filteredCommands.add(command);
|
||||
tmpFilteredCommands.add(command);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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 +96,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,28 +24,22 @@ 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());
|
||||
}
|
||||
|
||||
|
||||
public static User getUser(UUID uuid) {
|
||||
|
||||
if (uuid == null) {
|
||||
Logger.warning("Attempted to get LuckPerms user with null UUID!");
|
||||
return null;
|
||||
}
|
||||
|
||||
return PROVIDER.getUserManager().getUser(uuid);
|
||||
}
|
||||
|
||||
@@ -54,13 +50,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 +93,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();
|
||||
}
|
||||
|
||||
|
||||
+6
-16
@@ -81,14 +81,9 @@ public class BukkitConfigurationBuilder implements ConfigurationBuilder {
|
||||
if (result != null)
|
||||
return result;
|
||||
|
||||
if (fileName.equals("config")) {
|
||||
if (!ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart((!path.isBlank() ? path + "." : "") + target);
|
||||
return object;
|
||||
}
|
||||
|
||||
set(path, target, object);
|
||||
return get(path, target);
|
||||
if (fileName.equals("config") && !ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart((!path.isBlank() ? path + "." : "") + target);
|
||||
return object;
|
||||
}
|
||||
|
||||
set(path, target, object);
|
||||
@@ -103,14 +98,9 @@ public class BukkitConfigurationBuilder implements ConfigurationBuilder {
|
||||
if (result != null)
|
||||
return result;
|
||||
|
||||
if (fileName.equals("config")) {
|
||||
if (!ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart(target);
|
||||
return object;
|
||||
}
|
||||
|
||||
set(target, object);
|
||||
return get(target);
|
||||
if (fileName.equals("config") && !ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart(target);
|
||||
return object;
|
||||
}
|
||||
|
||||
set(target, object);
|
||||
|
||||
@@ -88,14 +88,9 @@ public class ProxyConfigurationBuilder implements ConfigurationBuilder {
|
||||
if (result != null)
|
||||
return result;
|
||||
|
||||
if (fileName.equals("config")) {
|
||||
if (!ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart((!path.isBlank() ? path + "." : "") + target);
|
||||
return object;
|
||||
}
|
||||
|
||||
set(path, target, object);
|
||||
return get(path, target);
|
||||
if (fileName.equals("config") && !ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart((!path.isBlank() ? path + "." : "") + target);
|
||||
return object;
|
||||
}
|
||||
|
||||
set(path, target, object);
|
||||
@@ -110,14 +105,9 @@ public class ProxyConfigurationBuilder implements ConfigurationBuilder {
|
||||
if (result != null)
|
||||
return result;
|
||||
|
||||
if (fileName.equals("config")) {
|
||||
if (!ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart(target);
|
||||
return object;
|
||||
}
|
||||
|
||||
set(target, object);
|
||||
return get(target);
|
||||
if (fileName.equals("config") && !ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart(target);
|
||||
return object;
|
||||
}
|
||||
|
||||
set(target, object);
|
||||
|
||||
@@ -101,13 +101,20 @@ public class ConfigUpdater {
|
||||
}
|
||||
|
||||
Logger.warning(" ");
|
||||
Logger.warning("The config.yml is missing a few parts.");
|
||||
Logger.warning("What can be done to solve this issue? There are two options:");
|
||||
Logger.warning("Hey, the config.yml is missing a few parts.");
|
||||
Logger.warning("This most likely happened because PAT added a new feature or message.");
|
||||
Logger.warning(" ");
|
||||
Logger.warning("No worries though! This isn't a bad or dangerous thing.");
|
||||
Logger.warning("You can even ignore or disable this warning entirely by disabling 'announce-missing-parts'.");
|
||||
Logger.warning(" ");
|
||||
Logger.warning("But more importantly. If you want to fill the missing parts,");
|
||||
Logger.warning("then you would have three options on how to do so:");
|
||||
Logger.warning(" ");
|
||||
Logger.warning("Option 1: Delete your current config.yml and restart the server.");
|
||||
Logger.warning("Option 2: Set the missing parts/sections yourself in the config.yml.");
|
||||
Logger.warning("Option 3: Enable 'auto-update-config'. But *please* read the warning message above that option.");
|
||||
Logger.warning(" ");
|
||||
Logger.warning("To simplify that process, a new file with the newest config.yml content has been created as comparison. (plugins/ProAntiTab/comparable-config.yml)");
|
||||
Logger.warning("To simplify this process, a new file with the newest config.yml content has been created as comparison. (plugins/ProAntiTab/comparable-config.yml)");
|
||||
Logger.warning(" ");
|
||||
Logger.warning("Following parts are missing:");
|
||||
|
||||
@@ -116,7 +123,9 @@ public class ConfigUpdater {
|
||||
});
|
||||
|
||||
Logger.warning(" ");
|
||||
Logger.warning("How to read? Check out the newly generated " + HOW_TO_READ_FILE_NAME + " file. ^^");
|
||||
Logger.warning("You don't know how to interpret the missing parts? No worries.");
|
||||
Logger.warning("A new file has been created which explains with examples on how to read and apply the missing parts.");
|
||||
Logger.warning("-> ./plugins/ProAntiTab/" + HOW_TO_READ_FILE_NAME);
|
||||
Logger.warning(" ");
|
||||
}
|
||||
}
|
||||
@@ -108,6 +108,10 @@ public class Group implements Serializable {
|
||||
|
||||
public void add(String command) {
|
||||
this.generalGroupBlacklist.add(command).save();
|
||||
|
||||
if (command.startsWith("plugin=") || command.startsWith("!")) {
|
||||
this.generalGroupBlacklist.load();
|
||||
}
|
||||
}
|
||||
|
||||
public void add(String command, String server) {
|
||||
@@ -118,6 +122,10 @@ public class Group implements Serializable {
|
||||
|
||||
public void remove(String command) {
|
||||
this.generalGroupBlacklist.remove(command).save();
|
||||
|
||||
if (command.startsWith("plugin=") || command.startsWith("!")) {
|
||||
this.generalGroupBlacklist.load();
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(String command, String server) {
|
||||
@@ -128,6 +136,7 @@ public class Group implements Serializable {
|
||||
|
||||
public void clear() {
|
||||
this.generalGroupBlacklist.clear().save();
|
||||
this.generalGroupBlacklist.load();
|
||||
}
|
||||
|
||||
public void clear(String server) {
|
||||
|
||||
@@ -55,30 +55,38 @@ public class GroupManager {
|
||||
return playerGroups;
|
||||
}
|
||||
|
||||
public static boolean canAccessCommand(Object targetObj, String unmodifiedCommand, Storage.Blacklist.BlockType type) {
|
||||
public static AccessResult canAccessCommand(Object targetObj, String unmodifiedCommand, Storage.Blacklist.BlockType type) {
|
||||
return canAccessCommand(targetObj, unmodifiedCommand, type, null);
|
||||
}
|
||||
|
||||
public static boolean canAccessCommand(Object targetObj, String unmodifiedCommand, Storage.Blacklist.BlockType type, String server) {
|
||||
public static AccessResult
|
||||
canAccessCommand(Object targetObj, String unmodifiedCommand, Storage.Blacklist.BlockType type, String server) {
|
||||
final CommandSender sender = CommandSenderHandler.from(targetObj);
|
||||
|
||||
if (sender == null) {
|
||||
Logger.warning("Failed to load player! (GroupManager#62)");
|
||||
return false;
|
||||
Logger.warning("Failed to load player! (GroupManager#66)");
|
||||
return AccessResult.UNKNOWN;
|
||||
}
|
||||
|
||||
final List<Group> playerGroups = sender.getGroups();
|
||||
|
||||
if (playerGroups == null || playerGroups.isEmpty()) {
|
||||
return false;
|
||||
return AccessResult.NO_GROUPS;
|
||||
}
|
||||
|
||||
String command = type.toString() + unmodifiedCommand;
|
||||
|
||||
boolean permitted = false;
|
||||
String command = type.toString() + unmodifiedCommand;
|
||||
String allCommand = type + "*";
|
||||
String negatedCommand = type.toString() + BlockType.NEGATE + unmodifiedCommand;
|
||||
|
||||
boolean all = false,
|
||||
permitted = false,
|
||||
negated = false;
|
||||
|
||||
for (Group group : playerGroups) {
|
||||
|
||||
all = group.contains(allCommand);
|
||||
permitted = group.contains(command);
|
||||
negated = group.contains(negatedCommand);
|
||||
|
||||
if (permitted) {
|
||||
break;
|
||||
@@ -90,21 +98,35 @@ public class GroupManager {
|
||||
|
||||
for (String s : servers) {
|
||||
|
||||
if (group.contains(command, s)) {
|
||||
permitted = true;
|
||||
break;
|
||||
if (!all) {
|
||||
all = group.contains(allCommand, s);
|
||||
}
|
||||
|
||||
if (!permitted) {
|
||||
permitted = group.contains(command, s);
|
||||
}
|
||||
|
||||
if (!negated) {
|
||||
negated = group.contains(negatedCommand, s);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (negated) {
|
||||
return AccessResult.NEGATED;
|
||||
}
|
||||
|
||||
if (all) {
|
||||
return AccessResult.ALLOWED;
|
||||
}
|
||||
|
||||
if (!permitted && type != BlockType.BOTH)
|
||||
return canAccessCommand(targetObj, unmodifiedCommand, Storage.Blacklist.BlockType.BOTH, server);
|
||||
|
||||
return permitted;
|
||||
return permitted ? AccessResult.ALLOWED : AccessResult.NOT_LISTED;
|
||||
}
|
||||
|
||||
public static void setGroup(String groupName, List<String> commands) {
|
||||
@@ -251,4 +273,19 @@ public class GroupManager {
|
||||
public static boolean isGroupRegistered(String groupName) {
|
||||
return getGroupByName(groupName) != null;
|
||||
}
|
||||
|
||||
public enum AccessResult {
|
||||
ALLOWED(true), NEGATED(false),
|
||||
NO_GROUPS(false), NOT_LISTED(false),
|
||||
UNKNOWN(false);
|
||||
|
||||
private final boolean bool;
|
||||
AccessResult(boolean bool) {
|
||||
this.bool = bool;
|
||||
}
|
||||
|
||||
public boolean asBoolean() {
|
||||
return this.bool;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,8 @@ package de.rayzs.pat.utils.permission;
|
||||
import java.util.*;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
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;
|
||||
@@ -23,6 +25,10 @@ public class PermissionUtil {
|
||||
}
|
||||
|
||||
public static void reloadPermissions(UUID uuid) {
|
||||
if (uuid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
resetPermissions(uuid);
|
||||
setPlayerPermissions(uuid);
|
||||
|
||||
@@ -39,10 +45,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 +68,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 +78,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 +118,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 +148,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 +170,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.20
|
||||
version: 2.2.0
|
||||
main: de.rayzs.pat.plugin.BungeeLoader
|
||||
|
||||
softDepends: [LuckPerms, PAPIProxyBridge]
|
||||
@@ -65,16 +65,25 @@ turn-blacklist-to-whitelist: true
|
||||
base-command-case-sensitive: true
|
||||
|
||||
# (!) Warning:
|
||||
# Enabling this could lead to performance issues if many players
|
||||
# change worlds frequently in short amount of time.
|
||||
# Enabling this could lead to performance issues depending on
|
||||
# the amount of players and commands. (> 1100)
|
||||
#
|
||||
# This decides whether PAT updates the commands for a player after changing worlds.
|
||||
# This allows PAT groups to block commands, which have been allowed
|
||||
# inside the global section. This can be achieved by negating commands
|
||||
# inside a PAT group.
|
||||
allow-group-overruling: false
|
||||
|
||||
# (!) Warning:
|
||||
# Enabling this could lead to performance issues if many players
|
||||
# change worlds frequently in a short amount of time.
|
||||
#
|
||||
# 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!
|
||||
@@ -178,6 +187,9 @@ custom-version:
|
||||
# You can bypass this restriction with the proantitab.namespace permission.
|
||||
block-namespace-commands:
|
||||
enabled: false
|
||||
# Basically blocks the command execution no matter if
|
||||
# 'cancel-blocked-commands' is enabled or not.
|
||||
always-block-command: true
|
||||
|
||||
#>> HTP (Overwritten)
|
||||
# Auto lowercase all commands when being executed,
|
||||
@@ -271,6 +283,15 @@ perms-check:
|
||||
player-is-missing: "&cPlease specify the player whose permission you want to check."
|
||||
player-not-online: "&c%player% is not online!"
|
||||
|
||||
extract:
|
||||
usage: '&7Usage: &f/pat extract [plugin] <use-colon> &7or &f<group> <use-colon>'
|
||||
plugin-not-found: '&cPlugin %plugin% not found!'
|
||||
success: '&aSuccessfully extracted &e%amount% &anew commands from %plugin%!'
|
||||
|
||||
convert:
|
||||
converter-not-found: '&cConverter or necessary files could not be found!'
|
||||
success: '&aSuccessfully converted &e%converter% &ainto the PAT storage.yml!'
|
||||
|
||||
help:
|
||||
- '&7Available commands are: &f/%label%&7... &8[&fBUKKIT&8]'
|
||||
- '&7Format: &8<optional> (required)'
|
||||
@@ -280,6 +301,8 @@ help:
|
||||
- '&f postdebug &7to post the PAT logs'
|
||||
- '&f update <player> &7to update player(s) permissions'
|
||||
- "&f perms <player> &7to check a player's permissions"
|
||||
- "&f extract (plugin) &7to extract all plugin commands"
|
||||
- "&f convert (plugin) &7converts into a PAT storage.yml"
|
||||
- '&f add/rem (command) &8<group> &7to manage the list'
|
||||
- '&f clear &8<group> &7to clear the list'
|
||||
- '&f creategroup (group) &7to create a group'
|
||||
|
||||
@@ -32,7 +32,6 @@ updater:
|
||||
# In other words, the backend servers won't receive any updates from the proxy about the storage.yml.
|
||||
# It's here to prevent any unnecessary communication between the proxy and the backend servers, if PAT is being used on the proxy alone.
|
||||
# For why this can be the case, read the following: https://github.com/RayzsYT/ProAntiTab/wiki/FAQ#can-i-install-pat-just-on-my-proxy-server
|
||||
# It is NOT recommended to enable this option, unless you know what you are doing.
|
||||
disable-sync: false
|
||||
|
||||
# This is a very necessary feature if you have way too many commands to block and instead decide
|
||||
@@ -48,6 +47,15 @@ turn-blacklist-to-whitelist: true
|
||||
# /HelP --> Allowed
|
||||
base-command-case-sensitive: true
|
||||
|
||||
# (!) Warning:
|
||||
# Enabling this could lead to performance issues depending on
|
||||
# the amount of players and commands. (> 1100)
|
||||
#
|
||||
# This allows PAT groups to block commands, which have been allowed
|
||||
# inside the global section. This can be achieved by negating commands
|
||||
# inside a PAT group.
|
||||
allow-group-overruling: false
|
||||
|
||||
# Here you can customize the server version that is displayed on a ping. (The text at the player-count)
|
||||
custom-protocol-ping:
|
||||
enabled: true
|
||||
@@ -145,6 +153,9 @@ custom-version:
|
||||
# You can bypass this restriction with the proantitab.namespace permission.
|
||||
block-namespace-commands:
|
||||
enabled: false
|
||||
# Basically blocks the command execution no matter if
|
||||
# 'cancel-blocked-commands' is enabled or not.
|
||||
always-block-command: true
|
||||
|
||||
# Patches a small exploit which causes the server to lag.
|
||||
# Due to the fact that PAT interacts directly with Tab-Completions and their packets,
|
||||
@@ -236,6 +247,10 @@ perms-check:
|
||||
player-is-missing: "&cPlease specify the player whose permission you want to check."
|
||||
player-not-online: "&c%player% is not online!"
|
||||
|
||||
convert:
|
||||
converter-not-found: '&cConverter or necessary files could not be found!'
|
||||
success: '&aSuccessfully converted &e%converter% &ainto the PAT storage.yml!'
|
||||
|
||||
help:
|
||||
- '&7Available commands are: &f/%label%&7... &8[&fPROXY&8]'
|
||||
- '&7Format: &8<optional> (required)'
|
||||
@@ -245,6 +260,7 @@ help:
|
||||
- '&f postdebug &7to post the PAT logs'
|
||||
- '&f update <player> &7to update player(s) permissions'
|
||||
- "&f perms <player> &7to check a player's permissions"
|
||||
- "&f convert (plugin) &7converts into a PAT storage.yml"
|
||||
- '&f add/rem (command) &8<group> &7to manage the list'
|
||||
- '&f clear &8<group> &7to clear the list'
|
||||
- '&f creategroup (group) &7to create a group'
|
||||
|
||||
@@ -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.20
|
||||
version: 2.2.0
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
main: de.rayzs.pat.plugin.BukkitLoader
|
||||
|
||||
Reference in new issue
Block a user