mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-15 05:22:01 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e63836bd11 | ||
|
|
1afd93d296 | ||
|
|
cb44ae50ff | ||
|
|
6ce5c8caaf | ||
|
|
d5b53aecfa | ||
|
|
cc1bb4ec34 | ||
|
|
be9027fa82 | ||
|
|
247b3a1ffd | ||
|
|
356454c66d | ||
|
|
c11cb20917 | ||
|
|
84a7fbafae | ||
|
|
f5acc445e7 | ||
|
|
38142da87e | ||
|
|
4ea2f5cb33 | ||
|
|
8001e5aa8d | ||
|
|
5b4c45dbcc | ||
|
|
fa62e0fae6 | ||
|
|
06e0030f63 | ||
|
|
8441481d10 | ||
|
|
6782635202 | ||
|
|
d061b8967b | ||
|
|
4881fa3c66 | ||
|
|
8e8643bf06 | ||
|
|
18ee04a979 | ||
|
|
0394aaedf4 | ||
|
|
3c62d3c1b9 | ||
|
|
94eff2bf6d | ||
|
|
1f7e6cd77a | ||
|
|
34cba027f9 | ||
|
|
db42fc1295 | ||
|
|
5270a432e9 | ||
|
|
ab052d62b5 | ||
|
|
a878944b33 | ||
|
|
cb349e8abb |
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>de.rayzs.pat</groupId>
|
||||
<artifactId>ProAntiTab</artifactId>
|
||||
<version>1.8.3</version>
|
||||
<version>1.9.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
||||
@@ -5,6 +5,8 @@ import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import de.rayzs.pat.utils.scheduler.PATSchedulerTask;
|
||||
import io.netty.channel.Channel;
|
||||
import de.rayzs.pat.api.brand.*;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -19,7 +21,7 @@ public class BukkitServerBrand implements ServerBrand {
|
||||
private static final List<Player> MODIFIED_BRAND_PLAYERS = new ArrayList<>();
|
||||
private static final Server SERVER = Bukkit.getServer();
|
||||
private static String BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0);
|
||||
private static int TASK = -1;
|
||||
private static PATSchedulerTask TASK;
|
||||
private static boolean INITIALIZED = false;
|
||||
private static Class<?> brandPayloadClass, clientBoundCustomPacketPayloadPacketClass, customPacketPayloadPacketClass;
|
||||
|
||||
@@ -48,9 +50,9 @@ public class BukkitServerBrand implements ServerBrand {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
if(TASK != -1) {
|
||||
Bukkit.getScheduler().cancelTask(TASK);
|
||||
TASK = -1;
|
||||
if(TASK != null && TASK.isActive()) {
|
||||
TASK.cancelTask();
|
||||
TASK = null;
|
||||
MODIFIED_BRAND_PLAYERS.clear();
|
||||
}
|
||||
|
||||
@@ -58,12 +60,13 @@ public class BukkitServerBrand implements ServerBrand {
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0) + "§r";
|
||||
TASK = Bukkit.getScheduler().scheduleAsyncRepeatingTask(BukkitLoader.getPlugin(), () -> {
|
||||
|
||||
PATScheduler.createAsyncScheduler(() -> {
|
||||
Bukkit.getOnlinePlayers().forEach(this::send);
|
||||
}, 1, Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY);
|
||||
} else {
|
||||
AtomicInteger animationState = new AtomicInteger(0);
|
||||
TASK = Bukkit.getScheduler().scheduleAsyncRepeatingTask(BukkitLoader.getPlugin(), () -> {
|
||||
TASK = PATScheduler.createAsyncScheduler(() -> {
|
||||
if (animationState.getAndIncrement() >= Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().size() - 1)
|
||||
animationState.set(0);
|
||||
BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(animationState.get()) + "§r";
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.rayzs.pat.api.netty.bukkit.handlers;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
@@ -8,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import java.lang.reflect.Field;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
|
||||
@@ -69,7 +72,13 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
newResultList.add(s);
|
||||
}
|
||||
} else {
|
||||
if(!cancelsBeforeHand) newResultList.addAll(Arrays.asList(tR));
|
||||
if(!cancelsBeforeHand) {
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), input, Arrays.asList(tR));
|
||||
if(!filteredTabCompletionEvent.isCancelled()) {
|
||||
List<String> suggestions = Arrays.stream(tR).filter(s -> filteredTabCompletionEvent.getCompletion().contains(s)).collect(Collectors.toList());
|
||||
newResultList.addAll(suggestions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
field.set(packetObj, newResultList.toArray(new String[0]));
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(input);
|
||||
}
|
||||
|
||||
if(is121Packet || Reflection.isPaper() && packetObj.getClass().getSimpleName().equals("PacketPlayOutTabComplete")) {
|
||||
if(is121Packet || Reflection.isFoliaServer() && packetObj.getClass().getSimpleName().equals("PacketPlayOutTabComplete")) {
|
||||
try {
|
||||
Field suggestionsField = Reflection.getFieldsByTypeNormal(packetObj.getClass(), "List", Reflection.SearchOption.ENDS).get(0);
|
||||
List<?> suggestionsTmp = (List<?>) suggestionsField.get(packetObj),
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package de.rayzs.pat.api.netty.proxy;
|
||||
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.proxy.crypto.SignedChatCommand;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.session.UnsignedPlayerCommandPacket;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.plugin.listeners.velocity.VelocityBlockCommandListener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
@@ -136,8 +140,9 @@ public class VelocityPacketAnalyzer {
|
||||
}
|
||||
|
||||
if(packet instanceof UnsignedPlayerCommandPacket) {
|
||||
|
||||
UnsignedPlayerCommandPacket unsignedPlayerCommandPacket = (UnsignedPlayerCommandPacket) packet;
|
||||
if(!VelocityBlockCommandListener.handleCommand(player, unsignedPlayerCommandPacket.getCommand()))
|
||||
if(VelocityBlockCommandListener.handleCommand(player, unsignedPlayerCommandPacket.getCommand()))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -209,6 +214,12 @@ public class VelocityPacketAnalyzer {
|
||||
});
|
||||
} else {
|
||||
if (cancelsBeforeHand) return;
|
||||
List<String> suggestionsAsString = new ArrayList<>();
|
||||
response.getOffers().forEach(offer -> suggestionsAsString.add(offer.getText()));
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), cursor, suggestionsAsString);
|
||||
if(filteredTabCompletionEvent.isCancelled()) return;
|
||||
response.getOffers().removeIf(offer -> !filteredTabCompletionEvent.getCompletion().contains(offer.getText()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ public class Storage {
|
||||
CONFIGURATION = Configurator.get("config"),
|
||||
STORAGE = Configurator.get("storage"),
|
||||
PLACEHOLDERS = Configurator.get("placeholders"),
|
||||
CUSTOM_RESPONSES = Configurator.get("custom-responses"),
|
||||
TOKEN = Configurator.get("token");
|
||||
|
||||
public static void initialize() {}
|
||||
@@ -189,7 +190,7 @@ public class Storage {
|
||||
|
||||
public static class Blacklist {
|
||||
|
||||
private static HashMap<String, GeneralBlacklist> SERVER_BLACKLISTS = new HashMap<>();
|
||||
private static final HashMap<String, GeneralBlacklist> SERVER_BLACKLISTS = new HashMap<>();
|
||||
private static final GeneralBlacklist BLACKLIST = BlacklistCreator.createGeneralBlacklist();
|
||||
private static final IgnoredServersStorage IGNORED_SERVERS = new GeneralIgnoredServers();
|
||||
private static final ExpireCache<String, List<GeneralBlacklist>> CACHED_SERVER_BLACKLIST = new ExpireCache<>(1, TimeUnit.HOURS);
|
||||
@@ -342,13 +343,22 @@ public class Storage {
|
||||
}
|
||||
|
||||
public static boolean isListed(Object playerObj, String command, boolean intensive, boolean listed, boolean slash, String server) {
|
||||
return isListed(playerObj, command, intensive, listed, slash, server, false);
|
||||
}
|
||||
|
||||
public static boolean isListed(Object playerObj, String command, boolean intensive, boolean listed, boolean slash, String server, boolean instantReturn) {
|
||||
if(GroupManager.getGroupsByServer(server).stream().anyMatch(group -> isInListed(command, group.getAllCommands(server), intensive) && group.hasPermission(playerObj)))
|
||||
return false;
|
||||
|
||||
if(!listed) for (GeneralBlacklist blacklist : getBlacklists(server)) {
|
||||
if(listed) return true;
|
||||
|
||||
for (GeneralBlacklist blacklist : getBlacklists(server)) {
|
||||
listed = blacklist.isListed(command, intensive, true, slash);
|
||||
if(instantReturn) return listed;
|
||||
|
||||
if(listed) break;
|
||||
}
|
||||
|
||||
return listed;
|
||||
}
|
||||
|
||||
@@ -371,18 +381,26 @@ public class Storage {
|
||||
if(focusOnBlock && blockedGlobal) return true;
|
||||
|
||||
for (GeneralBlacklist blacklist : getBlacklists(server)) {
|
||||
if(!focusOnBlock) {
|
||||
blockedServer = blacklist.isBlockedIgnorePermission(command, intensive);
|
||||
if (blockedServer) break;
|
||||
} else {
|
||||
if(blacklist.isBlocked(command, intensive)) return true;
|
||||
if(focusOnBlock && blacklist.isBlocked(command, intensive))
|
||||
return true;
|
||||
|
||||
blockedServer = blacklist.isBlockedIgnorePermission(command, intensive);
|
||||
break;
|
||||
|
||||
/* Former code
|
||||
if (!blacklist.isBlockedIgnorePermission(command, intensive)) {
|
||||
blockedServer = false;
|
||||
break;
|
||||
}
|
||||
|
||||
blockedServer = true;
|
||||
*/
|
||||
}
|
||||
|
||||
blocked = turn ? blockedGlobal && blockedServer : blockedServer || blockedGlobal;
|
||||
if(!blocked
|
||||
&& CACHED_SERVER_BLACKLIST.contains(server)
|
||||
&& CACHED_SERVER_BLACKLIST.get(server).size() == 0)
|
||||
&& CACHED_SERVER_BLACKLIST.get(server).isEmpty())
|
||||
if(turn) blocked = true;
|
||||
|
||||
return blocked;
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.Collections;
|
||||
public class CancelCommandSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
public MultipleMessagesHelper MESSAGE;
|
||||
public MultipleMessagesHelper BASE_COMMAND_RESPONSE, SUB_COMMAND_RESPONSE;
|
||||
|
||||
public CancelCommandSection() {
|
||||
super("cancel-blocked-commands");
|
||||
@@ -17,6 +17,7 @@ public class CancelCommandSection extends ConfigStorage {
|
||||
public void load() {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
MESSAGE = new MultipleMessagesHelper(this, "message", Collections.singletonList("&cThe command %command% is blocked!"));
|
||||
BASE_COMMAND_RESPONSE = new MultipleMessagesHelper(this, "base-command-message", Collections.singletonList("&cThe command %command% is blocked!"));
|
||||
SUB_COMMAND_RESPONSE = new MultipleMessagesHelper(this, "sub-command-message", Collections.singletonList("&cThis sub-argument is blocked!"));
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BlockedBaseCommandPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public BlockedBaseCommandPlaceholder() { super("message_base_blocked"); }
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
return StringUtils.buildStringList(Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE.getLines());
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,16 +1,16 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BlockedCommandPlaceholder extends PlaceholderStorage {
|
||||
public class BlockedSubCommandPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public BlockedCommandPlaceholder() { super("message_blocked"); }
|
||||
public BlockedSubCommandPlaceholder() { super("message_sub_blocked"); }
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
return StringUtils.buildStringList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE.getLines());
|
||||
return StringUtils.buildStringList(Storage.ConfigSections.Settings.CANCEL_COMMAND.SUB_COMMAND_RESPONSE.getLines());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.rayzs.pat.plugin;
|
||||
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
@@ -41,6 +42,7 @@ public class BukkitLoader extends JavaPlugin {
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\bukkit-config.yml", "config.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\bukkit-storage.yml", "storage.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\bukkit-placeholders.yml", "placeholders.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\bukkit-custom-responses.yml", "custom-responses.yml", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,9 +99,10 @@ public class BukkitLoader extends JavaPlugin {
|
||||
ViaVersionAdapter.initialize();
|
||||
|
||||
if(Storage.USE_SIMPLECLOUD)
|
||||
Logger.warning("Detected SimpleCloud and therefore MiniMessages by Kyori are disabled!");
|
||||
Logger.warning("Detected SimpleCloud. Therefore, MiniMessages are disabled!");
|
||||
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
SubArgsModule.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,7 +196,7 @@ public class BukkitLoader extends JavaPlugin {
|
||||
Storage.Blacklist.getBlacklist().setList(new ArrayList<>());
|
||||
|
||||
else if (!ArrayUtils.compareStringArrays(Storage.Blacklist.getBlacklist().getCommands(), commandsPacket.getCommands())) {
|
||||
BukkitAntiTabListener.setChangeStatus();
|
||||
if(Reflection.getMinor() >= 13) BukkitAntiTabListener.setChangeStatus();
|
||||
Storage.Blacklist.getBlacklist().setList(commandsPacket.getCommands());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package de.rayzs.pat.plugin;
|
||||
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.utils.configuration.Configurator;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||
import de.rayzs.pat.plugin.commands.BungeeCommand;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
@@ -33,6 +36,7 @@ public class BungeeLoader extends Plugin {
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\proxy-config.yml", "config.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\proxy-storage.yml", "storage.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\proxy-placeholders.yml", "placeholders.yml", false);
|
||||
Configurator.createResourcedFile(getDataFolder(), "files\\proxy-custom-responses.yml", "custom-responses.yml", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,6 +87,7 @@ public class BungeeLoader extends Plugin {
|
||||
|
||||
BungeePacketAnalyzer.injectAll();
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
SubArgsModule.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,6 +159,19 @@ public class BungeeLoader extends Plugin {
|
||||
}, 20L, Storage.ConfigSections.Settings.UPDATE.PERIOD, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public static String getServerNameByPlayerUUID(UUID uuid) {
|
||||
ProxiedPlayer proxiedPlayer = ProxyServer.getInstance().getPlayer(uuid);
|
||||
if(proxiedPlayer == null) return null;
|
||||
|
||||
Server server = proxiedPlayer.getServer();
|
||||
if(server == null) return null;
|
||||
|
||||
ServerInfo serverInfo = server.getInfo();
|
||||
if(serverInfo == null) return null;
|
||||
|
||||
return serverInfo.getName();
|
||||
}
|
||||
|
||||
public static Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package de.rayzs.pat.plugin;
|
||||
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.VersionComparer;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.plugin.metrics.impl.VelocityMetrics;
|
||||
@@ -28,7 +30,7 @@ import java.util.*;
|
||||
|
||||
@Plugin(name = "ProAntiTab",
|
||||
id = "proantitab",
|
||||
version = "1.8.3",
|
||||
version = "1.9.0",
|
||||
authors = "Rayzs_YT",
|
||||
description = "Hide more than just your plugins. Hide almost everything!",
|
||||
dependencies = {
|
||||
@@ -59,6 +61,7 @@ public class VelocityLoader {
|
||||
Configurator.createResourcedFile("./plugins/ProAntiTab", "files\\proxy-config.yml", "config.yml", false);
|
||||
Configurator.createResourcedFile("./plugins/ProAntiTab", "files\\proxy-storage.yml", "storage.yml", false);
|
||||
Configurator.createResourcedFile("./plugins/ProAntiTab", "files\\proxy-placeholders.yml", "placeholders.yml", false);
|
||||
Configurator.createResourcedFile("./plugins/ProAntiTab", "files\\proxy-custom-responses.yml", "custom-responses.yml", false);
|
||||
|
||||
Reflection.initialize(server);
|
||||
ConfigUpdater.initialize();
|
||||
@@ -98,6 +101,7 @@ public class VelocityLoader {
|
||||
Logger.warning("Detected SimpleCloud and therefore MiniMessages by Kyori are disabled!");
|
||||
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
SubArgsModule.initialize();
|
||||
}
|
||||
|
||||
public static void delayedPermissionsReload() {
|
||||
@@ -165,6 +169,20 @@ public class VelocityLoader {
|
||||
}).delay(1, TimeUnit.SECONDS).repeat(Storage.ConfigSections.Settings.UPDATE.PERIOD, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
|
||||
public static String getServerNameByPlayerUUID(UUID uuid) {
|
||||
Optional<Player> optPlayer = server.getPlayer(uuid);
|
||||
if(!optPlayer.isPresent()) return null;
|
||||
|
||||
Player player = optPlayer.get();
|
||||
Optional<ServerConnection> optServer = player.getCurrentServer();
|
||||
if(!optServer.isPresent()) return null;
|
||||
|
||||
ServerConnection server = optServer.get();
|
||||
if(server.getServerInfo() == null) return null;
|
||||
|
||||
return server.getServerInfo().getName();
|
||||
}
|
||||
|
||||
public static ProxyServer getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
}
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED || Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED || rawCommand.equals("/")) return;
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE, "%command%", command);
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE, "%command%", command);
|
||||
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED) return;
|
||||
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE, "%command%", command);
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE, "%command%", command);
|
||||
|
||||
boolean listed, serverListed, ignored;
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
@@ -84,7 +84,7 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
}
|
||||
|
||||
listed = Storage.Blacklist.isListed(command, false, true, false);
|
||||
serverListed = Storage.Blacklist.isListed(player, command, false, listed, false, serverName);
|
||||
serverListed = Storage.Blacklist.isListed(player, command, false, listed, false, serverName, true);
|
||||
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
|
||||
|
||||
if(ignored ? !listed && serverListed : serverListed) {
|
||||
|
||||
+24
-20
@@ -68,7 +68,7 @@ public class VelocityBlockCommandListener {
|
||||
}
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED) return;
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE, "%command%", command.replaceFirst("/", ""));
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE, "%command%", command.replaceFirst("/", ""));
|
||||
|
||||
boolean listed, serverListed, ignored;
|
||||
|
||||
@@ -152,14 +152,13 @@ public class VelocityBlockCommandListener {
|
||||
command = StringUtils.getFirstArg(command);
|
||||
command = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command, false)) return true;
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command, false)) return false;
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Messages.NOTIFICATION.ALERT, "%player%", player.getUsername(), "%command%", command, "%server%", serverName);
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
|
||||
if (executeCommandEvent.isBlocked()) blocked = true;
|
||||
if (executeCommandEvent.isCancelled()) return true;
|
||||
if (executeCommandEvent.isCancelled()) return false;
|
||||
|
||||
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE, "%command%", command.replaceFirst("/", ""));
|
||||
|
||||
@@ -167,13 +166,13 @@ public class VelocityBlockCommandListener {
|
||||
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
|
||||
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> VelocityLoader.getServer().getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(VelocityLoader.getServer().getPlayer(uuid).get(), notificationMessage));
|
||||
|
||||
return !blocked;
|
||||
return blocked;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
|
||||
if (executeCommandEvent.isBlocked()) blocked = true;
|
||||
if (executeCommandEvent.isCancelled()) return true;
|
||||
if (executeCommandEvent.isCancelled()) return false;
|
||||
|
||||
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE, "%command%", command.replaceFirst("/", ""));
|
||||
|
||||
@@ -181,41 +180,46 @@ public class VelocityBlockCommandListener {
|
||||
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
|
||||
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> VelocityLoader.getServer().getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(VelocityLoader.getServer().getPlayer(uuid).get(), notificationMessage));
|
||||
|
||||
return !blocked;
|
||||
return blocked;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED) return true;
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE, "%command%", command.replaceFirst("/", ""));
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED) return false;
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE, "%command%", command.replaceFirst("/", ""));
|
||||
boolean listed, serverListed, ignored;
|
||||
|
||||
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
|
||||
if (Storage.Blacklist.doesGroupBypass(player, command, false, true, false, player.getCurrentServer().get().getServerInfo().getName())) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
|
||||
return !executeCommandEvent.isBlocked();
|
||||
return executeCommandEvent.isBlocked();
|
||||
}
|
||||
|
||||
listed = Storage.Blacklist.isListed(command, false, true, false);
|
||||
serverListed = Storage.Blacklist.isListed(player, command, false, listed, false, serverName);
|
||||
serverListed = Storage.Blacklist.isListed(player, command, false, listed, false, serverName, true);
|
||||
ignored = Storage.Blacklist.isOnIgnoredServer(serverName);
|
||||
|
||||
if (ignored ? !listed && serverListed : serverListed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
|
||||
return !executeCommandEvent.isBlocked();
|
||||
return executeCommandEvent.isBlocked();
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
|
||||
|
||||
if (executeCommandEvent.isBlocked()) blocked = true;
|
||||
if (executeCommandEvent.isCancelled()) return true;
|
||||
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
return !blocked;
|
||||
return blocked;
|
||||
}
|
||||
|
||||
System.out.println(4);
|
||||
|
||||
|
||||
|
||||
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && !Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
|
||||
if (executeCommandEvent.isBlocked()) blocked = true;
|
||||
if (executeCommandEvent.isCancelled()) return true;
|
||||
if (executeCommandEvent.isCancelled()) return false;
|
||||
|
||||
MessageTranslator.send(player, cancelCommandMessage);
|
||||
|
||||
@@ -223,12 +227,12 @@ public class VelocityBlockCommandListener {
|
||||
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
|
||||
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> VelocityLoader.getServer().getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(VelocityLoader.getServer().getPlayer(uuid).get(), notificationMessage));
|
||||
|
||||
return !blocked;
|
||||
return blocked;
|
||||
}
|
||||
|
||||
if (Storage.Blacklist.doesGroupBypass(player, command, true, true, false, player.getCurrentServer().get().getServerInfo().getName())) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
|
||||
return !executeCommandEvent.isBlocked();
|
||||
return executeCommandEvent.isBlocked();
|
||||
}
|
||||
|
||||
listed = Storage.Blacklist.isListed(command, true, true, false);
|
||||
@@ -237,12 +241,12 @@ public class VelocityBlockCommandListener {
|
||||
|
||||
if (!listed && !serverListed || listed && serverListed && ignored) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
|
||||
return !executeCommandEvent.isBlocked();
|
||||
return executeCommandEvent.isBlocked();
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player.getUniqueId())) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, false);
|
||||
return !executeCommandEvent.isBlocked();
|
||||
return executeCommandEvent.isBlocked();
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
|
||||
@@ -254,6 +258,6 @@ public class VelocityBlockCommandListener {
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
|
||||
Storage.NOTIFY_PLAYERS.stream().filter(uuid -> VelocityLoader.getServer().getPlayer(uuid).isPresent()).forEach(uuid -> MessageTranslator.send(VelocityLoader.getServer().getPlayer(uuid).get(), notificationMessage));
|
||||
return !blocked;
|
||||
return blocked;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package de.rayzs.pat.plugin.modules.subargs;
|
||||
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.plugin.modules.subargs.events.*;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.subargs.*;
|
||||
import java.util.stream.Collectors;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import de.rayzs.pat.plugin.*;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SubArgsModule {
|
||||
|
||||
public static List<String> GENERAL_LIST, BLOCKED_MESSAGE, PLAYER_NAMES;
|
||||
public static HashMap<UUID, Argument> PLAYER_COMMANDS = new HashMap<>();
|
||||
|
||||
public static void initialize() {
|
||||
updateList();
|
||||
updateMessages();
|
||||
updatePlayerNames();
|
||||
|
||||
PATEventHandler.register(new TabCompletion());
|
||||
PATEventHandler.register(new ExecuteCommand());
|
||||
|
||||
PATEventHandler.register(UpdateList.UPDATE_PLUGIN_EVENT);
|
||||
PATEventHandler.register(UpdateList.RECEIVE_SYNC_EVENT);
|
||||
PATEventHandler.register(UpdateList.UPDATE_PLAYER_COMMANDS_EVENT);
|
||||
PATEventHandler.register(UpdateList.SERVER_PLAYERS_CHANGE_EVENT);
|
||||
}
|
||||
|
||||
public static void updatePlayerNames() {
|
||||
PLAYER_NAMES = Reflection.isProxyServer()
|
||||
? Reflection.isVelocityServer()
|
||||
? VelocityLoader.getPlayerNames()
|
||||
: BungeeLoader.getPlayerNames()
|
||||
: BukkitLoader.getPlayerNames();
|
||||
}
|
||||
|
||||
public static List<String> getPlayerNames() {
|
||||
return PLAYER_NAMES;
|
||||
}
|
||||
|
||||
public static void updateList() {
|
||||
GENERAL_LIST = Storage.Blacklist.getBlacklist().getCommands().stream().filter(command -> command.contains(" ")).collect(Collectors.toList());
|
||||
|
||||
Argument.clearArguments();
|
||||
GENERAL_LIST.forEach(Argument::buildArguments);
|
||||
SubArgsModule.PLAYER_COMMANDS = new HashMap<>();
|
||||
}
|
||||
|
||||
public static void updateMessages() {
|
||||
Storage.Files.CUSTOM_RESPONSES.reload();
|
||||
Responses.update();
|
||||
}
|
||||
|
||||
public static List<String> getServerCommands(UUID uuid) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
if(!Reflection.isProxyServer()) return commands;
|
||||
|
||||
String serverName = Reflection.isVelocityServer() ? VelocityLoader.getServerNameByPlayerUUID(uuid) : BungeeLoader.getServerNameByPlayerUUID(uuid);
|
||||
if(serverName == null) return commands;
|
||||
|
||||
List<GeneralBlacklist> blacklists = Storage.Blacklist.getBlacklists(serverName);
|
||||
for (GeneralBlacklist blacklist : blacklists)
|
||||
commands.addAll(blacklist.getCommands());
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
public static List<String> getGroupCommands(UUID uuid) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
List<Group> groups = new ArrayList<>();
|
||||
|
||||
Group currentGroup;
|
||||
for (String permission : Objects.requireNonNull(PermissionUtil.getPermissions(uuid))) {
|
||||
if(!permission.startsWith("proantitab.group.")) continue;
|
||||
currentGroup = GroupManager.getGroupByName(StringUtils.replaceFirst(permission, "proantitab.group.", ""));
|
||||
if(currentGroup != null && !groups.contains(currentGroup)) groups.add(currentGroup);
|
||||
}
|
||||
|
||||
if(!groups.isEmpty()) {
|
||||
int highestPriority = groups.stream().mapToInt(Group::getPriority).filter(group -> group <= 9999).min().orElse(9999);
|
||||
groups.removeIf(group -> group.getPriority() > highestPriority);
|
||||
for (Group group : groups) commands.addAll(group.getCommands().stream().filter(command -> command.contains(" ")).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
return commands;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package de.rayzs.pat.plugin.modules.subargs.events;
|
||||
|
||||
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.subargs.*;
|
||||
import de.rayzs.pat.utils.*;
|
||||
|
||||
public class ExecuteCommand extends ExecuteCommandEvent {
|
||||
|
||||
@Override
|
||||
public void handle(ExecuteCommandEvent event) {
|
||||
String command = StringUtils.replaceFirst(event.getCommand(), "/", "");
|
||||
|
||||
if(PermissionUtil.hasBypassPermission(event.getSenderObj(), command.contains(" ") ? command.split(" ")[0] : command))
|
||||
return;
|
||||
|
||||
if(command.contains(" ") && shouldCommandBeBlocked(event, command)) {
|
||||
event.setBlocked(true);
|
||||
event.setCancelled(true);
|
||||
MessageTranslator.send(event.getSenderObj(), Responses.getResponse(event.getCommand()), "%command%", event.getCommand());
|
||||
return;
|
||||
}
|
||||
|
||||
if(!event.isBlocked()) return;
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
MessageTranslator.send(event.getSenderObj(), Responses.getResponse(event.getCommand(), Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE.getLines()), "%command%", event.getCommand());
|
||||
}
|
||||
|
||||
private boolean shouldCommandBeBlocked(ExecuteCommandEvent event, String command) {
|
||||
CommandSender sender = new CommandSender(event.getSenderObj());
|
||||
boolean listed = false,
|
||||
turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED,
|
||||
blocked = event.isBlocked(),
|
||||
ignored = false,
|
||||
useFilter = false,
|
||||
tooBig = false;
|
||||
|
||||
String[] split, originCommandSplit, copiedOriginCommandSplit;
|
||||
String tmpCommand;
|
||||
for (String s : SubArgsModule.PLAYER_COMMANDS.getOrDefault(sender.getUniqueId(), Argument.getGeneralArgument()).getInputs()) {
|
||||
if(s.contains("%hidden_online_players%")) continue;
|
||||
tmpCommand = command;
|
||||
|
||||
if(s.split(" ")[0].equalsIgnoreCase(tmpCommand.split(" ")[0]))
|
||||
useFilter = true;
|
||||
|
||||
originCommandSplit = tmpCommand.split(" ");
|
||||
split = s.split(" ");
|
||||
int i;
|
||||
|
||||
for(i = 0; i < split.length; i++) {
|
||||
if(!split[i].equals("%online_players%")) continue;
|
||||
|
||||
boolean foundPlayer = false;
|
||||
for (String playerName : SubArgsModule.getPlayerNames()) {
|
||||
if(i >= originCommandSplit.length) continue;
|
||||
if(!playerName.equalsIgnoreCase(originCommandSplit[i])) continue;
|
||||
|
||||
foundPlayer = true;
|
||||
originCommandSplit[i] = "%online_players%";
|
||||
break;
|
||||
}
|
||||
|
||||
if(!foundPlayer) {
|
||||
|
||||
copiedOriginCommandSplit = originCommandSplit.clone();
|
||||
copiedOriginCommandSplit[copiedOriginCommandSplit.length-1] = null;
|
||||
String c = String.join(" ", copiedOriginCommandSplit);
|
||||
|
||||
if(s.startsWith(c)) return turn;
|
||||
}
|
||||
|
||||
tmpCommand = String.join(" ", originCommandSplit);
|
||||
}
|
||||
|
||||
if (!tmpCommand.toLowerCase().startsWith(StringUtils.replaceFirst(s.toLowerCase(), " _-", "")))
|
||||
continue;
|
||||
|
||||
if (!listed) listed = true;
|
||||
if (s.endsWith(" _-")) ignored = true;
|
||||
|
||||
tooBig = originCommandSplit.length > s.replace(" _-", "").split(" ").length;
|
||||
}
|
||||
|
||||
return !(blocked || !useFilter) && turn != listed || ignored && tooBig;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package de.rayzs.pat.plugin.modules.subargs.events;
|
||||
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.subargs.Argument;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TabCompletion extends FilteredTabCompletionEvent {
|
||||
|
||||
@Override
|
||||
public void handle(FilteredTabCompletionEvent event) {
|
||||
String cursor = StringUtils.replaceFirst(event.getCursor(), "/", "");
|
||||
if (event.getCompletion().isEmpty()) return;
|
||||
|
||||
UUID uuid = event.getSenderObj() instanceof UUID ? (UUID) event.getSenderObj() : new CommandSender(event.getSenderObj()).getUniqueId();
|
||||
Argument argument = SubArgsModule.PLAYER_COMMANDS.getOrDefault(uuid, Argument.getGeneralArgument());
|
||||
List<String> possibilities = event.getCompletion(), result = argument.getResult(cursor);
|
||||
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
possibilities = result;
|
||||
if(result.contains("%online_players%")) {
|
||||
possibilities.remove("%online_players%");
|
||||
possibilities.addAll(SubArgsModule.getPlayerNames());
|
||||
}
|
||||
|
||||
if(result.contains("%hidden_online_players%")) {
|
||||
possibilities.remove("%hidden_online_players%");
|
||||
possibilities.addAll(event.getCompletion().stream().filter(completion -> {
|
||||
if(SubArgsModule.getPlayerNames().contains(completion)) return false;
|
||||
return result.contains(completion);
|
||||
}).collect(Collectors.toList()));
|
||||
|
||||
if(possibilities.isEmpty()) possibilities.add("///////////");
|
||||
}
|
||||
|
||||
} else {
|
||||
if(result.contains("%online_players%"))
|
||||
possibilities.removeIf(possibility -> SubArgsModule.getPlayerNames().contains(possibility));
|
||||
|
||||
possibilities.removeAll(result);
|
||||
}
|
||||
|
||||
cursor = StringUtils.getFirstArg(cursor.toLowerCase());
|
||||
if(possibilities.isEmpty() && !SubArgsModule.GENERAL_LIST.contains(cursor)) return;
|
||||
|
||||
event.setCompletion(possibilities);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package de.rayzs.pat.plugin.modules.subargs.events;
|
||||
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.utils.subargs.Argument;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.CommandSender;
|
||||
import de.rayzs.pat.api.event.events.*;
|
||||
import java.util.*;
|
||||
|
||||
public class UpdateList {
|
||||
|
||||
public static UpdatePluginEvent UPDATE_PLUGIN_EVENT = new UpdatePluginEvent() {
|
||||
@Override
|
||||
public void handle(UpdatePluginEvent event) {
|
||||
SubArgsModule.updateMessages();
|
||||
SubArgsModule.updateList();
|
||||
}
|
||||
};
|
||||
|
||||
public static ServerPlayersChangeEvent SERVER_PLAYERS_CHANGE_EVENT = new ServerPlayersChangeEvent() {
|
||||
@Override
|
||||
public void handle(ServerPlayersChangeEvent event) {
|
||||
SubArgsModule.updatePlayerNames();
|
||||
}
|
||||
};
|
||||
|
||||
public static ReceiveSyncEvent RECEIVE_SYNC_EVENT = new ReceiveSyncEvent() {
|
||||
@Override
|
||||
public void handle(ReceiveSyncEvent event) {
|
||||
SubArgsModule.updateList();
|
||||
}
|
||||
};
|
||||
|
||||
public static UpdatePlayerCommandsEvent UPDATE_PLAYER_COMMANDS_EVENT = new UpdatePlayerCommandsEvent() {
|
||||
@Override
|
||||
public void handle(UpdatePlayerCommandsEvent event) {
|
||||
final UUID uuid = event.getSenderObj() instanceof UUID ? (UUID) event.getSenderObj() : new CommandSender(event.getSenderObj()).getUniqueId();
|
||||
final Argument argument = SubArgsModule.PLAYER_COMMANDS.getOrDefault(uuid, new Argument());
|
||||
|
||||
argument.clearAllArguments();
|
||||
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
for (String command : event.getCommands())
|
||||
argument.buildArgumentStacks(command);
|
||||
|
||||
for(String command : Argument.getGeneralArgument().getInputs())
|
||||
argument.buildArgumentStacks(command);
|
||||
|
||||
for (String command : SubArgsModule.getGroupCommands(uuid))
|
||||
argument.buildArgumentStacks(command);
|
||||
|
||||
for (String command : SubArgsModule.getServerCommands(uuid))
|
||||
argument.buildArgumentStacks(command);
|
||||
} else {
|
||||
List<String> groupCommands = SubArgsModule.getGroupCommands(uuid);
|
||||
for (String command : Argument.getGeneralArgument().getInputs()) {
|
||||
if(groupCommands.contains(command)) continue;
|
||||
argument.buildArgumentStacks(command);
|
||||
}
|
||||
}
|
||||
|
||||
SubArgsModule.PLAYER_COMMANDS.putIfAbsent(uuid, argument);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -86,8 +86,8 @@ public class VersionComparer {
|
||||
}
|
||||
|
||||
public boolean isOlder(Version comparedVersion) {
|
||||
if(release < comparedVersion.getRelease()) return true;
|
||||
if(major < comparedVersion.getMajor()) return true;
|
||||
if(release > comparedVersion.getRelease()) return false;
|
||||
if(major > comparedVersion.getMajor()) return false;
|
||||
|
||||
return patch < comparedVersion.getPatch();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package de.rayzs.pat.utils.subargs;
|
||||
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import java.util.*;
|
||||
|
||||
public class Argument {
|
||||
|
||||
private static final Argument GENERAL = new Argument();
|
||||
|
||||
|
||||
private final List<String> INPUTS = new ArrayList<>();
|
||||
private final HashMap<String, ArgumentStack> ARGUMENT_STACKS = new HashMap<>();
|
||||
|
||||
public static Argument getGeneralArgument() {
|
||||
Argument copiedGeneralArguments = new Argument();
|
||||
GENERAL.getInputs().forEach(copiedGeneralArguments::buildArgumentStacks);
|
||||
return copiedGeneralArguments;
|
||||
}
|
||||
|
||||
public static List<String> getOptions(String input) {
|
||||
return GENERAL.getResult(input);
|
||||
}
|
||||
|
||||
public static void clearArguments() {
|
||||
GENERAL.clearAllArguments();
|
||||
}
|
||||
|
||||
public static void buildArguments(String input) {
|
||||
GENERAL.buildArgumentStacks(input);
|
||||
}
|
||||
|
||||
public static List<String> getAllInputs() {
|
||||
return GENERAL.getInputs();
|
||||
}
|
||||
|
||||
|
||||
public List<String> getInputs() {
|
||||
return INPUTS;
|
||||
}
|
||||
|
||||
public List<String> getResult(String input) {
|
||||
String firstInputArg = input.contains(" ") ? input.split(" ")[0] : input;
|
||||
|
||||
for (Map.Entry<String, ArgumentStack> entry : ARGUMENT_STACKS.entrySet()) {
|
||||
if(!entry.getKey().startsWith(firstInputArg)) continue;
|
||||
return ARGUMENT_STACKS.get(entry.getKey()).getResult(input);
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public void clearAllArguments() {
|
||||
INPUTS.clear();
|
||||
ARGUMENT_STACKS.clear();
|
||||
}
|
||||
|
||||
public void buildArgumentStacks(String input) {
|
||||
if(!input.contains(" ")) return;
|
||||
|
||||
if(!INPUTS.contains(input))
|
||||
INPUTS.add(input);
|
||||
|
||||
boolean first = true;
|
||||
ArgumentStack argumentStack = null;
|
||||
|
||||
for (String s : input.split(" ")) {
|
||||
if(!first) {
|
||||
argumentStack = argumentStack.createAndGetArgumentStack(s);
|
||||
continue;
|
||||
}
|
||||
|
||||
argumentStack = ARGUMENT_STACKS.get(s);
|
||||
if (argumentStack == null) {
|
||||
argumentStack = new ArgumentStack();
|
||||
ARGUMENT_STACKS.put(s, argumentStack);
|
||||
}
|
||||
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ArgumentStack {
|
||||
|
||||
private final HashMap<String, ArgumentStack> argumentStacks = new HashMap<>();
|
||||
private final List<String> suggestions = new ArrayList<>();
|
||||
|
||||
public List<String> getResult(String input) {
|
||||
String current;
|
||||
while(input.contains(" ")) {
|
||||
current = input.split(" ")[0];
|
||||
input = StringUtils.replaceFirst(input, current, "");
|
||||
input = input.startsWith(" ") ? StringUtils.replaceFirst(input, " ", "") : input;
|
||||
|
||||
for (Map.Entry<String, ArgumentStack> entry : argumentStacks.entrySet()) {
|
||||
if(!entry.getKey().startsWith(current)) continue;
|
||||
return entry.getValue().getResult(input);
|
||||
}
|
||||
}
|
||||
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
public ArgumentStack createAndGetArgumentStack(String origin) {
|
||||
|
||||
if(!suggestions.contains(origin))
|
||||
suggestions.add(origin);
|
||||
|
||||
if(!argumentStacks.containsKey(origin)) {
|
||||
ArgumentStack argumentStack = new ArgumentStack();
|
||||
argumentStacks.put(origin, argumentStack);
|
||||
return argumentStack;
|
||||
}
|
||||
|
||||
return argumentStacks.get(origin);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package de.rayzs.pat.utils.subargs;
|
||||
|
||||
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import java.util.*;
|
||||
|
||||
public class Responses {
|
||||
|
||||
private static List<Response> RESPONSES = new ArrayList<>();
|
||||
|
||||
public static void update() {
|
||||
RESPONSES = new ArrayList<>();
|
||||
|
||||
Storage.Files.CUSTOM_RESPONSES.getKeys(true).stream().filter(key -> !key.equals("default-message")).forEach(key -> {
|
||||
if(!key.contains(".")) {
|
||||
Response response = new Response(key);
|
||||
RESPONSES.add(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static List<String> getResponse(String input) {
|
||||
return getResponse(input, Storage.ConfigSections.Settings.CANCEL_COMMAND.SUB_COMMAND_RESPONSE.getLines());
|
||||
}
|
||||
|
||||
public static List<String> getResponse(String input, List<String> defaultMessage) {
|
||||
final String finalInput = input.startsWith("/") ? StringUtils.replaceFirst(input, "/", "") : input;
|
||||
|
||||
final Optional<Response> optionalResponse = RESPONSES.stream().filter(response -> {
|
||||
for (String trigger : response.triggers)
|
||||
if(trigger.endsWith("*") ? finalInput.startsWith(StringUtils.replace(trigger, "*", "")) : finalInput.equals(trigger))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}).findFirst();
|
||||
return optionalResponse.isPresent() ? optionalResponse.get().message : defaultMessage;
|
||||
}
|
||||
|
||||
private static class Response {
|
||||
|
||||
private final List<String> triggers, message;
|
||||
|
||||
public Response(final String key) {
|
||||
this.triggers = (List<String>) Storage.Files.CUSTOM_RESPONSES.get(key + ".triggers");
|
||||
this.message = (List<String>) Storage.Files.CUSTOM_RESPONSES.getOrSet(key + ".message", SubArgsModule.BLOCKED_MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ name: ProAntiTab
|
||||
description: Hide more than just your plugins. Hide almost everything!
|
||||
|
||||
author: Rayzs_YT
|
||||
version: 1.8.3
|
||||
version: 1.9.0
|
||||
main: de.rayzs.pat.plugin.BungeeLoader
|
||||
|
||||
softDepends:
|
||||
|
||||
@@ -83,8 +83,10 @@ custom-unknown-command:
|
||||
# is being blocked entirely.
|
||||
cancel-blocked-commands:
|
||||
enabled: true
|
||||
message:
|
||||
base-command-message:
|
||||
- '%prefix% &cThis command &8(&4%command%&8) &cis blocked!'
|
||||
sub-command-message:
|
||||
- '&cCommand &8(&4%command%&8) &cwith the provided sub-argument is not allowed!'
|
||||
|
||||
#>> HTP (Overwritten)
|
||||
# Here you can customize your own fake '/plugins' command.
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
# ____ ___ __ _ ______ __
|
||||
# / __ \_________ / | ____ / /_(_)_ __/___ _/ /_
|
||||
# / /_/ / ___/ __ \/ /| | / __ \/ __/ / / / / __ `/ __ \
|
||||
# / ____/ / / /_/ / ___ |/ / / / /_/ / / / / /_/ / /_/ /
|
||||
# /_/ /_/ \____/_/ |_/_/ /_/\__/_/ /_/ \__,_/_.___/
|
||||
# custom-responses.yml
|
||||
#
|
||||
# Here you can configure a few of the blocked commands a bit further.
|
||||
# But what exactly is this here? Every command that would normally respond with the typical "command is blocked" message, can be configured in here!
|
||||
# But how does it work? It's simple. You just provide the a trigger of the command that would be normally blocked.
|
||||
# Commands that would normally work won't send the messages you have set here.
|
||||
# This way PAT can offer you full control over certain commands and their normal responses.
|
||||
# Here are a few examples:
|
||||
|
||||
# Example with kits.
|
||||
# In here we only trigger the given message, if the player would type "/kit ...".
|
||||
# If this command would work through sub-arguments, then the player would only able to execute the command with the
|
||||
# listed sub-arguments assigned to it. Everything else will result with the set message in there.
|
||||
# --
|
||||
# example-with-kits:
|
||||
# triggers:
|
||||
# - "kit *"
|
||||
# message:
|
||||
# - "&cThis kit does not exist!"
|
||||
|
||||
# Here another example with an auctionhouse plugin.
|
||||
# In here we only trigger the given message, if the player would type "/ah plugin".
|
||||
# Normally it would print out the "command is blocked" message, because PAT would have blocked it in our case.
|
||||
# Therefore, we can also assign a custom response message to it.
|
||||
# ---
|
||||
# example-with-auctionhouse:
|
||||
# triggers:
|
||||
# - "ah plugin"
|
||||
# message:
|
||||
# - "&cThis sub-command does not exist. Please type: &e/ah help"
|
||||
@@ -18,7 +18,8 @@
|
||||
|
||||
# Placeholders of some of the messages in the config.yml:
|
||||
# %pat_message_unknowncommand% = Get the "unknown command"-message from the config.yml of PAT. [cancel-blocked-command]
|
||||
# %pat_message_blocked% = Get the "command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
# %pat_message_base_blocked% = Get the "command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
# %pat_message_sub_blocked% = Get the "sub-command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
|
||||
# Placeholders to list all commands:
|
||||
# %pat_list_size_commands% = Get the amount of all listed commands.
|
||||
|
||||
@@ -66,8 +66,10 @@ custom-unknown-command:
|
||||
# is being blocked entirely.
|
||||
cancel-blocked-commands:
|
||||
enabled: true
|
||||
message:
|
||||
base-command-message:
|
||||
- '%prefix% &cThis command &8(&4%command%&8) &cis blocked!'
|
||||
sub-command-message:
|
||||
- '&cCommand &8(&4%command%&8) &cwith the provided sub-argument is not allowed!'
|
||||
|
||||
# Here you can customize your own fake '/plugins' command.
|
||||
custom-plugins:
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
# ____ ___ __ _ ______ __
|
||||
# / __ \_________ / | ____ / /_(_)_ __/___ _/ /_
|
||||
# / /_/ / ___/ __ \/ /| | / __ \/ __/ / / / / __ `/ __ \
|
||||
# / ____/ / / /_/ / ___ |/ / / / /_/ / / / / /_/ / /_/ /
|
||||
# /_/ /_/ \____/_/ |_/_/ /_/\__/_/ /_/ \__,_/_.___/
|
||||
# custom-responses.yml
|
||||
#
|
||||
# Here you can configure a few of the blocked commands a bit further.
|
||||
# But what exactly is this here? Every command that would normally respond with the typical "command is blocked" message, can be configured in here!
|
||||
# But how does it work? It's simple. You just provide the a trigger of the command that would be normally blocked.
|
||||
# Commands that would normally work won't send the messages you have set here.
|
||||
# This way PAT can offer you full control over certain commands and their normal responses.
|
||||
# Here are a few examples:
|
||||
|
||||
# Example with kits.
|
||||
# In here we only trigger the given message, if the player would type "/kit ...".
|
||||
# If this command would work through sub-arguments, then the player would only able to execute the command with the
|
||||
# listed sub-arguments assigned to it. Everything else will result with the set message in there.
|
||||
# --
|
||||
# example-with-kits:
|
||||
# triggers:
|
||||
# - "kit *"
|
||||
# message:
|
||||
# - "&cThis kit does not exist!"
|
||||
|
||||
# Here another example with an auctionhouse plugin.
|
||||
# In here we only trigger the given message, if the player would type "/ah plugin".
|
||||
# Normally it would print out the "command is blocked" message, because PAT would have blocked it in our case.
|
||||
# Therefore, we can also assign a custom response message to it.
|
||||
# ---
|
||||
# example-with-auctionhouse:
|
||||
# triggers:
|
||||
# - "ah plugin"
|
||||
# message:
|
||||
# - "&cThis sub-command does not exist. Please type: &e/ah help"
|
||||
@@ -17,7 +17,8 @@
|
||||
|
||||
# Placeholders of some of the messages in the config.yml:
|
||||
# %pat_message_unknowncommand% = Get the "unknown command"-message from the config.yml of PAT. [cancel-blocked-command]
|
||||
# %pat_message_blocked% = Get the "command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
# %pat_message_base_blocked% = Get the "command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
# %pat_message_sub_blocked% = Get the "sub-command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
|
||||
# Placeholders to list all commands:
|
||||
# %pat_list_size_commands% = Get the amount of all listed commands.
|
||||
|
||||
@@ -2,7 +2,7 @@ name: ProAntiTab
|
||||
description: Hide more than just your plugins. Hide almost everything!
|
||||
|
||||
author: Rayzs_YT
|
||||
version: 1.8.3
|
||||
version: 1.9.0
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
main: de.rayzs.pat.plugin.BukkitLoader
|
||||
|
||||
Reference in new issue
Block a user