mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-13 12:41:58 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a8b78ce9c | ||
|
|
87e13ea777 | ||
|
|
8e70558363 | ||
|
|
5764842f52 | ||
|
|
c2634da6af | ||
|
|
bf04109e91 | ||
|
|
ebc46247ad | ||
|
|
bac1361f98 | ||
|
|
b26b1eacba | ||
|
|
367357821e | ||
|
|
030154a135 | ||
|
|
b0bb78acdd | ||
|
|
f98aafa8d1 | ||
|
|
805a041474 | ||
|
|
3f5a0ae4a0 | ||
|
|
27caf727de | ||
|
|
31a7d9bc9f | ||
|
|
3eaf2549e8 | ||
|
|
6f0d290d0d | ||
|
|
a03da1bbd3 | ||
|
|
35d6bd9ead | ||
|
|
97e7b712c7 | ||
|
|
fcdcb8fa1c | ||
|
|
71b64d74e6 | ||
|
|
bd411e3239 | ||
|
|
91ce9326b2 | ||
|
|
9711af2ff4 | ||
|
|
dabf1ca089 | ||
|
|
f43c4f7680 | ||
|
|
28ecc7c92d | ||
|
|
b36428b4ab | ||
|
|
21d219ca53 | ||
|
|
497ea897d3 | ||
|
|
35c4908936 | ||
|
|
091eb9ae8a | ||
|
|
445a5d37c3 | ||
|
|
e6b8a9383e | ||
|
|
66b350eb5e | ||
|
|
da84e1164a | ||
|
|
cde86d46c3 | ||
|
|
607ee2a6c8 | ||
|
|
6219c7ce9a | ||
|
|
098035d280 | ||
|
|
111b1275c4 | ||
|
|
d6119a41fb | ||
|
|
095dfde3bb | ||
|
|
3bc56bc934 | ||
|
|
14ecc52cda | ||
|
|
464355c91c | ||
|
|
82e704eaf7 | ||
|
|
54284a0543 | ||
|
|
2cf07382df | ||
|
|
1de01ac745 | ||
|
|
66fce9fb50 | ||
|
|
017500fb5a | ||
|
|
ddd8025fe5 | ||
|
|
f27bc065ba | ||
|
|
9db3819866 | ||
|
|
8a5470dc68 | ||
|
|
159f1b5938 | ||
|
|
89fc1ef8ee | ||
|
|
f249f77cfa | ||
|
|
fad7525101 | ||
|
|
8dc3583ec7 | ||
|
|
2936faab56 | ||
|
|
637b7a263a | ||
|
|
be26033dfe | ||
|
|
4bc7a7f292 | ||
|
|
9b6a9061bc | ||
|
|
6358358078 | ||
|
|
4c4224eb09 | ||
|
|
9100db600e | ||
|
|
263e3e6896 | ||
|
|
26f326668f | ||
|
|
74e26a05f3 |
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>de.rayzs.pat</groupId>
|
||||
<artifactId>ProAntiTab</artifactId>
|
||||
<version>2.0.8</version>
|
||||
<version>2.0.17</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
||||
@@ -47,8 +47,8 @@ public class BukkitPacketAnalyzer {
|
||||
|
||||
try {
|
||||
Channel channel = Reflection.getPlayerChannel(player);
|
||||
|
||||
if (channel == null) {
|
||||
Logger.warning("Failed to inject " + player.getName() + "! Channel is null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -57,8 +57,22 @@ public class BukkitPacketAnalyzer {
|
||||
|
||||
channel.pipeline().addBefore(BukkitPacketAnalyzer.PIPELINE_NAME, BukkitPacketAnalyzer.HANDLER_NAME, new PacketDecoder(player));
|
||||
BukkitPacketAnalyzer.INJECTED_PLAYERS.put(player.getUniqueId(), channel);
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
} catch (IndexOutOfBoundsException indexOutOfBoundsException) {
|
||||
Reflection.toggleInjectionMethod();
|
||||
|
||||
Logger.info("Injection failed. Switching to secondary injection method.");
|
||||
boolean success = inject(player);
|
||||
|
||||
if (success) {
|
||||
Logger.info("Secondary injection method was successful.");
|
||||
} else {
|
||||
Logger.warning("Secondary injection method failed!");
|
||||
}
|
||||
|
||||
return success;
|
||||
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@@ -47,9 +47,13 @@ public class BungeePacketAnalyzer {
|
||||
|
||||
private static Class<?> channelWrapperClass, serverConnectionClass;
|
||||
|
||||
private static final List<String> PROXY_COMMANDS;
|
||||
private static List<String> PROXY_COMMANDS;
|
||||
|
||||
static {
|
||||
loadProxyCommands();
|
||||
}
|
||||
|
||||
public static void loadProxyCommands() {
|
||||
PROXY_COMMANDS = ProxyServer.getInstance().getPluginManager().getCommands().stream().map(entry -> {
|
||||
String key = entry.getKey();
|
||||
return key.startsWith("/") ? key.substring(1) : key;
|
||||
@@ -146,7 +150,7 @@ public class BungeePacketAnalyzer {
|
||||
|
||||
CommandsCache commandsCache = cache.get(serverName);
|
||||
|
||||
List<String> commandsAsString = new ArrayList<String>(PROXY_COMMANDS);
|
||||
List<String> commandsAsString = new ArrayList<>(PROXY_COMMANDS);
|
||||
commandsAsString.addAll(helper.getChildrenNames());
|
||||
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
@@ -163,14 +167,16 @@ public class BungeePacketAnalyzer {
|
||||
if (commands.getRoot().getChild(command.getKey()) != null)
|
||||
continue;
|
||||
|
||||
if (!command.getValue().hasPermission(player))
|
||||
if (!command.getValue().hasPermission(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String commandName = command.getKey();
|
||||
commandName = commandName.startsWith("/") ? commandName.substring(1) : commandName;
|
||||
|
||||
if (!playerCommands.contains(commandName))
|
||||
if (!playerCommands.contains(commandName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CommandNode dummy = createDummyCommandNode(command.getKey());
|
||||
commands.getRoot().addChild(dummy);
|
||||
|
||||
@@ -213,7 +213,6 @@ public class VelocityPacketAnalyzer {
|
||||
final String cursor = playerInput;
|
||||
|
||||
if (!cursor.startsWith("/") && spaces < 2 && player.getProtocolVersion().getProtocol() >= 754) {
|
||||
Logger.debug("Player won't receive TabCompleteResponsePacket because the client protocol id is " + player.getProtocolVersion().getProtocol() + "! This doesn't makes sense, that's why.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
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;
|
||||
@@ -28,19 +29,6 @@ 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.config.settings.AutoLowercaseCommandsSection;
|
||||
import de.rayzs.pat.api.storage.config.settings.BlockNamespaceCommandsSection;
|
||||
import de.rayzs.pat.api.storage.config.settings.CancelCommandSection;
|
||||
import de.rayzs.pat.api.storage.config.settings.CustomBrandSection;
|
||||
import de.rayzs.pat.api.storage.config.settings.CustomPluginsSection;
|
||||
import de.rayzs.pat.api.storage.config.settings.CustomProtocolPingSection;
|
||||
import de.rayzs.pat.api.storage.config.settings.CustomUnknownCommandSection;
|
||||
import de.rayzs.pat.api.storage.config.settings.CustomVersionSection;
|
||||
import de.rayzs.pat.api.storage.config.settings.DisableSyncSection;
|
||||
import de.rayzs.pat.api.storage.config.settings.HandleThroughProxySection;
|
||||
import de.rayzs.pat.api.storage.config.settings.PatchExploitSection;
|
||||
import de.rayzs.pat.api.storage.config.settings.TurnBlacklistToWhitelistSection;
|
||||
import de.rayzs.pat.api.storage.config.settings.UpdateSection;
|
||||
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;
|
||||
@@ -204,6 +192,8 @@ public class Storage {
|
||||
|
||||
} else {
|
||||
|
||||
Storage.Blacklist.Experimental.forceCacheReset();
|
||||
|
||||
if (isVelocity) {
|
||||
List<UUID> playerIds = Storage.getLoader().getPlayerIds();
|
||||
|
||||
@@ -300,6 +290,7 @@ public class Storage {
|
||||
public static CustomProtocolPingSection CUSTOM_PROTOCOL_PING = new CustomProtocolPingSection();
|
||||
public static CustomUnknownCommandSection CUSTOM_UNKNOWN_COMMAND = new CustomUnknownCommandSection();
|
||||
public static TurnBlacklistToWhitelistSection TURN_BLACKLIST_TO_WHITELIST = new TurnBlacklistToWhitelistSection();
|
||||
public static BaseCommandCaseSensitiveSection BASE_COMMAND_CASE_SENSITIVE = new BaseCommandCaseSensitiveSection();
|
||||
public static UpdateSection UPDATE = new UpdateSection();
|
||||
|
||||
public static void initialize() {}
|
||||
@@ -384,6 +375,19 @@ public class Storage {
|
||||
|
||||
public static class Blacklist {
|
||||
|
||||
public static class Experimental {
|
||||
|
||||
public static void forceCacheReset() {
|
||||
for (Object o : CACHED_SERVER_BLACKLIST.getCache().asMap().keySet()) {
|
||||
String s = (String) o;
|
||||
|
||||
clearServerBlacklists(s);
|
||||
loadCachedServerBlacklists(s);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum BlockType {
|
||||
CHAT("[CMD]"),
|
||||
TAB("[TAB]"),
|
||||
@@ -428,14 +432,9 @@ public class Storage {
|
||||
BLACKLIST.getConfig().getKeys("global.servers", true).forEach(key -> {
|
||||
GeneralBlacklist blacklist = BlacklistCreator.createGeneralBlacklist(key);
|
||||
blacklist.load();
|
||||
|
||||
SERVER_BLACKLISTS.put(key, blacklist);
|
||||
});
|
||||
|
||||
loadAllCachedServerBlacklists();
|
||||
}
|
||||
|
||||
private static void loadAllCachedServerBlacklists() {
|
||||
getServers().forEach(Blacklist::loadCachedServerBlacklists);
|
||||
}
|
||||
|
||||
@@ -443,9 +442,7 @@ public class Storage {
|
||||
List<GeneralBlacklist> blacklists = SERVER_BLACKLISTS.entrySet().stream()
|
||||
.filter(entry ->
|
||||
isServer(entry.getKey(), server)
|
||||
).map(entry ->
|
||||
entry.getValue()
|
||||
).toList();
|
||||
).map(Map.Entry::getValue).toList();
|
||||
|
||||
CACHED_SERVER_BLACKLIST.put(server, blacklists);
|
||||
}
|
||||
@@ -547,9 +544,19 @@ public class Storage {
|
||||
}
|
||||
|
||||
public static boolean isBlocked(String command, BlockType type, String server) {
|
||||
|
||||
BlockType negation = BlockType.NEGATE;
|
||||
String negatedCommand = negation + command;
|
||||
|
||||
boolean listed = isListed(command, type, server),
|
||||
negatedListed = isListed(negatedCommand, type, server),
|
||||
turn = ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
|
||||
|
||||
if (!turn && negatedListed) {
|
||||
listed = !listed;
|
||||
}
|
||||
|
||||
if (turn) {
|
||||
return !listed;
|
||||
} else {
|
||||
@@ -565,18 +572,17 @@ public class Storage {
|
||||
boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
boolean listed = false;
|
||||
|
||||
if (type == BlockType.NEGATE)
|
||||
turn = !turn;
|
||||
|
||||
String command = type.toString() + unmodifiedCommand;
|
||||
|
||||
if (server == null || !isIgnoredServer(server))
|
||||
if (server == null || !isIgnoredServer(server)) {
|
||||
listed = BLACKLIST.isListed(command, !turn);
|
||||
}
|
||||
|
||||
if (server == null) {
|
||||
|
||||
if (!listed && type != BlockType.BOTH)
|
||||
if (!listed && type != BlockType.BOTH) {
|
||||
return isListed(unmodifiedCommand, BlockType.BOTH, null);
|
||||
}
|
||||
|
||||
return listed;
|
||||
}
|
||||
@@ -586,7 +592,7 @@ public class Storage {
|
||||
blacklists.add(BLACKLIST);
|
||||
|
||||
for (GeneralBlacklist blacklist : blacklists) {
|
||||
if (listed && turn) {
|
||||
if (listed/* && turn*/) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -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.Reflection;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class BaseCommandCaseSensitiveSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
|
||||
public BaseCommandCaseSensitiveSection() {
|
||||
super("base-command-case-sensitive");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, true).getOrSet();
|
||||
}
|
||||
}
|
||||
@@ -20,27 +20,37 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
return isListed(command, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
|
||||
}
|
||||
|
||||
public boolean isListed(String command, boolean ignoreCollons) {
|
||||
if(commands == null) {
|
||||
public boolean isListed(String command, boolean ignoreColons) {
|
||||
final boolean caseSensitive = Storage.ConfigSections.Settings.BASE_COMMAND_CASE_SENSITIVE.ENABLED;
|
||||
|
||||
if (commands == null || command.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (commands.contains("*"))
|
||||
if (!isNegated(command) && commands.contains("*")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (String listedCommand : commands) {
|
||||
if(listedCommand == null)
|
||||
if (listedCommand == null)
|
||||
continue;
|
||||
|
||||
if (ignoreCollons) {
|
||||
if (ignoreColons) {
|
||||
command = StringUtils.getFirstArg(command);
|
||||
|
||||
if (command.contains(":"))
|
||||
command = command.substring(command.indexOf(':'));
|
||||
}
|
||||
|
||||
if (StringUtils.getFirstArg(listedCommand).equalsIgnoreCase(StringUtils.getFirstArg(command)))
|
||||
return true;
|
||||
if (caseSensitive) {
|
||||
if (StringUtils.getFirstArg(listedCommand).equals(StringUtils.getFirstArg(command))) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (StringUtils.getFirstArg(listedCommand).equalsIgnoreCase(StringUtils.getFirstArg(command))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -81,4 +91,17 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
getConfig().reload();
|
||||
commands = (ArrayList<String>) getConfig().getOrSet(getNavigatePath(), commands);
|
||||
}
|
||||
|
||||
private boolean isNegated(String command) {
|
||||
if (command.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean negated = command.charAt(0) == '!';
|
||||
|
||||
if (!negated && command.length() > 5)
|
||||
negated = command.charAt(5) == '!';
|
||||
|
||||
return negated;
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,9 @@ import java.util.*;
|
||||
|
||||
public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
private static List<String> commands = new ArrayList<>(), allowedCommands = new ArrayList<>();
|
||||
private static List<String> commands = new ArrayList<>(),
|
||||
allowedCommands = new ArrayList<>(),
|
||||
disallowedCommands = new ArrayList<>();
|
||||
|
||||
private static Plugin plugin;
|
||||
private static java.util.logging.Logger logger;
|
||||
@@ -185,7 +187,7 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
@Override
|
||||
public boolean doesPlayerExist(String playerName) {
|
||||
return ArrayUtils.containsIgnoreCase(getPlayerNames(), playerName);
|
||||
return isPlayerOnline(playerName) || ArrayUtils.containsIgnoreCase(getPlayerNames(), playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -318,13 +320,8 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
if (!loaded)
|
||||
loaded = true;
|
||||
|
||||
if (Reflection.getMinor() >= 13) {
|
||||
|
||||
if (updatedList) {
|
||||
BukkitAntiTabListener.updateCommands();
|
||||
Logger.debug("Force server to load all players tab-completion due to received sync!");
|
||||
}
|
||||
|
||||
if (Reflection.getMinor() >= 13 && updatedList) {
|
||||
BukkitAntiTabListener.updateCommands();
|
||||
}
|
||||
|
||||
PATEventHandler.callReceiveSyncEvents(packetBundle);
|
||||
@@ -338,6 +335,22 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
return new ArrayList<>(allowedCommands);
|
||||
}
|
||||
|
||||
public static List<String> getDisallowedCommands() {
|
||||
return disallowedCommands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginNames() {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
PluginDescriptionFile description = plugin.getDescription();
|
||||
pluginNames.add(description.getName() + " (" + description.getVersion() + ")");
|
||||
}
|
||||
|
||||
return pluginNames;
|
||||
}
|
||||
|
||||
private void loadCommandMap() {
|
||||
try {
|
||||
if (Bukkit.getPluginManager() instanceof SimplePluginManager) {
|
||||
@@ -404,6 +417,7 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
BukkitLoader.commands = result;
|
||||
BukkitLoader.allowedCommands = allowedCommands;
|
||||
BukkitLoader.disallowedCommands = commands.stream().filter(command -> !allowedCommands.contains(command)).toList();
|
||||
}
|
||||
|
||||
public static boolean useSuggestions() {
|
||||
|
||||
@@ -33,7 +33,6 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
private static Plugin plugin;
|
||||
private static java.util.logging.Logger logger;
|
||||
|
||||
private static boolean checkUpdate = false;
|
||||
private static final HashMap<String, CommandsCache> commandsCacheMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
@@ -98,6 +97,11 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,7 +118,9 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReload() {}
|
||||
public void handleReload() {
|
||||
BungeePacketAnalyzer.loadProxyCommands();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesCommandExist(String command) {
|
||||
@@ -233,6 +239,18 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
return new ArrayList<>(ProxyServer.getInstance().getServers().keySet().stream().toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginNames() {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
|
||||
for (Plugin plugin : ProxyServer.getInstance().getPluginManager().getPlugins()) {
|
||||
PluginDescription description = plugin.getDescription();
|
||||
pluginNames.add(description.getName() + " (" + description.getVersion() + ")");
|
||||
}
|
||||
|
||||
return pluginNames;
|
||||
}
|
||||
|
||||
public void startUpdaterTask() {
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED)
|
||||
return;
|
||||
|
||||
@@ -38,4 +38,6 @@ public interface PluginLoader {
|
||||
List<String> getPlayerNames();
|
||||
List<String> getOnlinePlayerNames();
|
||||
List<String> getOfflinePlayerNames();
|
||||
|
||||
List<String> getPluginNames();
|
||||
}
|
||||
@@ -38,7 +38,7 @@ import java.util.*;
|
||||
|
||||
@Plugin(name = "ProAntiTab",
|
||||
id = "proantitab",
|
||||
version = "2.0.8",
|
||||
version = "2.0.17",
|
||||
authors = "Rayzs_YT",
|
||||
description = "Hide more than just your plugins. Hide almost everything!",
|
||||
url = "https://www.rayzs.de/products/proantitab/page",
|
||||
@@ -58,7 +58,6 @@ public class VelocityLoader implements PluginLoader {
|
||||
private ScheduledTask updaterTask;
|
||||
|
||||
private static final HashMap<String, CommandsCache> commandsCacheMap = new HashMap<>();
|
||||
private static boolean checkUpdate = false;
|
||||
|
||||
@Inject
|
||||
public VelocityLoader(ProxyServer server, org.slf4j.Logger logger, VelocityMetrics.Factory metricsFactory) {
|
||||
@@ -95,7 +94,7 @@ public class VelocityLoader implements PluginLoader {
|
||||
metricsFactory.make(this, 21638);
|
||||
|
||||
server.getCommandManager().register("bpat", new VelocityCommand(), "bungeeproantitab");
|
||||
//server.getEventManager().register(this, new VelocityBlockCommandListener(server));
|
||||
server.getEventManager().register(this, new VelocityBlockCommandListener());
|
||||
server.getEventManager().register(this, new VelocityAntiTabListener(server));
|
||||
server.getEventManager().register(this, new VelocityConnectionListener(server, this));
|
||||
server.getEventManager().register(this, new VelocityPingListener(server));
|
||||
@@ -275,6 +274,21 @@ public class VelocityLoader implements PluginLoader {
|
||||
return new ArrayList<>(server.getAllServers().stream().map(registeredServer -> registeredServer.getServerInfo().getName()).toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginNames() {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
for (PluginContainer plugin : server.getPluginManager().getPlugins()) {
|
||||
PluginDescription description = plugin.getDescription();
|
||||
|
||||
String pluginName = description.getName().orElse("/");
|
||||
String version = description.getVersion().orElse("/");
|
||||
|
||||
pluginNames.add(pluginName + " (" + version + ")");
|
||||
}
|
||||
|
||||
return pluginNames;
|
||||
}
|
||||
|
||||
public void startUpdaterTask() {
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED) return;
|
||||
|
||||
|
||||
@@ -5,15 +5,12 @@ import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.adapter.ViaVersionAdapter;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import org.bukkit.entity.Player;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import org.bukkit.event.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class BukkitAntiTabListener implements Listener {
|
||||
@@ -27,13 +24,11 @@ public class BukkitAntiTabListener implements Listener {
|
||||
String uuidSubstring = uuid.toString().substring(uuid.toString().length() - 5);
|
||||
|
||||
if (Storage.USE_VELOCITY || player.isOp()) {
|
||||
Logger.debug("Doesn't even tried to create the commands list for player with uuid " + uuidSubstring + ". (Veloctiy? " + Storage.USE_VELOCITY + ". OP? " + player.isOp() + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BukkitLoader.isLoaded()) {
|
||||
event.getCommands().clear();
|
||||
Logger.debug("Doesn't even tried to create the commands list for player with uuid " + uuidSubstring + ". (not loaded)");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -41,15 +36,13 @@ public class BukkitAntiTabListener implements Listener {
|
||||
return;
|
||||
|
||||
if (event.getCommands().isEmpty()) {
|
||||
Logger.debug("No available commands to filter! Ignoring rest of the code until at least one command is listed in there.");
|
||||
return;
|
||||
}
|
||||
List<String> allCommands = getCommands();
|
||||
|
||||
List<String> allCommands = getCommands();
|
||||
COMMANDS_CACHE.handleCommands(allCommands);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player)) {
|
||||
Logger.debug("Player with uuid " + uuidSubstring + " skipped the commands-list creation due to its permissions.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -62,7 +55,6 @@ public class BukkitAntiTabListener implements Listener {
|
||||
return;
|
||||
|
||||
event.getCommands().addAll(filteredSuggestionEvent.getSuggestions());
|
||||
Logger.debug("Player with uuid " + uuidSubstring + " has a total of " + playerCommands.size() + " commands.");
|
||||
}
|
||||
|
||||
public static List<String> getCommands() {
|
||||
|
||||
@@ -46,8 +46,9 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandProcess(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
final String commandFirstArg = StringUtils.getFirstArg(event.getMessage());
|
||||
|
||||
if (Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.isCommand(StringUtils.getFirstArg(event.getMessage()))) {
|
||||
if (Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.isCommand(commandFirstArg)) {
|
||||
String command = event.getMessage();
|
||||
|
||||
if (command.contains(" ")) {
|
||||
@@ -56,9 +57,11 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
command = String.join(" ", args);
|
||||
} else command = command.toLowerCase();
|
||||
|
||||
player.chat(command);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
if (!commandFirstArg.equals(command)) {
|
||||
player.chat(command);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
World world = player.getWorld();
|
||||
@@ -71,7 +74,7 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
command = StringUtils.getFirstArg(command);
|
||||
|
||||
final String displayName = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
command = command.toLowerCase();
|
||||
//command = command.toLowerCase();
|
||||
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
|
||||
|
||||
+15
-5
@@ -9,12 +9,12 @@ import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
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.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.*;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class BukkitPlayerConnectionListener implements Listener {
|
||||
|
||||
@@ -23,16 +23,26 @@ public class BukkitPlayerConnectionListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
|
||||
if(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
BackendUpdater.handle();
|
||||
|
||||
PermissionUtil.setPlayerPermissions(player.getUniqueId());
|
||||
CustomServerBrand.preparePlayer(player);
|
||||
|
||||
if(CustomServerBrand.isEnabled())
|
||||
if (CustomServerBrand.isEnabled())
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
|
||||
if(!BukkitPacketAnalyzer.inject(player)) {
|
||||
if (!Storage.USE_LUCKPERMS && !Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
PATScheduler.createScheduler(() -> {
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
assert sender != null;
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
BukkitAntiTabListener.handleTabCompletion(player.getUniqueId());
|
||||
}, 20);
|
||||
}
|
||||
|
||||
if (!BukkitPacketAnalyzer.inject(player)) {
|
||||
|
||||
PATScheduler.createScheduler(() -> {
|
||||
if (player.isOnline()) {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
|
||||
final String displayCommand = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
|
||||
command = command.toLowerCase();
|
||||
//command = command.toLowerCase();
|
||||
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
|
||||
|
||||
@@ -24,7 +24,7 @@ public class BungeePingListener implements Listener {
|
||||
try {
|
||||
max = proxyServer.getConfigurationAdapter().getListeners().iterator().next().getMaxPlayers();
|
||||
} catch (Throwable throwable) {
|
||||
Logger.debug("Failed to read max-players count for %max% placeholder! Using -1 as default value instead.");
|
||||
Logger.warning("Failed to read max-players count for %max% placeholder! Using -1 as default value instead.");
|
||||
}
|
||||
|
||||
ServerPing serverPing = event.getResponse();
|
||||
|
||||
@@ -43,46 +43,56 @@ public class VelocityAntiTabListener {
|
||||
|
||||
@Subscribe (order = PostOrder.LAST)
|
||||
public void onPlayerAvailableCommands(PlayerAvailableCommandsEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
try {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(event.getRootNode().getChildren().isEmpty() || !player.getCurrentServer().isPresent())
|
||||
return;
|
||||
if (event.getRootNode().getChildren().isEmpty() || !player.getCurrentServer().isPresent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
|
||||
if(!cache.containsKey(serverName))
|
||||
cache.put(serverName, new CommandsCache());
|
||||
if (!cache.containsKey(serverName)) {
|
||||
cache.put(serverName, new CommandsCache());
|
||||
}
|
||||
|
||||
CommandsCache commandsCache = cache.get(serverName);
|
||||
CommandsCache commandsCache = cache.get(serverName);
|
||||
|
||||
List<String> commandsAsString = new ArrayList<>();
|
||||
event.getRootNode().getChildren().stream().filter(command -> command != null && command.getName() != null).forEach(command -> commandsAsString.add(command.getName()));
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
List<String> commandsAsString = new ArrayList<>();
|
||||
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;
|
||||
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 boolean newer = player.getProtocolVersion().getProtocol() > 340, argsChildrenExist = event.getRootNode().getChild("args") != null;
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
|
||||
|
||||
if (event.getRootNode().getChildren().size() == 1
|
||||
&& newer && argsChildrenExist
|
||||
&& event.getRootNode().getChild("args").getChildren().isEmpty()) {
|
||||
return;
|
||||
if (event.getRootNode().getChildren().size() == 1
|
||||
&& newer && argsChildrenExist
|
||||
&& event.getRootNode().getChild("args").getChildren().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getRootNode().getChildren().size() == 1 && newer && argsChildrenExist) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.getRootNode().getChildren().removeIf(command -> {
|
||||
if (command == null || command.getName() == null)
|
||||
return true;
|
||||
|
||||
if (command.getName().equals("args"))
|
||||
return false;
|
||||
|
||||
return !playerCommands.contains(command.getName());
|
||||
});
|
||||
} catch (Exception exception) {
|
||||
System.out.println("An error occurred while processing commands in PAT: " + exception.getMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
if(event.getRootNode().getChildren().size() == 1 && newer && argsChildrenExist) return;
|
||||
|
||||
event.getRootNode().getChildren().removeIf(command -> {
|
||||
if (command == null || command.getName() == null)
|
||||
return true;
|
||||
|
||||
if (command.getName().equals("args"))
|
||||
return false;
|
||||
|
||||
return !playerCommands.contains(command.getName());
|
||||
});
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -1,5 +1,6 @@
|
||||
package de.rayzs.pat.plugin.listeners.velocity;
|
||||
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
|
||||
@@ -13,6 +14,11 @@ import java.util.List;
|
||||
|
||||
public class VelocityBlockCommandListener {
|
||||
|
||||
@Subscribe
|
||||
public void onCommandExecute(CommandExecuteEvent event) {
|
||||
handleCommand(event);
|
||||
}
|
||||
|
||||
public static CommandExecuteEvent handleCommand(Player player, String command) {
|
||||
return handleCommand(new CommandExecuteEvent(player, command));
|
||||
}
|
||||
@@ -41,7 +47,7 @@ public class VelocityBlockCommandListener {
|
||||
|
||||
final String displayCommand = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
|
||||
command = command.toLowerCase();
|
||||
//command = command.toLowerCase();
|
||||
|
||||
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
|
||||
@@ -1,21 +1,41 @@
|
||||
package de.rayzs.pat.plugin.logger;
|
||||
|
||||
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.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.plugin.logger.impl.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
public class Logger {
|
||||
|
||||
private static final String LOG_HEADER;
|
||||
|
||||
static {
|
||||
final String software = Reflection.isProxyServer()
|
||||
? Reflection.isVelocityServer() ? "Velocity" : "Bungeecord"
|
||||
: (Reflection.isPaper() ? "Paper" : Reflection.isFoliaServer() ? "Folia" : "Spigot/Bukkit");
|
||||
|
||||
final String version = Reflection.isProxyServer() ? "" : " " + Reflection.getRawVersionName().replace("_", ".");
|
||||
|
||||
LOG_HEADER = "> ProAntiTab v" + Storage.CURRENT_VERSION + " [" + software + version + "]";
|
||||
}
|
||||
|
||||
private final static LoggerTemplate LOGGER =
|
||||
Reflection.isVelocityServer() ? new VelocityLogger()
|
||||
: Reflection.isProxyServer() ? new BungeeLogger()
|
||||
: new BukkitLogger();
|
||||
|
||||
|
||||
public static void info(List<String> messages) {
|
||||
LOGGER.info(messages);
|
||||
}
|
||||
@@ -24,10 +44,6 @@ public class Logger {
|
||||
LOGGER.warn(messages);
|
||||
}
|
||||
|
||||
public static void debug(List<String> messages) {
|
||||
LOGGER.debug(messages);
|
||||
}
|
||||
|
||||
public static void info(String message) {
|
||||
LOGGER.info(message);
|
||||
}
|
||||
@@ -36,25 +52,9 @@ public class Logger {
|
||||
LOGGER.warn(message);
|
||||
}
|
||||
|
||||
public static void debug(String message) {
|
||||
LOGGER.debug(message);
|
||||
}
|
||||
|
||||
public static String post() throws IOException {
|
||||
ArrayList<String> clonedLogs = new ArrayList<>(LOGGER.getLogs());
|
||||
int startIndex = clonedLogs.size() > 980 ? clonedLogs.size() - 980 : 0;
|
||||
StringBuilder textBuilder = new StringBuilder("[ProAntiTab " + Storage.CURRENT_VERSION + " | " + (Reflection.isProxyServer() ? Reflection.isVelocityServer() ? "Velocity" : "Proxy" : Reflection.isPaper() ? "Paper" : "Bukkit") + "]" + (Reflection.getRawVersionName() != null ? " Server version: " + Reflection.getVersionName() + " " + Reflection.getRawVersionName().replace("_", ".") : "") + "\n" + (startIndex != 0 ? "... another part is split!\n\n" : ""));
|
||||
|
||||
for (int i = startIndex; i < clonedLogs.size(); i++) {
|
||||
if (clonedLogs.get(i) == null)
|
||||
continue;
|
||||
|
||||
String line = clonedLogs.get(i);
|
||||
textBuilder.append("\n");
|
||||
textBuilder.append(line);
|
||||
}
|
||||
|
||||
byte[] textInBytes = textBuilder.toString().getBytes(StandardCharsets.UTF_8);
|
||||
byte[] textInBytes = (LOG_HEADER + "\n\n" + createInfo()).getBytes(StandardCharsets.UTF_8);
|
||||
int postDataLength = textInBytes.length;
|
||||
URL url = new URL("https://haste.rayzs.de/documents");
|
||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||
@@ -77,4 +77,94 @@ public class Logger {
|
||||
response = response.substring(response.indexOf(":") + 2, response.length() - 2);
|
||||
return "https://haste.rayzs.de/" + response + ".txt";
|
||||
}
|
||||
|
||||
private static String createInfo() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append("Updated: ")
|
||||
.append(!Storage.OUTDATED)
|
||||
.append("\n\n");
|
||||
|
||||
builder.append("Mode: ")
|
||||
.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("Installed plugins: \n ")
|
||||
.append(String.join("\n ", Storage.getLoader().getPluginNames()))
|
||||
.append("\n\n");
|
||||
|
||||
builder.append("Detected supported plugins:")
|
||||
.append("\n");
|
||||
|
||||
builder.append(" LuckPerms: ")
|
||||
.append(Storage.USE_LUCKPERMS)
|
||||
.append("\n");
|
||||
|
||||
builder.append(" PlaceholderAPI: ")
|
||||
.append(Storage.USE_PLACEHOLDERAPI)
|
||||
.append("\n");
|
||||
|
||||
builder.append(" ViaVersion: ")
|
||||
.append(Storage.USE_VIAVERSION)
|
||||
.append("\n\n");
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
builder.append("server-name: ")
|
||||
.append(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ? Storage.SERVER_NAME : "Not connected to a proxy using PAT")
|
||||
.append("\n");
|
||||
|
||||
builder.append("last-received-sync: ")
|
||||
.append(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ? Storage.LAST_SYNC : "Deactivated")
|
||||
.append("\n");
|
||||
}
|
||||
|
||||
builder.append("\ncommands: ")
|
||||
.append(String.join(", ", Storage.Blacklist.getBlacklist().getCommands()))
|
||||
.append("\n\n");
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
builder.append("\nservers: ")
|
||||
.append(String.join(", ", Storage.getServers()))
|
||||
.append("\n");
|
||||
|
||||
builder.append("last-sent-sync: ")
|
||||
.append(Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED ? "Deactivated" : (System.currentTimeMillis() - Storage.LAST_SYNC))
|
||||
.append("\n\n");
|
||||
|
||||
for (ClientInfo client : Communicator.CLIENTS) {
|
||||
builder.append("synced-server: ")
|
||||
.append(client.getName() + " (" + client.getSyncTime() + ")")
|
||||
.append(", ");
|
||||
}
|
||||
|
||||
builder.append("\n\n");
|
||||
}
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
builder.append("server-commands:").append("\n");
|
||||
|
||||
for (Map.Entry<String, GeneralBlacklist> blacklist : Storage.Blacklist.getBlacklists()) {
|
||||
builder.append(" ")
|
||||
.append(blacklist.getKey()).append(": ")
|
||||
.append(String.join(", ", blacklist.getValue().getCommands()))
|
||||
.append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
builder.append("\ngroups:");
|
||||
for (Group group : GroupManager.getGroups()) {
|
||||
builder.append("\n")
|
||||
.append(group.getGroupInfo());
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
package de.rayzs.pat.plugin.logger;
|
||||
|
||||
public enum LoggerPriority { INFO, WARNING, DEBUG }
|
||||
public enum LoggerPriority { INFO, WARNING }
|
||||
@@ -1,23 +1,16 @@
|
||||
package de.rayzs.pat.plugin.logger;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
||||
public interface LoggerTemplate {
|
||||
|
||||
SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss:SS");
|
||||
|
||||
List<String> getLogs();
|
||||
|
||||
void info(List<String> messages);
|
||||
void warn(List<String> messages);
|
||||
void debug(List<String> messages);
|
||||
|
||||
void send(LoggerPriority priority, List<String> messages);
|
||||
|
||||
void info(String message);
|
||||
void warn(String message);
|
||||
void debug(String message);
|
||||
|
||||
void send(LoggerPriority priority, String message);
|
||||
}
|
||||
@@ -1,25 +1,15 @@
|
||||
package de.rayzs.pat.plugin.logger.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.plugin.logger.LoggerPriority;
|
||||
import de.rayzs.pat.plugin.logger.LoggerTemplate;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.plugin.logger.*;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class BukkitLogger implements LoggerTemplate {
|
||||
|
||||
private final List<String> LOGS = new ArrayList<>();
|
||||
private final java.util.logging.Logger logger = BukkitLoader.getPluginLogger();
|
||||
|
||||
@Override
|
||||
public List<String> getLogs() {
|
||||
return LOGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(List<String> messages) {
|
||||
messages.forEach(this::info);
|
||||
@@ -30,11 +20,6 @@ public class BukkitLogger implements LoggerTemplate {
|
||||
messages.forEach(this::warn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(List<String> messages) {
|
||||
messages.forEach(this::debug);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(LoggerPriority priority, List<String> messages) {
|
||||
messages.forEach(message -> send(priority, message));
|
||||
@@ -50,22 +35,10 @@ public class BukkitLogger implements LoggerTemplate {
|
||||
send(LoggerPriority.WARNING, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
send(LoggerPriority.DEBUG, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(LoggerPriority priority, String message) {
|
||||
message = MessageTranslator.replaceMessage(message);
|
||||
|
||||
String time = TIME_FORMAT.format(new Date(System.currentTimeMillis()));
|
||||
if(time.length() != 12) time = time.substring(0, 9) + 0 + time.split(":")[3];
|
||||
LOGS.add("[" + priority.name() + " | " + time + "] " + MessageTranslator.colorless(message));
|
||||
|
||||
if (priority == LoggerPriority.DEBUG)
|
||||
return;
|
||||
|
||||
if (message.contains("§")) {
|
||||
MessageTranslator.send(Bukkit.getServer().getConsoleSender(), message);
|
||||
return;
|
||||
|
||||
@@ -1,25 +1,15 @@
|
||||
package de.rayzs.pat.plugin.logger.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.BungeeLoader;
|
||||
import de.rayzs.pat.plugin.logger.LoggerPriority;
|
||||
import de.rayzs.pat.plugin.logger.LoggerTemplate;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.plugin.BungeeLoader;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import de.rayzs.pat.plugin.logger.*;
|
||||
import java.util.*;
|
||||
|
||||
public class BungeeLogger implements LoggerTemplate {
|
||||
|
||||
private final List<String> LOGS = new ArrayList<>();
|
||||
private final java.util.logging.Logger logger = BungeeLoader.getPluginLogger();
|
||||
|
||||
@Override
|
||||
public List<String> getLogs() {
|
||||
return LOGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(List<String> messages) {
|
||||
messages.forEach(this::info);
|
||||
@@ -30,11 +20,6 @@ public class BungeeLogger implements LoggerTemplate {
|
||||
messages.forEach(this::warn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(List<String> messages) {
|
||||
messages.forEach(this::debug);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(LoggerPriority priority, List<String> messages) {
|
||||
messages.forEach(message -> send(priority, message));
|
||||
@@ -50,22 +35,10 @@ public class BungeeLogger implements LoggerTemplate {
|
||||
send(LoggerPriority.WARNING, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
send(LoggerPriority.DEBUG, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(LoggerPriority priority, String message) {
|
||||
message = MessageTranslator.replaceMessage(message);
|
||||
|
||||
String time = TIME_FORMAT.format(new Date(System.currentTimeMillis()));
|
||||
if(time.length() != 12) time = time.substring(0, 9) + 0 + time.split(":")[3];
|
||||
LOGS.add("[" + priority.name() + " | " + time + "] " + MessageTranslator.colorless(message));
|
||||
|
||||
if (priority == LoggerPriority.DEBUG)
|
||||
return;
|
||||
|
||||
if (message.contains("§")) {
|
||||
MessageTranslator.send(ProxyServer.getInstance().getConsole(), message);
|
||||
return;
|
||||
|
||||
@@ -1,25 +1,15 @@
|
||||
package de.rayzs.pat.plugin.logger.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.plugin.logger.LoggerPriority;
|
||||
import de.rayzs.pat.plugin.logger.LoggerTemplate;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.plugin.logger.*;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class VelocityLogger implements LoggerTemplate {
|
||||
|
||||
private final List<String> LOGS = new ArrayList<>();
|
||||
private final Logger logger = VelocityLoader.getPluginLogger();
|
||||
|
||||
@Override
|
||||
public List<String> getLogs() {
|
||||
return LOGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(List<String> messages) {
|
||||
messages.forEach(this::info);
|
||||
@@ -30,11 +20,6 @@ public class VelocityLogger implements LoggerTemplate {
|
||||
messages.forEach(this::warn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(List<String> messages) {
|
||||
messages.forEach(this::debug);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(LoggerPriority priority, List<String> messages) {
|
||||
messages.forEach(message -> send(priority, message));
|
||||
@@ -50,22 +35,10 @@ public class VelocityLogger implements LoggerTemplate {
|
||||
send(LoggerPriority.WARNING, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
send(LoggerPriority.DEBUG, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(LoggerPriority priority, String message) {
|
||||
message = MessageTranslator.replaceMessage(message);
|
||||
|
||||
String time = TIME_FORMAT.format(new Date(System.currentTimeMillis()));
|
||||
if(time.length() != 12) time = time.substring(0, 9) + 0 + time.split(":")[3];
|
||||
LOGS.add("[" + priority.name() + " | " + time + "] " + MessageTranslator.colorless(message));
|
||||
|
||||
if (priority == LoggerPriority.DEBUG)
|
||||
return;
|
||||
|
||||
if (message.contains("§")) {
|
||||
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), message);
|
||||
return;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ExecuteCommand extends ExecuteCommandEvent {
|
||||
return;
|
||||
}
|
||||
|
||||
if (command.contains(" ") && !canPlayerExecute(sender, command)) {
|
||||
if (isBlocked(sender, command)) {
|
||||
event.setBlocked(true);
|
||||
event.setCancelled(true);
|
||||
|
||||
@@ -87,20 +87,53 @@ public class ExecuteCommand extends ExecuteCommandEvent {
|
||||
|
||||
}
|
||||
|
||||
private boolean canPlayerExecute(CommandSender sender, String command) {
|
||||
boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
boolean listed = false;
|
||||
private boolean isBlocked(CommandSender sender, String command) {
|
||||
final Arguments arguments = SubArgsModule.PLAYER_COMMANDS.getOrDefault(sender.getUniqueId(), Arguments.ARGUMENTS);
|
||||
final List<String> commands = new ArrayList<>(arguments.CHAT_ARGUMENTS.getGeneralArgument().getInputs());
|
||||
final String firstArgument = StringUtils.getFirstArg(command);
|
||||
|
||||
Arguments arguments = SubArgsModule.PLAYER_COMMANDS.getOrDefault(sender.getUniqueId(), Arguments.ARGUMENTS);
|
||||
List<String> commands = new ArrayList<>(arguments.CHAT_ARGUMENTS.getGeneralArgument().getInputs());
|
||||
final String blockBaseCommandStr = firstArgument + " -_";
|
||||
final boolean blockBaseCommand = commands.contains(blockBaseCommandStr);
|
||||
|
||||
if (!command.contains(" ")) {
|
||||
return blockBaseCommand;
|
||||
}
|
||||
|
||||
if (blockBaseCommand) {
|
||||
commands.remove(blockBaseCommandStr);
|
||||
}
|
||||
|
||||
|
||||
boolean inCommands = commands.stream().anyMatch(c -> StringUtils.getFirstArg(c).equalsIgnoreCase(firstArgument));
|
||||
boolean negationInCommands = commands.stream().anyMatch(c -> StringUtils.getFirstArg(c).equalsIgnoreCase("!" + firstArgument));
|
||||
|
||||
|
||||
if (!inCommands && !negationInCommands) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
boolean listed = isListed(command, commands);
|
||||
boolean negated = isListed("!" + command, commands);
|
||||
|
||||
if (!listed && !inCommands) {
|
||||
listed = turn;
|
||||
}
|
||||
|
||||
if (negated) {
|
||||
listed = !turn;
|
||||
}
|
||||
|
||||
return turn != listed;
|
||||
}
|
||||
|
||||
private boolean isListed(String command, List<String> commands) {
|
||||
boolean listed = false;
|
||||
|
||||
final String unmodifiable = command;
|
||||
final String firstArgUnmodifiable = StringUtils.getFirstArg(unmodifiable);
|
||||
|
||||
if (commands.stream().noneMatch(c -> StringUtils.getFirstArg(c).equalsIgnoreCase(firstArgUnmodifiable))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
commands = commands.stream().map(c -> {
|
||||
if (c.contains("%hidden")) {
|
||||
return c.replace("%hidden_", "%");
|
||||
@@ -147,6 +180,6 @@ public class ExecuteCommand extends ExecuteCommandEvent {
|
||||
}
|
||||
}
|
||||
|
||||
return turn == listed;
|
||||
return listed;
|
||||
}
|
||||
}
|
||||
@@ -13,20 +13,50 @@ public class TabCompletion extends FilteredTabCompletionEvent {
|
||||
|
||||
@Override
|
||||
public void handle(FilteredTabCompletionEvent event) {
|
||||
String cursor = StringUtils.replaceFirst(event.getCursor(), "/", "");
|
||||
final String cursor = event.getCursor().substring(1);
|
||||
|
||||
if (event.getCompletion().isEmpty()) return;
|
||||
|
||||
UUID uuid = event.getSenderObj() instanceof UUID
|
||||
final boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
final UUID uuid = event.getSenderObj() instanceof UUID
|
||||
? (UUID) event.getSenderObj()
|
||||
: CommandSenderHandler.from(event.getSenderObj()).getUniqueId();
|
||||
|
||||
Arguments arguments = SubArgsModule.PLAYER_COMMANDS.getOrDefault(uuid, Arguments.ARGUMENTS);
|
||||
List<String> possibilities = event.getCompletion(), result = new ArrayList<>(arguments.getResultTab(cursor));
|
||||
final Arguments arguments = SubArgsModule.PLAYER_COMMANDS.getOrDefault(uuid, Arguments.ARGUMENTS);
|
||||
|
||||
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
List<String> possibilities = event.getCompletion(), result = new ArrayList<>(arguments.getResultTab(cursor));
|
||||
final List<String> negated = new ArrayList<>(arguments.getResultTab("!" + cursor));
|
||||
|
||||
final List<String> negatedInputs = new ArrayList<>(arguments.TAB_ARGUMENTS.INPUTS).stream().filter(s -> {
|
||||
if (s.isEmpty())
|
||||
return false;
|
||||
|
||||
boolean n = s.charAt(0) == '!';
|
||||
|
||||
if (!n && s.length() > 5)
|
||||
n = s.charAt(5) == '!';
|
||||
|
||||
return n;
|
||||
}).map(s -> s.substring(1 + (s.charAt(0) == '[' ? 5 : 0))).toList();
|
||||
|
||||
if (negatedInputs.stream().anyMatch(cursor::startsWith)) {
|
||||
if (turn) {
|
||||
event.setCompletion(new ArrayList<>());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
result.removeIf(s -> s.contains("-_"));
|
||||
|
||||
if (turn) {
|
||||
possibilities = result;
|
||||
|
||||
if (possibilities.isEmpty() && !negated.isEmpty()) {
|
||||
possibilities = event.getCompletion();
|
||||
possibilities.removeAll(negated);
|
||||
}
|
||||
|
||||
if (result.contains("%numbers%")) {
|
||||
possibilities.remove("%numbers%");
|
||||
possibilities.addAll(event.getCompletion().stream().filter(NumberUtils::isDigit).toList());
|
||||
@@ -75,7 +105,6 @@ public class TabCompletion extends FilteredTabCompletionEvent {
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (result.contains("%numbers%"))
|
||||
possibilities.removeIf(NumberUtils::isDigit);
|
||||
|
||||
@@ -85,11 +114,18 @@ public class TabCompletion extends FilteredTabCompletionEvent {
|
||||
if (result.contains("%online_players%"))
|
||||
possibilities.removeIf(possibility -> SubArgsModule.getOnlinePlayerNames().contains(possibility));
|
||||
|
||||
possibilities.removeAll(result);
|
||||
|
||||
possibilities.removeIf(s -> {
|
||||
if (negated.contains(s)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return result.contains(s);
|
||||
});
|
||||
}
|
||||
|
||||
cursor = StringUtils.getFirstArg(cursor.toLowerCase());
|
||||
if (possibilities.isEmpty() && !SubArgsModule.GENERAL_LIST.contains(cursor)) {
|
||||
String firstCursorArg = StringUtils.getFirstArg(cursor.toLowerCase());
|
||||
if (possibilities.isEmpty() && !SubArgsModule.GENERAL_LIST.contains(firstCursorArg)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,11 +48,26 @@ public class UpdateList {
|
||||
for (String command : event.getCommands())
|
||||
argument.buildArgumentStacks(command);
|
||||
|
||||
for (String command : argument.CHAT_ARGUMENTS.getGeneralArgument().getInputs())
|
||||
argument.CHAT_ARGUMENTS.buildArguments(Storage.Blacklist.BlockTypeFetcher.modify(command));
|
||||
final List<String> chatInputs = new ArrayList<>(argument.CHAT_ARGUMENTS.getGeneralArgument().getInputs());
|
||||
final List<String> tabInput = new ArrayList<>(argument.TAB_ARGUMENTS.getGeneralArgument().getInputs());
|
||||
|
||||
for (String command : argument.TAB_ARGUMENTS.getGeneralArgument().getInputs())
|
||||
argument.TAB_ARGUMENTS.buildArguments(Storage.Blacklist.BlockTypeFetcher.modify(command));
|
||||
for (String command : chatInputs) {
|
||||
Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(command);
|
||||
|
||||
if (type != Storage.Blacklist.BlockType.NEGATE)
|
||||
command = Storage.Blacklist.BlockTypeFetcher.modify(command, type);
|
||||
|
||||
argument.CHAT_ARGUMENTS.buildArguments(Storage.Blacklist.BlockTypeFetcher.modify(command));
|
||||
}
|
||||
|
||||
for (String command : tabInput) {
|
||||
Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(command);
|
||||
|
||||
if (type != Storage.Blacklist.BlockType.NEGATE)
|
||||
command = Storage.Blacklist.BlockTypeFetcher.modify(command, type);
|
||||
|
||||
argument.TAB_ARGUMENTS.buildArguments(command);
|
||||
}
|
||||
|
||||
for (String command : SubArgsModule.getGroupCommands(uuid, serverName))
|
||||
argument.buildArgumentStacks(command);
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.info;
|
||||
|
||||
import de.rayzs.pat.plugin.listeners.bukkit.BukkitAntiTabListener;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class UpdateCommand extends ProCommand {
|
||||
@@ -19,17 +23,35 @@ public class UpdateCommand extends ProCommand {
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
if (args.length == 0) {
|
||||
PermissionUtil.reloadPermissions();
|
||||
|
||||
Storage.getLoader().getOnlinePlayerNames().forEach(name -> {
|
||||
Object playerObj = Storage.getLoader().getPlayerObjByName(name);
|
||||
|
||||
if (playerObj != null) {
|
||||
CommandSender s = CommandSenderHandler.from(playerObj);
|
||||
|
||||
assert s != null;
|
||||
PermissionUtil.reloadPermissions(s);
|
||||
}
|
||||
});
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
BukkitAntiTabListener.handleTabCompletion();
|
||||
}
|
||||
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.UPDATE_PERMISSIONS.UPDATE_ALL);
|
||||
return true;
|
||||
}
|
||||
|
||||
String name = args[0];
|
||||
UUID uuid = Storage.getLoader().getUUIDByName(name);
|
||||
Object playerObj = Storage.getLoader().getPlayerObjByUUID(uuid);
|
||||
CommandSender targetSender = CommandSenderHandler.from(playerObj);
|
||||
|
||||
boolean exist = uuid != null;
|
||||
boolean exist = targetSender != null;
|
||||
|
||||
if (exist) {
|
||||
name = Storage.getLoader().getNameByUUID(uuid);
|
||||
name = targetSender.getName();
|
||||
}
|
||||
|
||||
String message = exist
|
||||
@@ -39,7 +61,13 @@ public class UpdateCommand extends ProCommand {
|
||||
message = message.replace("%target%", name);
|
||||
|
||||
if (exist) {
|
||||
PermissionUtil.reloadPermissions(uuid);
|
||||
|
||||
PermissionUtil.reloadPermissions(targetSender);
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
BukkitAntiTabListener.handleTabCompletion(uuid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sender.sendMessage(message);
|
||||
@@ -48,6 +76,6 @@ public class UpdateCommand extends ProCommand {
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||
return args.length < 2 ? Storage.getLoader().getPlayerNames() : null;
|
||||
return args.length < 2 ? Storage.getLoader().getOnlinePlayerNames() : null;
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public class AddCommand extends ProCommand {
|
||||
if (Reflection.isProxyServer())
|
||||
return null;
|
||||
|
||||
return BukkitLoader.getAllowedCommands();
|
||||
return BukkitLoader.getDisallowedCommands();
|
||||
}
|
||||
|
||||
String fullString = String.join(" ", args);
|
||||
|
||||
@@ -60,9 +60,7 @@ public class RemoveCommand extends ProCommand {
|
||||
final int length = args.length;
|
||||
|
||||
if (length == 1) {
|
||||
boolean exist = command.contains(" ")
|
||||
? Storage.Blacklist.getBlacklist().getCommands().contains(command)
|
||||
: Storage.Blacklist.getBlacklist().isListed(command);
|
||||
boolean exist = Storage.Blacklist.getBlacklist().getCommands().contains(command);
|
||||
|
||||
if (exist) {
|
||||
Storage.Blacklist.getBlacklist().remove(command).save();
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.rayzs.pat.plugin.process.impl.local.system;
|
||||
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
@@ -25,7 +26,9 @@ public class ReloadCommand extends ProCommand {
|
||||
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();
|
||||
@@ -35,13 +38,12 @@ public class ReloadCommand extends ProCommand {
|
||||
BackendUpdater.start();
|
||||
}
|
||||
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
if (!backend) {
|
||||
Storage.handleChange();
|
||||
}
|
||||
|
||||
ConfigUpdater.initialize();
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
Storage.getLoader().handleReload();
|
||||
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.RELOAD.DONE);
|
||||
|
||||
@@ -15,7 +15,7 @@ public class CommandsCache {
|
||||
if (change || !isOutdated(commands))
|
||||
return;
|
||||
|
||||
filteredCommands = new LinkedList<>();
|
||||
LinkedList<String> tmpFilteredCommands = new LinkedList<>();
|
||||
allCommands = new ArrayList<>(commands);
|
||||
|
||||
for (String command : allCommands) {
|
||||
@@ -36,6 +36,7 @@ public class CommandsCache {
|
||||
|
||||
}
|
||||
|
||||
filteredCommands = tmpFilteredCommands;
|
||||
change = true;
|
||||
}
|
||||
|
||||
@@ -43,7 +44,7 @@ public class CommandsCache {
|
||||
if(!isOutdated(commands))
|
||||
return;
|
||||
|
||||
filteredCommands = new LinkedList<>();
|
||||
LinkedList<String> tmpFilteredCommands = new LinkedList<>();
|
||||
allCommands = new ArrayList<>(commands);
|
||||
|
||||
for (String command : allCommands) {
|
||||
@@ -53,7 +54,7 @@ public class CommandsCache {
|
||||
if (type != Storage.Blacklist.BlockType.BOTH && type != Storage.Blacklist.BlockType.TAB)
|
||||
continue;
|
||||
|
||||
if (isFilterListAvailable(server)) {
|
||||
if (isFilterListAvailable()) {
|
||||
if (filteredCommands.contains(command))
|
||||
continue;
|
||||
|
||||
@@ -62,6 +63,8 @@ public class CommandsCache {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
filteredCommands = tmpFilteredCommands;
|
||||
}
|
||||
|
||||
public List<String> getPlayerCommands(Collection<String> unfilteredCommands, Object targetObj, UUID uuid) {
|
||||
@@ -70,11 +73,23 @@ public class CommandsCache {
|
||||
|
||||
public List<String> getPlayerCommands(Collection<String> unfilteredCommands, Object targetObj, UUID uuid, String serverName) {
|
||||
List<String> playerCommands = new LinkedList<>(unfilteredCommands);
|
||||
List<String> localFilteredCommands = filteredCommands == null ? null : new LinkedList<>(filteredCommands);
|
||||
List<String> localFilteredCommands = filteredCommands == null ? null : new LinkedList<>();
|
||||
|
||||
if (localFilteredCommands == null)
|
||||
return playerCommands;
|
||||
|
||||
|
||||
|
||||
final int max = filteredCommands.size();
|
||||
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());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean hasNamespaceBypass = Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(targetObj);
|
||||
|
||||
@@ -90,12 +105,6 @@ public class CommandsCache {
|
||||
return !Storage.Blacklist.canPlayerAccessTab(targetObj, command, serverName);
|
||||
});
|
||||
|
||||
String uuidSubstring = uuid.toString().substring(uuid.toString().length() - 5);
|
||||
if(playerCommands.isEmpty())
|
||||
Logger.debug("Commands list for player with uuid " + uuidSubstring + " is empty! (" + (filteredCommands != null ? filteredCommands.size() : "null") + " | " + (unfilteredCommands != null ? unfilteredCommands.size() : "null") + ")");
|
||||
else
|
||||
Logger.debug("Created list of commands for player with uuid " + uuidSubstring + " with a total of " + playerCommands.size() + " commands!");
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(targetObj, playerCommands, serverName != null);
|
||||
|
||||
return playerCommands.stream().map(command -> {
|
||||
@@ -111,15 +120,7 @@ public class CommandsCache {
|
||||
}
|
||||
|
||||
public boolean isFilterListAvailable() {
|
||||
return isFilterListAvailable(null);
|
||||
}
|
||||
|
||||
public boolean isFilterListAvailable(String server) {
|
||||
boolean available = this.filteredCommands != null;
|
||||
if(!available)
|
||||
Logger.debug("FilterList didn't exist during built!" + (server != null ? "(server: " + server + ")" : ""));
|
||||
|
||||
return available;
|
||||
return this.filteredCommands != null;
|
||||
}
|
||||
|
||||
public void updateChangeState() {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package de.rayzs.pat.utils;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class LimitedList<T> {
|
||||
|
||||
private ArrayDeque<T> list = new ArrayDeque<>();
|
||||
private final int maxCapacity;
|
||||
|
||||
public LimitedList(int maxCapacity) {
|
||||
this.maxCapacity = maxCapacity;
|
||||
}
|
||||
|
||||
public LimitedList(LimitedList<T> list) {
|
||||
this.maxCapacity = list.maxCapacity;
|
||||
this.list = new ArrayDeque<>(list.getList());
|
||||
}
|
||||
|
||||
public void add(T element) {
|
||||
if (list.size() == maxCapacity) {
|
||||
list.removeFirst();
|
||||
}
|
||||
|
||||
list.add(element);
|
||||
}
|
||||
|
||||
public void iterate(Consumer<T> action) {
|
||||
list.forEach(action);
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public int getMaxCapacity() {
|
||||
return maxCapacity;
|
||||
}
|
||||
|
||||
private ArrayDeque<T> getList() {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package de.rayzs.pat.utils;
|
||||
|
||||
public class NumberUtils {
|
||||
|
||||
private static final char[] EXCEPTIONS = {'.', ',', 'k', 'm', 'b'};
|
||||
|
||||
public static boolean isBetween(int n, int l, int r) {
|
||||
int min = Math.min(l, r);
|
||||
int max = Math.max(l, r);
|
||||
@@ -16,10 +18,9 @@ public class NumberUtils {
|
||||
int length = str.length();
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
||||
char c = str.charAt(i);
|
||||
|
||||
if (c == '.' || c == ',')
|
||||
if (isExceptionalDigit(c))
|
||||
continue;
|
||||
|
||||
if (!Character.isDigit(c))
|
||||
@@ -28,4 +29,17 @@ public class NumberUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isExceptionalDigit(char c) {
|
||||
for (char q : EXCEPTIONS) {
|
||||
if (c == q) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Character.isAlphabetic(c) && c == Character.toUpperCase(q)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,10 @@ public class Reflection {
|
||||
proxy = false;
|
||||
} catch (Throwable ignored) { proxy = true; }
|
||||
|
||||
if(!proxy) {
|
||||
if (!proxy) {
|
||||
try {
|
||||
Class.forName("com.destroystokyo.paper.proxy.VelocityProxy");
|
||||
folia = versionName.toLowerCase().contains("folia");
|
||||
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
|
||||
folia = true;
|
||||
} catch (Throwable throwable) {
|
||||
folia = false;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class Reflection {
|
||||
}
|
||||
}
|
||||
|
||||
if(proxy) {
|
||||
if (proxy) {
|
||||
try {
|
||||
Class.forName("com.velocitypowered.api.proxy.ProxyServer");
|
||||
velocity = true;
|
||||
@@ -58,6 +58,10 @@ public class Reflection {
|
||||
oldChannelMethod = folia || paper && Reflection.isWeird();
|
||||
}
|
||||
|
||||
public static void toggleInjectionMethod() {
|
||||
oldChannelMethod = !oldChannelMethod;
|
||||
}
|
||||
|
||||
|
||||
public static String getVersionPackageName() {return versionPackageName;}
|
||||
public static int[] getAges() { return new int[]{major, minor, release}; }
|
||||
|
||||
@@ -83,7 +83,7 @@ public class BukkitConfigurationBuilder implements ConfigurationBuilder {
|
||||
|
||||
if (fileName.equals("config")) {
|
||||
if (!ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart(path + "." + target);
|
||||
ConfigUpdater.addMissingPart((!path.isBlank() ? path + "." : "") + target);
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ProxyConfigurationBuilder implements ConfigurationBuilder {
|
||||
|
||||
if (fileName.equals("config")) {
|
||||
if (!ConfigUpdater.shouldAutoUpdate()) {
|
||||
ConfigUpdater.addMissingPart(path + "." + target);
|
||||
ConfigUpdater.addMissingPart((!path.isBlank() ? path + "." : "") + target);
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@ import java.util.*;
|
||||
|
||||
public class ConfigUpdater {
|
||||
|
||||
private static List<String> NEWEST_CONFIG_INPUT = new ArrayList<>(),
|
||||
MISSING_PARTS = new ArrayList<>();
|
||||
private static final List<String> MISSING_PARTS = new ArrayList<>();
|
||||
|
||||
private static boolean LOADED = false, AUTO_UPDATE = false, ANNOUNCE = false;
|
||||
|
||||
@@ -22,19 +21,19 @@ public class ConfigUpdater {
|
||||
HOW_TO_READ_FILE_NAME = "How-To-Read.txt";
|
||||
|
||||
public static void initialize() {
|
||||
try {
|
||||
MISSING_PARTS.clear();
|
||||
LOADED = false;
|
||||
MISSING_PARTS.clear();
|
||||
|
||||
try {
|
||||
ConfigurationBuilder config = Configurator.get("config");
|
||||
|
||||
ANNOUNCE = (boolean) config.getOrSet("updater.announce-missing-parts", true);
|
||||
AUTO_UPDATE = (boolean) config.getOrSet("updater.auto-update-config", false);
|
||||
|
||||
LOADED = true;
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("Failed to find section 'updater.auto-config-updater' in config.yml!");
|
||||
}
|
||||
|
||||
LOADED = true;
|
||||
}
|
||||
|
||||
public static boolean shouldAutoUpdate() {
|
||||
@@ -69,9 +68,6 @@ public class ConfigUpdater {
|
||||
if (!ANNOUNCE)
|
||||
return;
|
||||
|
||||
List<String> configInput = new LinkedList<>(Arrays.asList("# WARNING: This file is auto generated and its sole purpose is to be used as comparison!\n# WARNING: It will be deleted once this file is no longer needed.", " ", " "));
|
||||
configInput.addAll(NEWEST_CONFIG_INPUT);
|
||||
|
||||
Configurator.createResourcedFile(
|
||||
"files\\" + (Reflection.isProxyServer() ? "proxy" : "bukkit") + "-config.yml",
|
||||
COMPARABLE_FILE_NAME,
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package de.rayzs.pat.utils.group;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.BlacklistCreator;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GroupBlacklist;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.configuration.ConfigurationBuilder;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
|
||||
@@ -58,6 +56,37 @@ public class Group implements Serializable {
|
||||
loadServerBlacklist();
|
||||
}
|
||||
|
||||
public String getGroupInfo() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(" groupName: ")
|
||||
.append(groupName).append("\n")
|
||||
.append(" priority: ")
|
||||
.append(priority).append("\n");
|
||||
|
||||
builder.append(" commands: ")
|
||||
.append(String.join(", ", getCommands()))
|
||||
.append("\n");
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
builder.append(" servers:\n");
|
||||
|
||||
for (Map.Entry<String, GroupBlacklist> entry : groupServerBlacklist.entrySet()) {
|
||||
builder.append(" ")
|
||||
.append(entry.getKey())
|
||||
.append(": ");
|
||||
|
||||
for (GroupBlacklist blacklist : getAllServerGroupBlacklist(entry.getKey())) {
|
||||
builder.append(String.join(", ", blacklist.getCommands()));
|
||||
builder.append(", ");
|
||||
}
|
||||
|
||||
builder.append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private void loadServerBlacklist() {
|
||||
String path = "groups." + groupName + ".servers";
|
||||
|
||||
@@ -152,15 +181,16 @@ public class Group implements Serializable {
|
||||
|
||||
GroupBlacklist groupBlacklist;
|
||||
|
||||
if (this.groupServerBlacklist.containsKey(server) && this.groupServerBlacklist.get(server) != null)
|
||||
if (this.groupServerBlacklist.get(server) != null)
|
||||
groupBlacklist = this.groupServerBlacklist.get(server);
|
||||
else {
|
||||
groupBlacklist = BlacklistCreator.createGroupBlacklist(this.groupName, server, ignoreExist);
|
||||
this.groupServerBlacklist.put(server, groupBlacklist);
|
||||
}
|
||||
|
||||
if (groupBlacklist != null)
|
||||
groupBlacklist.load();
|
||||
if (groupBlacklist != null) {
|
||||
groupBlacklist.load();
|
||||
this.groupServerBlacklist.put(server, groupBlacklist);
|
||||
}
|
||||
}
|
||||
|
||||
return groupBlacklist;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,10 @@ import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.Storage.Blacklist.BlockType;
|
||||
import de.rayzs.pat.api.storage.blacklist.BlacklistCreator;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GroupBlacklist;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
|
||||
public class GroupManager {
|
||||
|
||||
@@ -57,29 +60,46 @@ public class GroupManager {
|
||||
}
|
||||
|
||||
public static boolean canAccessCommand(Object targetObj, String unmodifiedCommand, Storage.Blacklist.BlockType type, String server) {
|
||||
final List<Group> playerGroups = getPlayerGroups(targetObj);
|
||||
final CommandSender sender = CommandSenderHandler.from(targetObj);
|
||||
|
||||
if(playerGroups.isEmpty()) {
|
||||
if (sender == null) {
|
||||
Logger.warning("Failed to load player! (GroupManager#62)");
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<Group> playerGroups = sender.getGroups();
|
||||
|
||||
if (playerGroups == null || playerGroups.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String command = type.toString() + unmodifiedCommand;
|
||||
|
||||
boolean permitted = playerGroups.stream().anyMatch(group -> {
|
||||
if (group == null)
|
||||
return false;
|
||||
boolean permitted = false;
|
||||
for (Group group : playerGroups) {
|
||||
|
||||
permitted = group.contains(command);
|
||||
|
||||
if (permitted) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (server != null) {
|
||||
|
||||
List<String> servers = group.getBlacklistServerNames(server);
|
||||
|
||||
for (String s : servers) {
|
||||
if (group.contains(command, s))
|
||||
return true;
|
||||
|
||||
if (group.contains(command, s)) {
|
||||
permitted = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return group.contains(command);
|
||||
});
|
||||
}
|
||||
|
||||
if (!permitted && type != BlockType.BOTH)
|
||||
return canAccessCommand(targetObj, unmodifiedCommand, Storage.Blacklist.BlockType.BOTH, server);
|
||||
|
||||
@@ -41,8 +41,13 @@ public class PermissionMap {
|
||||
}
|
||||
|
||||
public PermissionState getPermissionState(String permission) {
|
||||
if(!hasPermissionState(permission)) return PermissionState.EMPTY;
|
||||
return permissionMap.get(permission) ? PermissionState.PERMITTED : PermissionState.DENIED;
|
||||
if (!hasPermissionState(permission)) {
|
||||
return PermissionState.EMPTY;
|
||||
}
|
||||
|
||||
return permissionMap.get(permission)
|
||||
? PermissionState.PERMITTED
|
||||
: PermissionState.DENIED;
|
||||
}
|
||||
|
||||
public boolean hasPermissionState(String permission) {
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package de.rayzs.pat.utils.permission;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
|
||||
@@ -19,15 +17,24 @@ public class PermissionUtil {
|
||||
}
|
||||
|
||||
public static void reloadPermissions() {
|
||||
MAP.keySet().forEach(PermissionUtil::reloadPermissions);
|
||||
List<UUID> uuids = new ArrayList<>(MAP.keySet());
|
||||
uuids.forEach(PermissionUtil::reloadPermissions);
|
||||
}
|
||||
|
||||
public static void reloadPermissions(UUID uuid) {
|
||||
if (!MAP.containsKey(uuid))
|
||||
return;
|
||||
|
||||
MAP.get(uuid).clear();
|
||||
resetPermissions(uuid);
|
||||
setPlayerPermissions(uuid);
|
||||
|
||||
CommandSender sender = CommandSenderHandler.getSenderFromUUID(uuid);
|
||||
if (sender != null) {
|
||||
sender.updateGroups();
|
||||
}
|
||||
}
|
||||
|
||||
public static void reloadPermissions(CommandSender sender) {
|
||||
resetPermissions(sender.getUniqueId());
|
||||
setPlayerPermissions(sender);
|
||||
sender.updateGroups();
|
||||
}
|
||||
|
||||
public static String getPermissionsAsString(UUID uuid) {
|
||||
@@ -41,17 +48,32 @@ public class PermissionUtil {
|
||||
|
||||
public static Set<String> getPermissions(UUID uuid) {
|
||||
PermissionMap permissionMap = MAP.get(uuid);
|
||||
if(permissionMap == null) return null;
|
||||
if(permissionMap == null)
|
||||
return null;
|
||||
|
||||
return permissionMap.getHashedPermissions();
|
||||
}
|
||||
|
||||
public static void setPlayerPermissions(CommandSender sender) {
|
||||
if (Storage.USE_LUCKPERMS) {
|
||||
LuckPermsAdapter.setPermissions(sender.getUniqueId());
|
||||
} else {
|
||||
GroupManager.getGroups().forEach(group -> group.hasPermission(sender));
|
||||
}
|
||||
}
|
||||
|
||||
public static void setPlayerPermissions(UUID uuid) {
|
||||
if (Storage.USE_LUCKPERMS)
|
||||
if (Storage.USE_LUCKPERMS) {
|
||||
LuckPermsAdapter.setPermissions(uuid);
|
||||
} else {
|
||||
GroupManager.getGroups().forEach(group -> group.hasPermission(uuid));
|
||||
}
|
||||
}
|
||||
|
||||
public static void resetPermissions(UUID uuid) {
|
||||
if(!MAP.containsKey(uuid)) return;
|
||||
if (!MAP.containsKey(uuid))
|
||||
return;
|
||||
|
||||
MAP.get(uuid).clear();
|
||||
}
|
||||
|
||||
@@ -86,7 +108,7 @@ public class PermissionUtil {
|
||||
uuid = sender.getUniqueId();
|
||||
}
|
||||
|
||||
if(!MAP.containsKey(uuid)) {
|
||||
if (!MAP.containsKey(uuid)) {
|
||||
MAP.put(uuid, new PermissionMap(uuid));
|
||||
return false;
|
||||
}
|
||||
@@ -94,20 +116,22 @@ public class PermissionUtil {
|
||||
permissionMap = MAP.get(uuid);
|
||||
|
||||
if (sender != null) {
|
||||
|
||||
if (!Storage.USE_LUCKPERMS) {
|
||||
if (permissionMap.hasPermissionState("*"))
|
||||
|
||||
if (!permissionMap.hasPermissionState("*"))
|
||||
permissionMap.setState("*", sender.hasPermission("*"));
|
||||
|
||||
if (permissionMap.hasPermissionState("proantitab.*"))
|
||||
if (!permissionMap.hasPermissionState("proantitab.*"))
|
||||
permissionMap.setState("proantitab.*", sender.hasPermission("proantitab.*"));
|
||||
|
||||
if (permissionMap.hasPermissionState("proantitab." + permission))
|
||||
if (!permissionMap.hasPermissionState("proantitab." + permission))
|
||||
permissionMap.setState("proantitab." + permission, sender.hasPermission("proantitab." + permission));
|
||||
|
||||
}
|
||||
|
||||
if (sender.isOperator())
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
return true;
|
||||
if (sender.isOperator() && !Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
return true;
|
||||
}
|
||||
|
||||
return permissionMap.isPermitted("*") || permissionMap.isPermitted("proantitab.*") || permissionMap.isPermitted("proantitab." + permission);
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package de.rayzs.pat.utils.sender;
|
||||
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface CommandSender {
|
||||
@@ -17,5 +20,8 @@ public interface CommandSender {
|
||||
String getName();
|
||||
String getServerName();
|
||||
|
||||
List<Group> getGroups();
|
||||
void updateGroups();
|
||||
|
||||
void sendMessage(String message);
|
||||
}
|
||||
@@ -1,10 +1,18 @@
|
||||
package de.rayzs.pat.utils.sender;
|
||||
|
||||
import java.util.UUID;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
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);
|
||||
|
||||
public CommandSenderAbstract(Object senderObj) {
|
||||
this.senderObj = senderObj;
|
||||
@@ -14,4 +22,19 @@ public abstract class CommandSenderAbstract implements CommandSender {
|
||||
public Object getSenderObject() {
|
||||
return senderObj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Group> getGroups() {
|
||||
final List<Group> groupList = groups.get(KEY);
|
||||
|
||||
if (groupList == null) {
|
||||
return groups.putAndGet(KEY, GroupManager.getPlayerGroups(getUniqueId()));
|
||||
}
|
||||
|
||||
return groupList;
|
||||
}
|
||||
|
||||
protected void setGroups(List<Group> groups) {
|
||||
this.groups.putIgnoreIfContains(KEY, groups);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,10 @@ public class CommandSenderHandler {
|
||||
private static final ExpireCache<UUID, CommandSender> CACHE = new ExpireCache<>(1, TimeUnit.HOURS);
|
||||
|
||||
|
||||
public static CommandSender getSenderFromUUID(UUID uuid) {
|
||||
return CACHE.get(uuid);
|
||||
}
|
||||
|
||||
public static CommandSender from(Object senderObj) {
|
||||
UUID uuid = extractUUID(senderObj);
|
||||
|
||||
@@ -31,8 +35,9 @@ public class CommandSenderHandler {
|
||||
sender = new BukkitSender(senderObj);
|
||||
}
|
||||
|
||||
if (sender.getUniqueId() == null)
|
||||
if (sender.getUniqueId() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return CACHE.putAndGet(uuid, sender);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.rayzs.pat.utils.sender.impl;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderAbstract;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
@@ -26,6 +27,7 @@ public class BukkitSender extends CommandSenderAbstract {
|
||||
this.uuid = player.getUniqueId();
|
||||
this.console = false;
|
||||
|
||||
updateGroups();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,11 +44,6 @@ public class BukkitSender extends CommandSenderAbstract {
|
||||
this.console = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSenderObject() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConsole() {
|
||||
return this.console;
|
||||
@@ -91,4 +88,9 @@ public class BukkitSender extends CommandSenderAbstract {
|
||||
|
||||
sender.sendMessage(MessageTranslator.replaceMessage(sender, message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGroups() {
|
||||
setGroups(GroupManager.getPlayerGroups(this.uuid));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.rayzs.pat.utils.sender.impl;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderAbstract;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
@@ -27,6 +28,7 @@ public class BungeeSender extends CommandSenderAbstract {
|
||||
this.uuid = player.getUniqueId();
|
||||
this.console = false;
|
||||
|
||||
updateGroups();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,11 +45,6 @@ public class BungeeSender extends CommandSenderAbstract {
|
||||
this.console = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSenderObject() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConsole() {
|
||||
return this.console;
|
||||
@@ -94,4 +91,9 @@ public class BungeeSender extends CommandSenderAbstract {
|
||||
|
||||
sender.sendMessage(MessageTranslator.replaceMessage(sender, message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGroups() {
|
||||
setGroups(GroupManager.getPlayerGroups(this.uuid));
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package de.rayzs.pat.utils.sender.impl;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderAbstract;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
@@ -27,6 +28,7 @@ public class VelocitySender extends CommandSenderAbstract {
|
||||
this.uuid = player.getUniqueId();
|
||||
this.console = false;
|
||||
|
||||
updateGroups();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,11 +45,6 @@ public class VelocitySender extends CommandSenderAbstract {
|
||||
this.console = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSenderObject() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConsole() {
|
||||
return this.console;
|
||||
@@ -89,4 +86,9 @@ public class VelocitySender extends CommandSenderAbstract {
|
||||
public void sendMessage(String message) {
|
||||
MessageTranslator.send(sender, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGroups() {
|
||||
setGroups(GroupManager.getPlayerGroups(this.uuid));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.rayzs.pat.utils.subargs;
|
||||
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ArgumentBuilder {
|
||||
@@ -15,7 +17,7 @@ public class ArgumentBuilder {
|
||||
}
|
||||
|
||||
public List<String> getResult(String input) {
|
||||
String firstInputArg = input.contains(" ") ? input.split(" ")[0] : input;
|
||||
String firstInputArg = StringUtils.getFirstArg(input);
|
||||
|
||||
for (Map.Entry<String, ArgumentStack> entry : source.ARGUMENT_STACKS.entrySet()) {
|
||||
if (!entry.getKey().equals(firstInputArg))
|
||||
|
||||
@@ -12,9 +12,12 @@ public class ArgumentSource {
|
||||
public final HashMap<String, ArgumentStack> ARGUMENT_STACKS = new HashMap<>();
|
||||
|
||||
public ArgumentBuilder getGeneralArgument() {
|
||||
/* Experimental removal
|
||||
ArgumentBuilder copiedGeneralArguments = new ArgumentBuilder(this);
|
||||
GENERAL.getInputs().forEach(copiedGeneralArguments::buildArgumentStacks);
|
||||
return copiedGeneralArguments;
|
||||
*/
|
||||
return GENERAL;
|
||||
}
|
||||
|
||||
public List<String> getOptions(String input) {
|
||||
|
||||
@@ -23,7 +23,9 @@ public class Arguments {
|
||||
|
||||
public void buildArgumentStacks(String input) {
|
||||
Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(input);
|
||||
input = Storage.Blacklist.BlockTypeFetcher.modify(input, type);
|
||||
if (type != Storage.Blacklist.BlockType.NEGATE) {
|
||||
input = Storage.Blacklist.BlockTypeFetcher.modify(input, type);
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case TAB:
|
||||
|
||||
@@ -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.8
|
||||
version: 2.0.17
|
||||
main: de.rayzs.pat.plugin.BungeeLoader
|
||||
|
||||
softDepends: [LuckPerms, PAPIProxyBridge]
|
||||
@@ -54,6 +54,15 @@ handle-through-proxy:
|
||||
# Enabling this will disable ALL commands except for those that are in the (group-)list.
|
||||
turn-blacklist-to-whitelist: true
|
||||
|
||||
# This decides whether PAT ignores or detects whether a command is written in upper/-lower cased letters.
|
||||
# Here are a few examples if this option is enabled:
|
||||
# Example with allowing the command "HelP"
|
||||
# /help --> Blocked
|
||||
# /Help --> Blocked
|
||||
# /HelP --> Allowed
|
||||
# Pro tip: You can also just use auto-lowercase-commands feature instead. ^^
|
||||
base-command-case-sensitive: true
|
||||
|
||||
# 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!
|
||||
# (!) Supported server versions: 1.12.2 - latest
|
||||
|
||||
@@ -1,28 +1,33 @@
|
||||
Confused about the display of missing parts in the console?
|
||||
It's actually quite easy to read and I'll show you how its done! :D
|
||||
|
||||
Let's take the for the following missing path:
|
||||
Missing parts are written in this format right here: xyz.zyx.idk
|
||||
A more befitting example would be something like:
|
||||
--> test-feature.enabled
|
||||
|
||||
In the config.yml, this would look like this:
|
||||
|
||||
|
||||
test-feature:
|
||||
enabled: true
|
||||
test-feature:
|
||||
enabled: true
|
||||
|
||||
|
||||
Now another example with something more fitting to your case:
|
||||
Here's another example of this format:
|
||||
--> info.version.updated
|
||||
|
||||
In the config.yml, this would look like this:
|
||||
|
||||
info:
|
||||
version:
|
||||
updated: ...
|
||||
|
||||
info:
|
||||
version:
|
||||
updated: ...
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
Then what should I copy or how should I transfer the information from the one to the other config.yml?
|
||||
Now that we know how things from the missing parts look like in the config.yml, let's go over to the more important part.
|
||||
Inserting the missing parts to your current config.yml. But how and what exactly?
|
||||
|
||||
Well, it's actually quite easy. Just take a look on what is missing.
|
||||
If PAT says, something like this is missing:
|
||||
- test-feature.enabled
|
||||
@@ -31,14 +36,45 @@ If PAT says, something like this is missing:
|
||||
|
||||
Then this basically just means, that the entire section for "test-feature" is missing.
|
||||
In other words, check the "comparable-config.yml" and look for the "test-feature" section.
|
||||
It would look like this:
|
||||
It would look like this for example:
|
||||
|
||||
|
||||
test-feature:
|
||||
enabled: true
|
||||
message: "Hello World"
|
||||
failed: "Error ;c"
|
||||
|
||||
test-feature:
|
||||
enabled: true
|
||||
message: "Hello World"
|
||||
failed: "Error ;c"
|
||||
|
||||
Just copy the entire thing and paste it somewhere in the config.yml.
|
||||
Once you've reloaded the plugin then, using "/(b)pat reload", everything should work fine.
|
||||
|
||||
If something went wrong, PAT will let you know! ^^
|
||||
If something went wrong, PAT will let you know! ^^
|
||||
|
||||
|
||||
Here's a more close to your case example. Let's say your config.yml looks like this:
|
||||
|
||||
handle-through-proxy:
|
||||
...
|
||||
|
||||
turn-blacklist-to-whitelist: true
|
||||
|
||||
custom-protocol-ping:
|
||||
...
|
||||
|
||||
|
||||
and now let's say PAT says that "base-command-case-sensitive" is missing.
|
||||
Then this would be what PAT is looking for as solution:
|
||||
|
||||
handle-through-proxy:
|
||||
...
|
||||
|
||||
turn-blacklist-to-whitelist: true
|
||||
|
||||
base-command-case-sensitive: true/false
|
||||
|
||||
custom-protocol-ping:
|
||||
...
|
||||
|
||||
|
||||
On how exactly it needs to be implemented can be seen in the comparison-config.yml file,
|
||||
as this is the original version which would be generated by default.
|
||||
@@ -40,6 +40,14 @@ disable-sync: false
|
||||
# Enabling this will disable ALL commands except for those that are in the (group-)list.
|
||||
turn-blacklist-to-whitelist: true
|
||||
|
||||
# This decides whether PAT ignores or detects whether a command is written in upper/-lower cased letters.
|
||||
# Here are a few examples if this option is enabled:
|
||||
# Example with allowing the command "HelP"
|
||||
# /help --> Blocked
|
||||
# /Help --> Blocked
|
||||
# /HelP --> Allowed
|
||||
base-command-case-sensitive: true
|
||||
|
||||
# Here you can customize the server version that is displayed on a ping. (The text at the player-count)
|
||||
custom-protocol-ping:
|
||||
enabled: true
|
||||
|
||||
@@ -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.8
|
||||
version: 2.0.17
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
main: de.rayzs.pat.plugin.BukkitLoader
|
||||
|
||||
Reference in new issue
Block a user