Compare commits

...
68 Commits
Author SHA1 Message Date
RayzsYT a453d7999e Changed warning for disable-sync 2025-02-26 19:56:41 +01:00
RayzsYT 07aad19fec Added "about" to custom-version feature 2025-02-26 19:46:38 +01:00
RayzsYT 1c4213da64 Integrated "disable sync" option 2025-02-25 16:37:50 +01:00
RayzsYT 5d27e7ee9a Update version 2025-02-25 16:28:06 +01:00
RayzsYT 3805d433f9 Add "disable sync" option 2025-02-25 16:21:58 +01:00
RayzsYT 4d66b8e540 Update libraries 2025-02-11 00:51:58 +01:00
RayzsYT 9aae436e13 Minor change 2025-02-11 00:51:42 +01:00
RayzsYT 406cec7683 Removed debug messages 2025-02-10 20:36:44 +01:00
RayzsYT 9360f5d6e4 Fix issue with no tab-completion for some sub-arguments if base is the same 2025-02-10 20:32:09 +01:00
RayzsYT 8446537b3b Remove : commands from default list 2025-02-10 16:42:04 +01:00
RayzsYT d5ed2242c0 Modified custom-plugins and custom-features default list a bit 2025-02-10 16:40:24 +01:00
RayzsYT 88dc1887f5 Outcommented code snip 2025-02-10 15:09:35 +01:00
RayzsYT 9177b3005b Improve detection performance 2025-02-10 15:09:23 +01:00
RayzsYT 6940bfb291 Add alwaysTabable option 2025-02-10 14:28:45 +01:00
RayzsYT 11f8900140 Fix -1 brand value issue 2025-02-10 02:54:22 +01:00
RayzsYT 8fd9eb0d2e Fixed wrong permission display 2025-02-10 01:34:09 +01:00
RayzsYT c2a4507697 Added small warning to description 2025-02-10 01:25:55 +01:00
RayzsYT a934eb24f7 Tiny code cleanup 2025-02-09 23:54:10 +01:00
RayzsYT 6d0535819b Tiny changes 2025-02-05 03:53:31 +01:00
RayzsYT 6e5f7cc980 Attempt to add Skript support 2025-02-05 02:04:35 +01:00
RayzsYT f6e77c04fa Refactored the code a bit 2025-02-04 20:38:40 +01:00
RayzsYT f9a133a1ed Improve Per-Group command execution 2025-01-30 23:37:24 +01:00
RayzsYT faa67160d0 Fix Folia support 2025-01-30 21:32:30 +01:00
RayzsYT 79e17de03b Fix Folia 1.21.1 support 2024-12-22 22:20:01 +01:00
RayzsYT 7c67f8d9e4 Add PlaceholderAPI support for ProtocolPing 2024-12-22 21:37:31 +01:00
RayzsYT 62639961d2 Fixed wrong section-target name 2024-12-22 00:09:46 +01:00
RayzsYT 8fe56347fc Fixed duplicating config.yml file bug 2024-12-22 00:07:28 +01:00
RayzsYT 38b622b9dc Integrated AutoUpdateConfig option 2024-12-21 19:40:10 +01:00
RayzsYT dadd9724eb Add AutoUpdateConfig option 2024-12-21 19:23:33 +01:00
RayzsYT ad8406f4a2 Add timeout method 2024-12-21 19:13:51 +01:00
RayzsYT 2f0ee0c278 Remove debug message 2024-11-10 20:56:28 +01:00
RayzsYT 6c48c979d7 Added containsIgnoreCase method 2024-11-10 20:31:00 +01:00
RayzsYT 74dab5fb09 Added usage of new containsIgnoreCase from ArrayUtils.java 2024-11-10 20:30:50 +01:00
RayzsYT b8faadc9ba Added unchanged playerInput variable (rawPlayerInput) 2024-11-10 20:20:53 +01:00
RayzsYT b8964bc843 Changed description of example 2024-11-10 17:22:53 +01:00
RayzsYT 1b8e69da9d Remove String colorcode replacement 2024-11-10 17:18:49 +01:00
RayzsYT 1a5de85eb9 Replace String 2024-11-10 17:17:56 +01:00
RayzsYT 918c901850 Fix actionbar <1.16 issue 2024-11-10 17:11:40 +01:00
RayzsYT 7104b885d5 Add getVersionPackageName method 2024-11-10 17:11:24 +01:00
RayzsYT 73d8d70661 Remove <hint> if no arguments exist 2024-11-10 16:45:46 +01:00
RayzsYT 53ce663032 Expanded description 2024-11-10 16:32:43 +01:00
RayzsYT b3d842cac2 Modified text replacements 2024-11-10 16:32:34 +01:00
RayzsYT 75089456b2 Changed values in example 2024-11-10 15:54:47 +01:00
RayzsYT 4744ae0037 Minor version-detection change 2024-11-10 15:51:32 +01:00
RayzsYT af1e285f8c Change description and fixed double console command execution 2024-11-10 15:48:20 +01:00
RayzsYT a75a71b6e7 Changed description 2024-11-10 15:38:27 +01:00
RayzsYT 7128f7cd74 Add actionbar 2024-11-10 15:32:46 +01:00
RayzsYT f5191580cf Improve Action system 2024-11-10 15:20:50 +01:00
RayzsYT fdef5b45b0 Removed unused import 2024-11-10 05:50:55 +01:00
RayzsYT 82a2fb1513 Add %player% variable to sendTitle method & removed old executeActions method 2024-11-10 05:50:08 +01:00
RayzsYT 7b627dd1b1 Add %player% variable to sendTitle method 2024-11-10 05:49:49 +01:00
RayzsYT d247850218 Fixed wrong description 2024-11-10 05:46:43 +01:00
RayzsYT c9d91d1d16 Made title more configurable 2024-11-10 05:39:01 +01:00
RayzsYT 4173e11105 Replace %player% placeholder in executeConsoleCommand method 2024-11-10 05:34:03 +01:00
RayzsYT 42d5b0b201 Add uuid to executeConsoleCommand parameters and adjust PlaceholderAPI replacements 2024-11-10 05:29:02 +01:00
RayzsYT 1baa12e007 Add uuid to executeConsoleCommand parameters 2024-11-10 05:28:48 +01:00
RayzsYT 3e99cb44b2 Add uuid 2024-11-10 05:28:12 +01:00
RayzsYT 2ecafd5c6c Add effect action 2024-11-10 05:19:39 +01:00
RayzsYT ef8b8d619a Add giveEffect method 2024-11-10 05:15:43 +01:00
RayzsYT 0f88b3f799 Add example to playSound method 2024-11-10 05:09:44 +01:00
RayzsYT 39301e8622 Adjust new customizable actions 2024-11-10 04:54:20 +01:00
RayzsYT cf77cae518 Added customizable actions 2024-11-10 04:52:21 +01:00
RayzsYT f37bdf4c07 Added methods 2024-11-10 04:52:05 +01:00
RayzsYT f7d44f4085 Added more versions just in case 2024-11-10 02:56:24 +01:00
RayzsYT 285c8125bd Updated version 2024-11-09 21:48:47 +01:00
RayzsYT 7c38083e64 Fixed possible ModificationException 2024-11-09 21:48:01 +01:00
RayzsYT b8dde730f5 Fixed player-variables issues 2024-11-09 21:47:20 +01:00
RayzsYT cce9722a66 Add replaceLast method 2024-11-09 21:46:46 +01:00
52 changed files with 1101 additions and 168 deletions

No files matched your search

+18 -5
View File
@@ -6,7 +6,7 @@
<groupId>de.rayzs.pat</groupId>
<artifactId>ProAntiTab</artifactId>
<version>1.9.0</version>
<version>1.9.2</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
@@ -72,10 +72,23 @@
<url>https://repo.william278.net/papiproxybridge</url>
</repository>
<repository>
<id>skript-releases</id>
<name>Skript Repository</name>
<url>https://repo.skriptlang.org/releases</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.skriptlang</groupId>
<artifactId>Skript</artifactId>
<version>2.10.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dev.folia</groupId>
<artifactId>folia-api</artifactId>
@@ -220,28 +233,28 @@
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.15.0</version>
<version>4.18.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.17.0</version>
<version>4.18.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-api</artifactId>
<version>4.3.2</version>
<version>4.3.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bungeecord</artifactId>
<version>4.3.2</version>
<version>4.3.3</version>
<scope>compile</scope>
</dependency>
@@ -63,7 +63,8 @@ public class BukkitServerBrand implements ServerBrand {
PATScheduler.createAsyncScheduler(() -> {
Bukkit.getOnlinePlayers().forEach(this::send);
}, 1, Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY);
}, 1, 1);
} else {
AtomicInteger animationState = new AtomicInteger(0);
TASK = PATScheduler.createAsyncScheduler(() -> {
@@ -101,6 +101,8 @@ public class Communicator {
}
public static void syncData(String serverId) {
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) return;
LAST_DATA_UPDATE = System.currentTimeMillis();
ClientInfo clientInfo;
if(serverId == null) {
@@ -1,5 +1,6 @@
package de.rayzs.pat.api.communication.impl;
import de.rayzs.pat.utils.scheduler.PATScheduler;
import org.bukkit.plugin.messaging.PluginMessageListener;
import de.rayzs.pat.utils.CommunicationPackets;
import de.rayzs.pat.plugin.BukkitLoader;
@@ -29,7 +30,7 @@ public class BukkitClient implements Client, PluginMessageListener {
Object packetObj = CommunicationPackets.buildFromBytes(bytes);
if(!CommunicationPackets.isPacket(packetObj)) return;
Bukkit.getScheduler().scheduleSyncDelayedTask(BukkitLoader.getPlugin(), () -> Communicator.receiveInformation("proxy", packetObj));
PATScheduler.createScheduler(() -> Communicator.receiveInformation("proxy", packetObj));
} catch (Throwable throwable) { throwable.printStackTrace(); }
}
}
@@ -0,0 +1,43 @@
package de.rayzs.pat.api.event.events.bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
public abstract class ExecuteCommandEvent extends Event implements Cancellable {
private final String command;
private boolean blocked;
public ExecuteCommandEvent() {
this.blocked = false;
this.command = null;
}
public ExecuteCommandEvent(Player player, String command, boolean blocked) {
this.blocked = blocked;
this.command = command;
}
public String getCommand() {
return command;
}
public boolean isBlocked() {
return blocked;
}
public void setBlocked(boolean blocked) {
this.blocked = blocked;
}
@Override
public boolean isCancelled() {
return blocked;
}
@Override
public void setCancelled(boolean cancel) {
this.blocked = cancel;
}
}
@@ -0,0 +1,26 @@
package de.rayzs.pat.api.event.events.bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import java.util.List;
public abstract class FilteredSuggestionEvent extends Event {
private List<String> suggestions;
public FilteredSuggestionEvent() {
this.suggestions = null;
}
public FilteredSuggestionEvent(Player player, List<String> suggestions) {
this.suggestions = suggestions;
}
public List<String> getSuggestions() {
return suggestions;
}
public void setSuggestions(List<String> suggestions) {
this.suggestions = suggestions;
}
}
@@ -0,0 +1,35 @@
package de.rayzs.pat.api.event.events.bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import java.util.List;
public abstract class FilteredTabCompletionEvent extends Event {
private String cursor;
private List<String> completion;
public FilteredTabCompletionEvent() {
this.cursor = null;
this.completion = null;
}
public FilteredTabCompletionEvent(Player player, String cursor, List<String> completion) {
this.cursor = cursor;
this.completion = completion;
}
public abstract void handle(FilteredTabCompletionEvent event);
public String getCursor() {
return cursor;
}
public List<String> getCompletion() {
return completion;
}
public void setCompletion(List<String> completion) {
this.completion = completion;
}
}
@@ -45,7 +45,7 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
}
cancelsBeforeHand = Storage.Blacklist.isBlocked(player, input, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(input);
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(input);
} else return true;
for (Field field : Reflection.getFields(packetObj)) {
@@ -59,7 +59,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
}
cancelsBeforeHand = Storage.Blacklist.isBlocked(player, input, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(input);
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(input);
}
if(is121Packet || Reflection.isFoliaServer() && packetObj.getClass().getSimpleName().equals("PacketPlayOutTabComplete")) {
@@ -106,10 +106,13 @@ public class ModernPacketHandler implements BukkitPacketHandler {
suggestions.removeIf(suggestion -> !filteredTabCompletionEvent.getCompletion().contains(getSuggestionFromEntry(suggestion)));
}
Object clientboundCommandSuggestionsPacketObj = clientboundCommandSuggestionsPacketClass
.getConstructor(int.class, int.class, int.class, List.class)
.newInstance(id, start, length, suggestions);
BukkitPacketAnalyzer.sendPacket(player.getUniqueId(), clientboundCommandSuggestionsPacketObj);
if(!suggestions.isEmpty()) {
Object clientboundCommandSuggestionsPacketObj = clientboundCommandSuggestionsPacketClass
.getConstructor(int.class, int.class, int.class, List.class)
.newInstance(id, start, length, suggestions);
BukkitPacketAnalyzer.sendPacket(player.getUniqueId(), clientboundCommandSuggestionsPacketObj);
}
return false;
} catch (Throwable throwable) { throwable.printStackTrace(); }
@@ -148,9 +151,8 @@ public class ModernPacketHandler implements BukkitPacketHandler {
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, suggestionsAsString);
if(filteredTabCompletionEvent.isCancelled()) suggestions.getList().clear();
suggestions.getList().removeIf(suggestion -> !filteredTabCompletionEvent.getCompletion().contains(suggestion.getText()));
return !suggestions.getList().isEmpty();
}
return true;
}
private String getSuggestionFromEntry(Object suggestionObj) {
@@ -197,7 +197,8 @@ public class BungeePacketAnalyzer {
if(!playerInput.equals("/")) {
cancelsBeforeHand = Storage.Blacklist.isBlocked(player, StringUtils.replaceFirst(playerInput, "/", ""), !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, server);
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(StringUtils.replaceFirst(playerInput, "/", ""));
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
}
final String cursor = playerInput;
if(cursor.startsWith("/")) {
@@ -183,7 +183,7 @@ public class VelocityPacketAnalyzer {
TabCompleteResponsePacket response = (TabCompleteResponsePacket) packet;
boolean cancelsBeforeHand = false;
String playerInput = getPlayerInput(player), server = player.getCurrentServer().get().getServerInfo().getName();
String playerInput = getPlayerInput(player), rawPlayerInput = playerInput, server = player.getCurrentServer().get().getServerInfo().getName();
int spaces = 0;
if(playerInput.contains(" ")) {
@@ -194,7 +194,7 @@ public class VelocityPacketAnalyzer {
if(!playerInput.equals("/")) {
cancelsBeforeHand = Storage.Blacklist.isBlocked(player, StringUtils.replaceFirst(playerInput, "/", ""), !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, server);
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(StringUtils.replaceFirst(playerInput, "/", ""));
if(!cancelsBeforeHand) cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
}
final String cursor = playerInput;
@@ -217,9 +217,11 @@ public class VelocityPacketAnalyzer {
List<String> suggestionsAsString = new ArrayList<>();
response.getOffers().forEach(offer -> suggestionsAsString.add(offer.getText()));
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), cursor, suggestionsAsString);
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawPlayerInput, suggestionsAsString);
if(filteredTabCompletionEvent.isCancelled()) return;
response.getOffers().removeIf(offer -> !filteredTabCompletionEvent.getCompletion().contains(offer.getText()));
if(response.getOffers().isEmpty()) return;
}
}
}
@@ -114,6 +114,7 @@ public class Storage {
public static CancelCommandSection CANCEL_COMMAND = new CancelCommandSection();
public static CustomPluginsSection CUSTOM_PLUGIN = new CustomPluginsSection();
public static CustomVersionSection CUSTOM_VERSION = new CustomVersionSection();
public static DisableSyncSection DISABLE_SYNC = new DisableSyncSection();
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();
@@ -252,7 +253,9 @@ public class Storage {
public static List<GeneralBlacklist> getBlacklists(String server) {
final String finalServer = server.toLowerCase();
if(CACHED_SERVER_BLACKLIST.contains(finalServer)) return CACHED_SERVER_BLACKLIST.get(finalServer);
if (CACHED_SERVER_BLACKLIST.contains(finalServer))
return CACHED_SERVER_BLACKLIST.get(finalServer);
List<GeneralBlacklist> blacklists = new ArrayList<>();
SERVER_BLACKLISTS.entrySet()
@@ -386,22 +389,16 @@ public class Storage {
blockedServer = blacklist.isBlockedIgnorePermission(command, intensive);
break;
/* Former code
if (!blacklist.isBlockedIgnorePermission(command, intensive)) {
blockedServer = false;
break;
}
blockedServer = true;
*/
}
blocked = turn ? blockedGlobal && blockedServer : blockedServer || blockedGlobal;
if(!blocked
// The reason which there's no tab-completion and also why every server-based list needs to exist to avoid this issue.
if (turn && !blocked
&& CACHED_SERVER_BLACKLIST.contains(server)
&& CACHED_SERVER_BLACKLIST.get(server).isEmpty())
if(turn) blocked = true;
blocked = true;
return blocked;
}
@@ -6,7 +6,7 @@ import java.util.*;
public class CustomPluginsSection extends ConfigStorage {
public boolean ENABLED;
public boolean ENABLED, ALWAYS_TAB_COMPLETABLE;
public MultipleMessagesHelper MESSAGE, COMMANDS;
public CustomPluginsSection() {
@@ -17,10 +17,18 @@ public class CustomPluginsSection extends ConfigStorage {
public void load() {
super.load();
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
COMMANDS = new MultipleMessagesHelper(this, "commands", Arrays.asList("pl", "plugins", "bukkit:pl", "bukkit:plugins"));
ALWAYS_TAB_COMPLETABLE = new ConfigSectionHelper<Boolean>(this, "always-tab-completable", false).getOrSet();
COMMANDS = new MultipleMessagesHelper(this, "commands", Arrays.asList("pl", "plugins"));
MESSAGE = new MultipleMessagesHelper(this, "message", Collections.singletonList("&fPlugins (0):"));
}
public boolean isTabCompletable(String command) {
if (!isCommand(command))
return false;
return ALWAYS_TAB_COMPLETABLE;
}
public boolean isCommand(String command) {
if(!ENABLED) return false;
@@ -31,7 +39,7 @@ public class CustomPluginsSection extends ConfigStorage {
command = command.split(" ")[0];
}
for (String currentCommand : COMMANDS.getLines()) {
if (currentCommand.equals(command.toLowerCase()))
if (currentCommand.equalsIgnoreCase(command))
return true;
}
return false;
@@ -7,7 +7,7 @@ import java.util.*;
public class CustomVersionSection extends ConfigStorage {
public boolean ENABLED;
public boolean ENABLED, ALWAYS_TAB_COMPLETABLE;
public MultipleMessagesHelper MESSAGE, COMMANDS;
public CustomVersionSection() {
@@ -18,16 +18,24 @@ public class CustomVersionSection extends ConfigStorage {
public void load() {
super.load();
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
COMMANDS = new MultipleMessagesHelper(this, "commands", Arrays.asList("icanhasbukkit", "ver", "version", "bukkit:ver", "bukkit:version"));
ALWAYS_TAB_COMPLETABLE = new ConfigSectionHelper<Boolean>(this, "always-tab-completable", false).getOrSet();
COMMANDS = new MultipleMessagesHelper(this, "commands", Arrays.asList("icanhasbukkit", "about", "ver", "version"));
MESSAGE = new MultipleMessagesHelper(this, "message", Collections.singletonList("&fThis server is running CraftBukkit version git-NasaSpigot-294 (MC: X)"));
}
public boolean isTabCompletable(String command) {
if (!isCommand(command))
return false;
return ALWAYS_TAB_COMPLETABLE;
}
public boolean isCommand(String command) {
if(!ENABLED) return false;
command = StringUtils.getFirstArg(command);
for (String currentCommand : COMMANDS.getLines()) {
if (currentCommand.equals(command.toLowerCase()))
if (currentCommand.equalsIgnoreCase(command))
return true;
}
return false;
@@ -0,0 +1,22 @@
package de.rayzs.pat.api.storage.config.settings;
import de.rayzs.pat.utils.Reflection;
import de.rayzs.pat.api.storage.storages.ConfigStorage;
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
public class DisableSyncSection extends ConfigStorage {
public boolean DISABLED;
public DisableSyncSection() {
super("disable-sync");
}
@Override
public void load() {
super.load();
if(!Reflection.isProxyServer()) return;
DISABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
}
}
@@ -6,7 +6,7 @@ import java.util.*;
public class UpdateSection extends ConfigStorage {
public boolean ENABLED;
public boolean ENABLED, AUTO_UPDATE_CONFIG;
public int PERIOD;
public MultipleMessagesHelper OUTDATED, UPDATED;
@@ -19,6 +19,7 @@ public class UpdateSection extends ConfigStorage {
super.load();
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
PERIOD = new ConfigSectionHelper<Integer>(this, "period", 10000).getOrSet();
AUTO_UPDATE_CONFIG = new ConfigSectionHelper<Boolean>(this, "auto-update-config", true).getOrSet();
UPDATED = new MultipleMessagesHelper(this, "updated", Collections.singletonList("&aYou are using the newest version! ^^"));
OUTDATED = new MultipleMessagesHelper(this, "outdated", Arrays.asList(
"&8[&4ProAntiTab&8] &cThere is a new version available! (%newest_version%)",
@@ -18,6 +18,7 @@ import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.plugin.metrics.bStats;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.utils.response.action.ActionHandler;
import org.bukkit.plugin.java.JavaPlugin;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.scheduler.*;
@@ -102,6 +103,7 @@ public class BukkitLoader extends JavaPlugin {
Logger.warning("Detected SimpleCloud. Therefore, MiniMessages are disabled!");
ConfigUpdater.broadcastMissingParts();
ActionHandler.initialize();
SubArgsModule.initialize();
}
@@ -1,22 +1,23 @@
package de.rayzs.pat.plugin;
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
import de.rayzs.pat.utils.configuration.Configurator;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
import de.rayzs.pat.api.communication.Communicator;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import de.rayzs.pat.utils.response.action.ActionHandler;
import net.md_5.bungee.api.scheduler.ScheduledTask;
import de.rayzs.pat.plugin.commands.BungeeCommand;
import de.rayzs.pat.api.brand.CustomServerBrand;
import de.rayzs.pat.plugin.listeners.bungee.*;
import de.rayzs.pat.utils.group.GroupManager;
import net.md_5.bungee.api.config.ServerInfo;
import de.rayzs.pat.plugin.metrics.bStats;
import de.rayzs.pat.plugin.logger.Logger;
import net.md_5.bungee.api.connection.*;
import de.rayzs.pat.api.storage.Storage;
import net.md_5.bungee.api.ProxyServer;
import java.util.concurrent.TimeUnit;
@@ -70,7 +71,9 @@ public class BungeeLoader extends Plugin {
manager.registerListener(this, new WaterfallAntiTabListener());
startUpdaterTask();
ProxyServer.getInstance().getScheduler().schedule(this, Communicator::syncData, 5, TimeUnit.SECONDS);
if (!Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED)
ProxyServer.getInstance().getScheduler().schedule(this, Communicator::syncData, 5, TimeUnit.SECONDS);
Storage.PLUGIN_OBJECT = this;
@@ -87,6 +90,7 @@ public class BungeeLoader extends Plugin {
BungeePacketAnalyzer.injectAll();
ConfigUpdater.broadcastMissingParts();
ActionHandler.initialize();
SubArgsModule.initialize();
}
@@ -4,7 +4,6 @@ import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ServerConnection;
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
import de.rayzs.pat.utils.VersionComparer;
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
import de.rayzs.pat.plugin.metrics.impl.VelocityMetrics;
import com.velocitypowered.api.scheduler.ScheduledTask;
@@ -17,20 +16,25 @@ import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
import com.velocitypowered.api.proxy.ProxyServer;
import de.rayzs.pat.api.brand.CustomServerBrand;
import de.rayzs.pat.plugin.listeners.velocity.*;
import de.rayzs.pat.utils.ConnectionBuilder;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.ConnectionBuilder;
import de.rayzs.pat.utils.VersionComparer;
import de.rayzs.pat.plugin.logger.Logger;
import com.velocitypowered.api.plugin.*;
import de.rayzs.pat.api.storage.Storage;
import com.velocitypowered.api.event.*;
import de.rayzs.pat.utils.Reflection;
import java.util.concurrent.TimeUnit;
import com.google.inject.Inject;
import de.rayzs.pat.utils.response.action.ActionHandler;
import java.util.*;
@Plugin(name = "ProAntiTab",
id = "proantitab",
version = "1.9.0",
version = "1.9.2",
authors = "Rayzs_YT",
description = "Hide more than just your plugins. Hide almost everything!",
dependencies = {
@@ -85,7 +89,9 @@ public class VelocityLoader {
server.getEventManager().register(this, new VelocityPingListener(server));
startUpdaterTask();
server.getScheduler().buildTask(this, Communicator::syncData).delay(5, TimeUnit.SECONDS).schedule();
if (!Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED)
server.getScheduler().buildTask(this, Communicator::syncData).delay(5, TimeUnit.SECONDS).schedule();
Storage.PLUGIN_OBJECT = this;
@@ -101,6 +107,7 @@ public class VelocityLoader {
Logger.warning("Detected SimpleCloud and therefore MiniMessages by Kyori are disabled!");
ConfigUpdater.broadcastMissingParts();
ActionHandler.initialize();
SubArgsModule.initialize();
}
@@ -35,7 +35,7 @@ public class BukkitAntiTabListener implements Listener {
return;
}
if(event.getCommands().size() == 0) {
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;
}
@@ -94,7 +94,6 @@ public class BukkitBlockCommandListener implements Listener {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, rawCommand, true);
if(executeCommandEvent.isBlocked()) event.setCancelled(true);
if(executeCommandEvent.isCancelled()) return;
MessageTranslator.send(player, cancelCommandMessage);
return;
}
@@ -2,6 +2,7 @@ package de.rayzs.pat.plugin.listeners.bukkit;
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.message.replacer.PlaceholderReplacer;
import org.bukkit.event.*;
import org.bukkit.Bukkit;
@@ -23,6 +24,9 @@ public class PaperServerListPing implements Listener {
if(Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.HIDE_PLAYERS)
event.getPlayerSample().clear();
if(versionName.contains("%"))
PlaceholderReplacer.replace(null, versionName);
event.setVersion(versionName);
}
}
@@ -174,7 +174,7 @@ public class VelocityBlockCommandListener {
if (executeCommandEvent.isBlocked()) blocked = true;
if (executeCommandEvent.isCancelled()) return false;
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE, "%command%", command.replaceFirst("/", ""));
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE, "%command%", command);
if (Storage.SEND_CONSOLE_NOTIFICATION)
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), notificationMessage);
@@ -212,10 +212,6 @@ public class VelocityBlockCommandListener {
return blocked;
}
System.out.println(4);
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command) && !Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, commandSource, true);
if (executeCommandEvent.isBlocked()) blocked = true;
@@ -3,6 +3,7 @@ package de.rayzs.pat.plugin.modules.subargs;
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.plugin.modules.subargs.events.*;
import de.rayzs.pat.utils.response.ResponseHandler;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.subargs.*;
@@ -53,7 +54,7 @@ public class SubArgsModule {
public static void updateMessages() {
Storage.Files.CUSTOM_RESPONSES.reload();
Responses.update();
ResponseHandler.update();
}
public static List<String> getServerCommands(UUID uuid) {
@@ -2,8 +2,8 @@ package de.rayzs.pat.plugin.modules.subargs.events;
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.utils.response.ResponseHandler;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.subargs.*;
import de.rayzs.pat.utils.*;
@@ -13,14 +13,17 @@ public class ExecuteCommand extends ExecuteCommandEvent {
@Override
public void handle(ExecuteCommandEvent event) {
String command = StringUtils.replaceFirst(event.getCommand(), "/", "");
CommandSender sender = new CommandSender(event.getSenderObj());
/* Removed due to the fact that it is not required after all.
if(PermissionUtil.hasBypassPermission(event.getSenderObj(), command.contains(" ") ? command.split(" ")[0] : command))
return;
*/
if(command.contains(" ") && shouldCommandBeBlocked(event, command)) {
if(command.contains(" ") && shouldCommandBeBlocked(sender, event, command)) {
event.setBlocked(true);
event.setCancelled(true);
MessageTranslator.send(event.getSenderObj(), Responses.getResponse(event.getCommand()), "%command%", event.getCommand());
MessageTranslator.send(event.getSenderObj(), ResponseHandler.getResponse(sender.getUniqueId(), event.getCommand()), "%command%", event.getCommand());
return;
}
@@ -30,11 +33,10 @@ public class ExecuteCommand extends ExecuteCommandEvent {
return;
event.setCancelled(true);
MessageTranslator.send(event.getSenderObj(), Responses.getResponse(event.getCommand(), Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE.getLines()), "%command%", event.getCommand());
MessageTranslator.send(event.getSenderObj(), ResponseHandler.getResponse(sender.getUniqueId(), event.getCommand(), Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE.getLines()), "%command%", event.getCommand());
}
private boolean shouldCommandBeBlocked(ExecuteCommandEvent event, String command) {
CommandSender sender = new CommandSender(event.getSenderObj());
private boolean shouldCommandBeBlocked(CommandSender sender, ExecuteCommandEvent event, String command) {
boolean listed = false,
turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED,
blocked = event.isBlocked(),
@@ -4,9 +4,9 @@ import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
import de.rayzs.pat.utils.subargs.Argument;
import de.rayzs.pat.api.storage.Storage;
import java.util.stream.Collectors;
import de.rayzs.pat.utils.*;
import java.util.*;
import java.util.stream.Collectors;
public class TabCompletion extends FilteredTabCompletionEvent {
@@ -17,10 +17,11 @@ public class TabCompletion extends FilteredTabCompletionEvent {
UUID uuid = event.getSenderObj() instanceof UUID ? (UUID) event.getSenderObj() : new CommandSender(event.getSenderObj()).getUniqueId();
Argument argument = SubArgsModule.PLAYER_COMMANDS.getOrDefault(uuid, Argument.getGeneralArgument());
List<String> possibilities = event.getCompletion(), result = argument.getResult(cursor);
List<String> possibilities = event.getCompletion(), result = new ArrayList<>(argument.getResult(cursor));
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
possibilities = result;
if(result.contains("%online_players%")) {
possibilities.remove("%online_players%");
possibilities.addAll(SubArgsModule.getPlayerNames());
@@ -0,0 +1,19 @@
package de.rayzs.pat.plugin.skript;
import ch.njol.skript.*;
import org.bukkit.plugin.java.JavaPlugin;
import de.rayzs.pat.api.event.events.bukkit.ExecuteCommandEvent;
import de.rayzs.pat.plugin.skript.impl.events.ExecuteCommandSkriptEvent;
public class PATSkriptAddon {
public static SkriptAddon ADDON;
public static void initialize(JavaPlugin javaPlugin) {
ADDON = Skript.getAddon(javaPlugin);
Skript.registerEvent("PAT Command Execution", ExecuteCommandSkriptEvent.class, ExecuteCommandEvent.class, "if [command] is (blocked|cancelled|not blocked|not cancelled)");
}
}
@@ -0,0 +1,44 @@
package de.rayzs.pat.plugin.skript.impl.events;
import ch.njol.skript.doc.*;
import ch.njol.skript.lang.*;
import ch.njol.skript.Skript;
import org.bukkit.event.Event;
import de.rayzs.pat.api.event.events.bukkit.ExecuteCommandEvent;
@Name("PAT Command Execution")
@Description("Fires after a command has been checked by PAT.")
public class ExecuteCommandSkriptEvent extends SkriptEvent {
private boolean triggerOnBlocked;
static {
Skript.registerEvent("PAT Command Execution",
ExecuteCommandSkriptEvent.class, ExecuteCommandEvent.class,
"[if] (blocked|cancelled|not blocked|not cancelled)");
}
@Override
public boolean init(Literal<?>[] literals, int matchedPattern, SkriptParser.ParseResult parseResult) {
// 0 = blocked/cancelled
// 1 = not blocked/cancelled
triggerOnBlocked = matchedPattern == 0;
return true;
}
@Override
public String toString(Event event, boolean debug) {
return "PAT command execution event " + (triggerOnBlocked ? "(if blocked)" : "(if not blocked)");
}
@Override
public boolean check(Event event) {
if (event instanceof ExecuteCommandEvent) {
ExecuteCommandEvent executeCommandEvent = (ExecuteCommandEvent) event;
return executeCommandEvent.isBlocked() == triggerOnBlocked;
}
return false;
}
}
@@ -4,6 +4,14 @@ import java.util.*;
public class ArrayUtils {
public static boolean containsIgnoreCase(List<String> list, String element) {
for (String s : list)
if(s.equalsIgnoreCase(element))
return true;
return false;
}
public static boolean compareStringArrays(List<String> listA, List<String> listB) {
if(listA == null || listB == null) return false;
@@ -77,7 +77,9 @@ public class CommandsCache {
if(filteredCommands == null)
return useList ? playerCommands : new LinkedList<>(unfilteredCommands);
if(useList && !Storage.Blacklist.isOnIgnoredServer(serverName)) playerCommands = new LinkedList<>(filteredCommands);
if(useList && !Storage.Blacklist.isOnIgnoredServer(serverName)) {
playerCommands = new LinkedList<>(filteredCommands);
}
boolean permitted, bypassNamespace = true, turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
@@ -94,6 +96,16 @@ public class CommandsCache {
if (playerCommands.contains(command)) continue;
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
if (useList)
playerCommands.add(command);
else
playerCommands.remove(command);
continue;
}
permitted = Reflection.isProxyServer() && serverName != null
? !Storage.Blacklist.isBlocked(targetObj, command, !turn, serverName)
: !Storage.Blacklist.isBlocked(targetObj, command, !turn, false, false);
@@ -130,7 +142,10 @@ public class CommandsCache {
}
public void reset() {
if(change) return;
// Removed to reset the change state. Experimental change though
//if(change) return;
// Prob. gonna change it to: if (CONNECTED_TO_BUNGEE && change) return;
updateChangeState();
filteredCommands = null;
}
@@ -8,12 +8,18 @@ public class ConnectionBuilder {
private String url = null, response = null;
private List<String> responseList = new ArrayList<>();
private Object[] parameters = null;
private int timeout = -1;
public ConnectionBuilder setUrl(String url) {
this.url = url;
return this;
}
public ConnectionBuilder setTimeout(int timeout) {
this.timeout = timeout;
return this;
}
public ConnectionBuilder setProperties(Object... parameters) {
this.parameters = parameters;
return this;
@@ -24,6 +30,9 @@ public class ConnectionBuilder {
String rawUrl = url;
URL url = new URL(rawUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
if(timeout != -1) connection.setConnectTimeout(timeout);
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
connection.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
if(parameters != null && parameters.length > 0) {
@@ -56,6 +56,8 @@ public class Reflection {
if (proxy) version = Version.UNKNOWN;
}
public static String getVersionPackageName() {return versionPackageName;}
public static int[] getAges() { return new int[]{major, minor, release}; }
public static String getVersionName() { return versionName; }
public static String getRawVersionName() { return rawVersionName; }
@@ -275,7 +277,7 @@ public class Reflection {
public static Channel getPlayerChannel(Player player) throws Exception {
Object channelObject;
if(!folia && paper && Reflection.isWeird()) {
if(folia && minor == 21 && release == 1 || !folia && paper && Reflection.isWeird()) {
Object serverPlayerObj = getMethodsByReturnTypeAndName(player.getClass(), "ServerPlayer", SearchOption.ENDS, "getHandle").get(0).invoke(player),
serverGamePacketListenerImplObj = getFieldByName(serverPlayerObj.getClass(), "connection").get(serverPlayerObj),
connectionObj = getFieldByName(serverGamePacketListenerImplObj.getClass().getSuperclass(), "connection").get(serverGamePacketListenerImplObj);
@@ -391,7 +393,8 @@ public class Reflection {
v_1_18_1, v_1_18_2,
v_1_19, v_1_19_1, v_1_19_2, v_1_19_3, v_1_19_4,
v_1_20, v_1_20_1, v_1_20_2, v_1_20_3, v_1_20_4, v_1_20_5, v_1_20_6,
v_1_21, v_1_21_1, v_1_21_2,
v_1_21, v_1_21_1, v_1_21_2, v_1_21_3, v_1_21_4,
v_1_22, v_1_22_1, v_1_22_2
}
public enum SearchOption { CONTAINS, EQUALS, ENDS, STARTS }
@@ -17,6 +17,26 @@ public class StringUtils {
return input;
}
public static String replaceLast(String input, String trigger, String replacement) {
if (input.contains(trigger)) {
String[] split = input.split(trigger.equals("*") ? "\\*" : trigger);
if (split.length >= 1) {
StringBuilder result = new StringBuilder();
String current;
int i;
for(i = 0; i < split.length; i++) {
current = split[i];
result.append(current);
if(i < split.length -1) result.append(" ");
}
input = result.toString();
} else input = input.replace(trigger, replacement);
}
return input;
}
public static int countMatches(Character character, String string) {
int count = 0;
for (char c : string.toCharArray()) {
@@ -26,6 +46,27 @@ public class StringUtils {
return count;
}
public static String replaceElementsFromString(String input, List<String> targets, String replacement) {
final String[] args = input.split(" ");
final StringBuilder result = new StringBuilder();
final int max = args.length;
String part;
int i;
for (i = 0; i < max; i++) {
part = args[i];
if(ArrayUtils.containsIgnoreCase(targets, part))
part = replacement;
result.append(part);
if(i < args.length -1) result.append(" ");
}
return result.toString();
}
public static String replaceTriggers(String input, String replacement, String... triggers) {
for (String trigger : triggers) {
if(!input.contains(trigger)) continue;
@@ -58,7 +58,7 @@ public class LuckPermsAdapter {
Map<String, Boolean> permissions = getPermissions(uuid);
if(permissions == null) return false;
return permissions.size() > 0;
return !permissions.isEmpty();
}
public static void setPermissions(UUID uuid) {
@@ -67,9 +67,10 @@ public class LuckPermsAdapter {
permissions.forEach((permission, permitted) -> {
if(permission.startsWith("proantitab.") || permission.equals("*")) PermissionUtil.setPermission(uuid, permission, permitted);
}
);
if(permission.startsWith("proantitab.") || permission.equals("*"))
PermissionUtil.setPermission(uuid, permission, permitted);
});
if(Reflection.isProxyServer()) {
if(Reflection.isVelocityServer()) VelocityAntiTabListener.updateCommands();
@@ -95,11 +96,14 @@ public class LuckPermsAdapter {
if (event.isUser() && event.getTarget() instanceof User) {
User user = (User) event.getTarget();
if (Reflection.isProxyServer()) {
if(Reflection.isVelocityServer())
PermissionUtil.reloadPermissions(user.getUniqueId());
}
else BukkitAntiTabListener.luckpermsNetworkUserSync(user.getUniqueId());
PermissionUtil.reloadPermissions(user.getUniqueId());
} else BukkitAntiTabListener.luckpermsNetworkUserSync(user.getUniqueId());
}
}
}
@@ -3,6 +3,8 @@ package de.rayzs.pat.utils.configuration.updater;
import de.rayzs.pat.utils.configuration.ConfigurationBuilder;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.utils.*;
import de.rayzs.pat.utils.configuration.Configurator;
import java.nio.file.Files;
import java.util.*;
import java.io.*;
@@ -13,7 +15,18 @@ public class ConfigUpdater {
private static boolean LOADED = false;
public static void initialize() {
NEWEST_CONFIG_INPUT = new ConnectionBuilder().setUrl("https://raw.githubusercontent.com/RayzsYT/ProAntiTab/main/src/main/resources/files/"
try {
boolean autoUpdateConfig = (boolean) Configurator.get("config").getOrSet("updater.auto-update-config", true);
if (autoUpdateConfig) {
LOADED = false;
return;
}
} catch (Exception exception) {
Logger.warning("Failed to find section 'updater.auto-config-updater' in config.yml!");
}
NEWEST_CONFIG_INPUT = new ConnectionBuilder().setTimeout(2000).setUrl("https://raw.githubusercontent.com/RayzsYT/ProAntiTab/main/src/main/resources/files/"
+ (Reflection.isProxyServer() ? "proxy" : "bukkit")
+ "-config.yml").connect().getResponseList();
@@ -38,7 +51,7 @@ public class ConfigUpdater {
return;
}
List<String> fileInput = new LinkedList<>(Arrays.asList("# WARNING: This file is auto generated with to solely purpose to be used as comparison!", " ", " "));
List<String> fileInput = new LinkedList<>(Arrays.asList("# WARNING: This file is auto generated and its solely purpose is to be used as comparison!", " ", " "));
fileInput.addAll(NEWEST_CONFIG_INPUT);
try {
@@ -1,6 +1,7 @@
package de.rayzs.pat.utils.permission;
import java.util.*;
import java.util.stream.Collectors;
public class PermissionMap {
@@ -20,7 +21,7 @@ public class PermissionMap {
}
public Set<String> getHashedPermissions() {
return permissionMap.keySet();
return permissionMap.keySet().stream().filter(permissionMap::get).collect(Collectors.toSet());
}
public void clear() {
@@ -48,10 +48,12 @@ public class PermissionUtil {
public static void setPermission(UUID uuid, String permission, boolean permitted) {
PermissionMap permissionMap;
if(!MAP.containsKey(uuid)) {
permissionMap = new PermissionMap(uuid);
MAP.put(uuid, permissionMap);
} else permissionMap = MAP.get(uuid);
permissionMap.setState(permission, permitted);
}
@@ -62,7 +64,9 @@ public class PermissionUtil {
if(targetObj instanceof CommandSender) sender = (CommandSender) targetObj;
else sender = new CommandSender(targetObj);
if(sender.isConsole()) return true;
uuid = sender.getUniqueId();
if(!MAP.containsKey(uuid)) {
@@ -0,0 +1,212 @@
package de.rayzs.pat.utils.response;
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.plugin.*;
import de.rayzs.pat.utils.*;
import de.rayzs.pat.utils.response.action.ActionHandler;
import java.util.*;
public class ResponseHandler {
private static List<Response> RESPONSES = new ArrayList<>();
public static void update() {
RESPONSES = new ArrayList<>();
Storage.Files.CUSTOM_RESPONSES.getKeys(true).stream().filter(key -> !key.equals("default-message")).forEach(key -> {
if(!key.contains(".")) {
Response response = new Response(key);
RESPONSES.add(response);
}
});
}
public static List<String> getResponse(UUID uuid, String input) {
return getResponse(uuid, input, Storage.ConfigSections.Settings.CANCEL_COMMAND.SUB_COMMAND_RESPONSE.getLines());
}
public static List<String> getResponse(UUID uuid, String input, List<String> defaultMessage) {
final String finalInput = input.startsWith("/") ? StringUtils.replaceFirst(input, "/", "") : input;
final Optional<Response> optionalResponse = RESPONSES.stream().filter(response -> {
for (String trigger : response.triggers)
if(trigger.endsWith("*") ? finalInput.startsWith(StringUtils.replace(trigger, "*", "")) : finalInput.equals(trigger))
return true;
return false;
}).findFirst();
if(uuid != null && optionalResponse.isPresent()) {
optionalResponse.get().executeAction(uuid);
return optionalResponse.get().message;
}
return defaultMessage;
}
private static class Response {
private final List<String> triggers, message, actions;
public Response(final String key) {
this.triggers = (List<String>) Storage.Files.CUSTOM_RESPONSES.get(key + ".triggers");
this.message = (List<String>) Storage.Files.CUSTOM_RESPONSES.getOrSet(key + ".message", SubArgsModule.BLOCKED_MESSAGE);
this.actions = (List<String>) Storage.Files.CUSTOM_RESPONSES.getOrSet(key + ".actions", new ArrayList<>());
}
public void executeAction(UUID uuid) {
String[] split;
for (String action : actions) {
if(!action.contains("::")) {
Logger.warning("! Could not recognise action: " + action);
Logger.warning(" > Syntax does not match at all. Have you used the splitters (::) correctly?");
continue;
}
split = action.split("::");
switch (split[0].toLowerCase()) {
case "effect":
if(Reflection.isProxyServer()) {
Logger.warning("! Could not execute action: " + action);
Logger.warning(" > Effect cannot be added on the proxy side!");
continue;
}
if(split.length != 4) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > Action requires 4 arguments but only has " + split.length);
Logger.warning(" > Here's an example to compare with:");
Logger.warning(" > effect::potionEffect::duration::amplifier");
Logger.warning(" > e.g: effect::BLINDNESS::100::1");
continue;
}
int duration, amplifier;
try {
duration = Integer.parseInt(split[2]);
} catch (Exception exception) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > Duration " + split[2].toUpperCase() + " is not a valid integer! (e.g: 1)");
continue;
}
try {
amplifier = Integer.parseInt(split[3]);
} catch (Exception exception) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > Amplifier " + split[3].toUpperCase() + " is not a valid integer! (e.g: 1)");
continue;
}
ActionHandler.addPotionEffect(action, uuid, split[1].toUpperCase(), duration, amplifier);
continue;
case "title":
if(split.length != 6) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > Action requires 6 arguments but only has " + split.length);
Logger.warning(" > Here's an example to compare with:");
Logger.warning(" > title::title::subtitle::fadeIn::stay::fadeOut");
Logger.warning(" > e.g: title::My title::My subtitle::300::3000::300");
continue;
}
int fadeIn, stay, fadeOut;
try {
fadeIn = Integer.parseInt(split[3]);
} catch (Exception exception) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > Fade-In " + split[3].toUpperCase() + " is not a valid integer! (e.g: 300)");
continue;
}
try {
stay = Integer.parseInt(split[4]);
} catch (Exception exception) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > Stay " + split[4].toUpperCase() + " is not a valid integer! (e.g: 3000)");
continue;
}
try {
fadeOut = Integer.parseInt(split[5]);
} catch (Exception exception) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > Fade-Out " + split[5].toUpperCase() + " is not a valid integer! (e.g: 300)");
continue;
}
ActionHandler.sendTitle(action, uuid, split[1], split[2], fadeIn, stay, fadeOut);
continue;
case "sound":
if(Reflection.isProxyServer()) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > Sounds cannot be played on the proxy side!");
continue;
}
if(split.length != 4) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > Action requires 4 arguments but only has " + split.length);
Logger.warning(" > Here's an example to compare with:");
Logger.warning(" > sound::soundName::volume::pitch");
Logger.warning(" > e.g: sound::ENTITY_ENDER_DRAGON_GROWL::1.0::1.0");
continue;
}
float volume, pitch;
try {
volume = Float.parseFloat(split[2]);
} catch (Exception exception) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > Volume " + split[2].toUpperCase() + " is not a valid float! (e.g: 1.0f)");
continue;
}
try {
pitch = Float.parseFloat(split[3]);
} catch (Exception exception) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > Pitch " + split[3].toUpperCase() + " is not a valid float! (e.g: 1.0f)");
continue;
}
ActionHandler.playSound(action, uuid, split[1].toUpperCase(), volume, pitch);
continue;
case "console":
if(split.length == 1) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > Action requires 1 arguments but only has " + split.length);
Logger.warning(" > Here's an example to compare with:");
Logger.warning(" > console::command");
Logger.warning(" > e.g: console::say Hello world!");
}
ActionHandler.executeConsoleCommand(action, uuid, split[1]);
case "actionbar":
if(split.length == 1) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > Action requires 1 arguments but only has " + split.length);
Logger.warning(" > Here's an example to compare with:");
Logger.warning(" > actionbar::text");
Logger.warning(" > e.g: actionbar::I like COOKIES");
}
ActionHandler.sendActionbar(action, uuid, split[1]);
}
}
}
}
}
@@ -0,0 +1,13 @@
package de.rayzs.pat.utils.response.action;
import java.util.UUID;
public interface Action {
void executeConsoleCommand(String action, UUID uuid, String command);
void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut);
void addPotionEffect(String action, UUID uuid, String potionEffectTypeName, int duration, int amplifier);
void playSound(String action, UUID uuid, String soundName, float volume, float pitch);
void sendActionbar(String action, UUID uuid, String text);
}
@@ -0,0 +1,31 @@
package de.rayzs.pat.utils.response.action;
import de.rayzs.pat.utils.response.action.impl.*;
import de.rayzs.pat.utils.Reflection;
import java.util.UUID;
public class ActionHandler {
private static final Action ACTION = Reflection.isProxyServer() ? Reflection.isVelocityServer() ? new VelocityAction() : new BungeeAction() : Reflection.getMinor() <= 16 ? new OldBukkitAction() : new ModernBukkitAction();
public static void initialize() {}
public static void executeConsoleCommand(String action, UUID uuid, String command) {
ACTION.executeConsoleCommand(action, uuid, command);
}
public static void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
ACTION.sendTitle(action, uuid, title, subTitle, fadeIn, stay, fadeOut);
}
public static void addPotionEffect(String action, UUID uuid, String potionEffectType, int duration, int amplifier) {
ACTION.addPotionEffect(action, uuid, potionEffectType, duration, amplifier);
}
public static void playSound(String action, UUID uuid, String soundName, float volume, float pitch) {
ACTION.playSound(action, uuid, soundName, volume, pitch);
}
public static void sendActionbar(String action, UUID uuid, String text) {
ACTION.sendActionbar(action, uuid, text);
}
}
@@ -0,0 +1,54 @@
package de.rayzs.pat.utils.response.action.impl;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.response.action.Action;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.Title;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.UUID;
public class BungeeAction implements Action {
@Override
public void executeConsoleCommand(String action, UUID uuid, String command) {
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
if(player != null) command = command.replace("%player%", player.getName());
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), command);
}
@Override
public void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
if(player == null) return;
Title titleObj = ProxyServer.getInstance().createTitle();
titleObj.title(TextComponent.fromLegacyText(StringUtils.replace(title, "&", "§", "%player%", player.getName())));
titleObj.subTitle(TextComponent.fromLegacyText(StringUtils.replace(subTitle, "&", "§", "%player%", player.getName())));
titleObj.fadeIn(fadeIn);
titleObj.stay(stay);
titleObj.fadeOut(fadeOut);
player.sendTitle(titleObj);
}
@Override
public void addPotionEffect(String action, UUID uuid, String potionEffectTypeName, int duration, int amplifier) {
}
@Override
public void playSound(String action, UUID uuid, String soundName, float volume, float pitch) {
}
@Override
public void sendActionbar(String action, UUID uuid, String text) {
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
if(player == null) return;
player.sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(StringUtils.replace(text, "%player%", player.getName())));
}
}
@@ -0,0 +1,82 @@
package de.rayzs.pat.utils.response.action.impl;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.message.replacer.PlaceholderReplacer;
import de.rayzs.pat.utils.response.action.Action;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.UUID;
public class ModernBukkitAction implements Action {
@Override
public void executeConsoleCommand(String action, UUID uuid, String command) {
Player player = Bukkit.getPlayer(uuid);
if(player != null) command = command.replace("%player%", player.getName());
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
}
@Override
public void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
Player player = Bukkit.getPlayer(uuid);
if(player == null) return;
title = PlaceholderReplacer.replace(player, StringUtils.replace(title, "&", "§", "%player%", player.getName()));
subTitle = PlaceholderReplacer.replace(player, StringUtils.replace(subTitle, "&", "§", "%player%", player.getName()));
player.sendTitle(title, subTitle, fadeIn, stay, fadeOut);
}
@Override
public void addPotionEffect(String action, UUID uuid, String potionEffectTypeName, int duration, int amplifier) {
Player player = Bukkit.getPlayer(uuid);
if(player == null) return;
PotionEffectType potionEffectType = null;
try {
potionEffectType = PotionEffectType.getByName(potionEffectTypeName);
} catch (Exception ignored) { }
if(potionEffectType == null) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > The effect \"" + potionEffectTypeName + "\" could not be found!");
Logger.warning(" > Here's an example of an existing effect:");
Logger.warning(" > BLINDNESS, REGENERATION");
return;
}
player.addPotionEffect(new PotionEffect(potionEffectType, duration, amplifier));
}
@Override
public void playSound(String action, UUID uuid, String soundName, float volume, float pitch) {
Player player = Bukkit.getPlayer(uuid);
if(player == null) return;
try {
Sound sound = Sound.valueOf(soundName);
player.playSound(player.getLocation(), sound, volume, pitch);
} catch (Exception exception) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > The sound \"" + soundName + "\" could not be found!");
Logger.warning(" > Here's an example of an existing sound effect:");
Logger.warning(" > ENTITY_ENDER_DRAGON_GROWL");
}
}
@Override
public void sendActionbar(String action, UUID uuid, String text) {
Player player = Bukkit.getPlayer(uuid);
if(player == null) return;
text = PlaceholderReplacer.replace(player, StringUtils.replace(text, "&", "§", "%player%", player.getName()));
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(text));
}
}
@@ -0,0 +1,105 @@
package de.rayzs.pat.utils.response.action.impl;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.utils.Reflection;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.message.replacer.PlaceholderReplacer;
import de.rayzs.pat.utils.response.action.Action;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Objects;
import java.util.UUID;
public class OldBukkitAction implements Action {
private String versionPackage = null;
@Override
public void executeConsoleCommand(String action, UUID uuid, String command) {
Player player = Bukkit.getPlayer(uuid);
if(player != null) command = command.replace("%player%", player.getName());
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
}
@Override
public void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
Player player = Bukkit.getPlayer(uuid);
if(player == null) return;
title = PlaceholderReplacer.replace(player, StringUtils.replace(title, "&", "§", "%player%", player.getName()));
subTitle = PlaceholderReplacer.replace(player, StringUtils.replace(subTitle, "&", "§", "%player%", player.getName()));
player.sendTitle(title, subTitle);
}
@Override
public void addPotionEffect(String action, UUID uuid, String potionEffectTypeName, int duration, int amplifier) {
Player player = Bukkit.getPlayer(uuid);
if(player == null) return;
PotionEffectType potionEffectType = null;
try {
potionEffectType = PotionEffectType.getByName(potionEffectTypeName);
} catch (Exception ignored) { }
if(potionEffectType == null) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > The effect \"" + potionEffectTypeName + "\" could not be found!");
Logger.warning(" > Here's an example of an existing effect:");
Logger.warning(" > BLINDNESS, REGENERATION");
return;
}
player.addPotionEffect(new PotionEffect(potionEffectType, duration, amplifier));
}
@Override
public void playSound(String action, UUID uuid, String soundName, float volume, float pitch) {
Player player = Bukkit.getPlayer(uuid);
if(player == null) return;
try {
Sound sound = Sound.valueOf(soundName);
player.playSound(player.getLocation(), sound, volume, pitch);
} catch (Exception exception) {
Logger.warning("! Failed to read action: " + action);
Logger.warning(" > The sound \"" + soundName + "\" could not be found!");
Logger.warning(" > Here's an example of an existing sound effect:");
Logger.warning(" > ENTITY_ENDER_DRAGON_GROWL");
}
}
@Override
public void sendActionbar(String action, UUID uuid, String text) {
Player player = Bukkit.getPlayer(uuid);
if(player == null) return;
text = PlaceholderReplacer.replace(player, StringUtils.replace(text, "&", "§", "%player%", player.getName()));
try {
if(versionPackage == null)
versionPackage = Reflection.getVersionPackageName();
Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player);
Constructor<?> constructor = (Objects.<Class<?>>requireNonNull(Class.forName("net.minecraft.server." + versionPackage + ".PacketPlayOutChat"))).getConstructor(Class.forName("net.minecraft.server." + versionPackage + ".IChatBaseComponent"), byte.class);
Object iChatBaseComponent = (Objects.requireNonNull(Class.forName("net.minecraft.server." + versionPackage + ".IChatBaseComponent"))).getDeclaredClasses()[0].getMethod("a", String.class).invoke(null, "{\"text\":\"" + text + "\"}");
Object actionbarPacket = constructor.newInstance(iChatBaseComponent, (byte) 2);
Object playerConnection = entityPlayer.getClass().getField("playerConnection").get(entityPlayer);
playerConnection.getClass().getMethod("sendPacket", Class.forName("net.minecraft.server." + versionPackage + ".Packet")).invoke(playerConnection, actionbarPacket);
} catch (ClassNotFoundException
| NoSuchMethodException
| IllegalAccessException
| InvocationTargetException
| NoSuchFieldException
| InstantiationException exception) {
Logger.warning("! Failed to run action: " + action);
Logger.warning(" > Actionbars are not supported in this server version!");
}
}
}
@@ -0,0 +1,55 @@
package de.rayzs.pat.utils.response.action.impl;
import de.rayzs.pat.utils.message.MessageTranslator;
import net.kyori.adventure.text.minimessage.MiniMessage;
import de.rayzs.pat.utils.response.action.Action;
import com.velocitypowered.api.proxy.Player;
import de.rayzs.pat.plugin.VelocityLoader;
import net.kyori.adventure.title.Title;
import de.rayzs.pat.utils.StringUtils;
import java.util.*;
import java.time.*;
public class VelocityAction implements Action {
@Override
public void executeConsoleCommand(String action, UUID uuid, String command) {
Optional<Player> optPlayer = VelocityLoader.getServer().getPlayer(uuid);
if (optPlayer.isPresent()) command = command.replace("%player%", optPlayer.get().getUsername());
VelocityLoader.getServer().getCommandManager().executeAsync(VelocityLoader.getServer().getConsoleCommandSource(), command);
}
@Override
public void sendTitle(String action, UUID uuid, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
Optional<Player> optPlayer = VelocityLoader.getServer().getPlayer(uuid);
if(!optPlayer.isPresent()) return;
Player player = optPlayer.get();
Title titleObj = Title.title(
MiniMessage.miniMessage().deserialize(MessageTranslator.replaceMessage(StringUtils.replace(title, "%player%", player.getUsername()))),
MiniMessage.miniMessage().deserialize(MessageTranslator.replaceMessage(StringUtils.replace(subTitle, "%player%", player.getUsername()))),
Title.Times.times(Duration.ofMillis(fadeIn), Duration.ofMillis(stay), Duration.ofMillis(fadeOut))
);
player.showTitle(titleObj);
}
@Override
public void addPotionEffect(String action, UUID uuid, String potionEffectTypeName, int duration, int amplifier) {
}
@Override
public void playSound(String action, UUID uuid, String soundName, float volume, float pitch) {
}
@Override
public void sendActionbar(String action, UUID uuid, String text) {
Optional<Player> optPlayer = VelocityLoader.getServer().getPlayer(uuid);
if(!optPlayer.isPresent()) return;
Player player = optPlayer.get();
player.sendActionBar(MiniMessage.miniMessage().deserialize(MessageTranslator.replaceMessage(StringUtils.replace(text, "%player%", player.getUsername()))));
}
}
@@ -1,5 +1,6 @@
package de.rayzs.pat.utils.subargs;
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
import de.rayzs.pat.utils.StringUtils;
import java.util.*;
@@ -7,7 +8,6 @@ public class Argument {
private static final Argument GENERAL = new Argument();
private final List<String> INPUTS = new ArrayList<>();
private final HashMap<String, ArgumentStack> ARGUMENT_STACKS = new HashMap<>();
@@ -41,6 +41,11 @@ public class Argument {
public List<String> getResult(String input) {
String firstInputArg = input.contains(" ") ? input.split(" ")[0] : input;
for (Map.Entry<String, ArgumentStack> entry : ARGUMENT_STACKS.entrySet()) {
if(!entry.getKey().equals(firstInputArg)) continue;
return ARGUMENT_STACKS.get(entry.getKey()).getResult(input);
}
for (Map.Entry<String, ArgumentStack> entry : ARGUMENT_STACKS.entrySet()) {
if(!entry.getKey().startsWith(firstInputArg)) continue;
return ARGUMENT_STACKS.get(entry.getKey()).getResult(input);
@@ -88,11 +93,23 @@ public class Argument {
String current;
while(input.contains(" ")) {
current = input.split(" ")[0];
if(suggestions.contains("%online_players%"))
current = StringUtils.replaceElementsFromString(current, SubArgsModule.getPlayerNames(), "%online_players%");
if(suggestions.contains("%hidden_online_players%"))
current = StringUtils.replaceElementsFromString(current, SubArgsModule.getPlayerNames(), "%hidden_online_players%");
input = StringUtils.replaceFirst(input, current, "");
input = input.startsWith(" ") ? StringUtils.replaceFirst(input, " ", "") : input;
for (Map.Entry<String, ArgumentStack> entry : argumentStacks.entrySet()) {
if(!entry.getKey().startsWith(current)) continue;
if(entry.getKey().contains("%online_players%"))
input = StringUtils.replaceElementsFromString(input, SubArgsModule.getPlayerNames(), "%online_players%");
if(entry.getKey().contains("%hidden_online_players%"))
input = StringUtils.replaceElementsFromString(input, SubArgsModule.getPlayerNames(), "%hidden_online_players%");
return entry.getValue().getResult(input);
}
}
@@ -1,50 +0,0 @@
package de.rayzs.pat.utils.subargs;
import de.rayzs.pat.plugin.modules.subargs.SubArgsModule;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.StringUtils;
import java.util.*;
public class Responses {
private static List<Response> RESPONSES = new ArrayList<>();
public static void update() {
RESPONSES = new ArrayList<>();
Storage.Files.CUSTOM_RESPONSES.getKeys(true).stream().filter(key -> !key.equals("default-message")).forEach(key -> {
if(!key.contains(".")) {
Response response = new Response(key);
RESPONSES.add(response);
}
});
}
public static List<String> getResponse(String input) {
return getResponse(input, Storage.ConfigSections.Settings.CANCEL_COMMAND.SUB_COMMAND_RESPONSE.getLines());
}
public static List<String> getResponse(String input, List<String> defaultMessage) {
final String finalInput = input.startsWith("/") ? StringUtils.replaceFirst(input, "/", "") : input;
final Optional<Response> optionalResponse = RESPONSES.stream().filter(response -> {
for (String trigger : response.triggers)
if(trigger.endsWith("*") ? finalInput.startsWith(StringUtils.replace(trigger, "*", "")) : finalInput.equals(trigger))
return true;
return false;
}).findFirst();
return optionalResponse.isPresent() ? optionalResponse.get().message : defaultMessage;
}
private static class Response {
private final List<String> triggers, message;
public Response(final String key) {
this.triggers = (List<String>) Storage.Files.CUSTOM_RESPONSES.get(key + ".triggers");
this.message = (List<String>) Storage.Files.CUSTOM_RESPONSES.getOrSet(key + ".message", SubArgsModule.BLOCKED_MESSAGE);
}
}
}
+1 -1
View File
@@ -2,7 +2,7 @@ name: ProAntiTab
description: Hide more than just your plugins. Hide almost everything!
author: Rayzs_YT
version: 1.9.0
version: 1.9.2
main: de.rayzs.pat.plugin.BungeeLoader
softDepends:
+13 -5
View File
@@ -11,6 +11,7 @@
updater:
enabled: true
period: 10000
auto-update-config: true
updated:
- '&8[&2PAT &7| &2Bukkit&8] &aYou are using the newest version! ^^'
outdated:
@@ -92,11 +93,14 @@ cancel-blocked-commands:
# Here you can customize your own fake '/plugins' command.
custom-plugins:
enabled: true
# If this is set to true, the command will always be tab-completable,
# even if the command is supposed to be blocked
always-tab-completable: false
commands:
- pl
- plugins
- bukkit:pl
- bukkit:plugins
message:
- '&fPlugins (0):'
@@ -104,12 +108,16 @@ custom-plugins:
# Here you can customize your own fake '/version' command.
custom-version:
enabled: true
# If this is set to true, the command will always be tab-completable,
# even if the command is supposed to be blocked
always-tab-completable: false
commands:
- icanhasbukkit
- about
- version
- ver
- icanhasbukkit
- bukkit:ver
- bukkit:version
message:
- '&fThis server is running CraftBukkit version git-NasaSpigot-294 (MC: X)'
@@ -6,10 +6,29 @@
# custom-responses.yml
#
# Here you can configure a few of the blocked commands a bit further.
# But what exactly is this here? Every command that would normally respond with the typical "command is blocked" message, can be configured in here!
# But how does it work? It's simple. You just provide the a trigger of the command that would be normally blocked.
# Commands that would normally work won't send the messages you have set here.
# This way PAT can offer you full control over certain commands and their normal responses.
# But what exactly is this here? Every command that would normally respond with the typical "command is blocked" message, can be configured in here!
# And how does it work? It's simple. You just provide the a trigger of the command that would be normally blocked.
# Commands that would normally work won't send the messages you have set here.
# This way PAT can offer you full control over certain commands and their normal responses.
# What are these action section at each block?
# This is an additional feature to make your responses much more alive.
# Example actions that can be used are the following:
# Execute console command:
# Syntax: console::command
# Example: console::say %player% is an evil player
# Send actionbar:
# Syntax: actionbar::text
# Example: actionbar::&cThis is not cool %player%!
# Send title:
# Syntax: title::title::subtitle::5::20::5
# Example: title::&aTest title::&cHello %player%!
# Play sound:
# Syntax: sound::soundName::volume::pitch
# Example: sound::ENTITY_ENDER_DRAGON_GROWL::1.0::1.0
# Give potion effect:
# Syntax: effect::potionEffect::duration::amplifier
# Example: effect::BLINDNESS::45::1
# Here are a few examples:
# Example with kits.
@@ -17,19 +36,31 @@
# If this command would work through sub-arguments, then the player would only able to execute the command with the
# listed sub-arguments assigned to it. Everything else will result with the set message in there.
# --
# example-with-kits:
# triggers:
# - "kit *"
# message:
# - "&cThis kit does not exist!"
#example-with-kits:
# triggers:
# - "kit *"
# message:
# - "&cThis kit does not exist!"
# actions:
# - "console::say That's not nice %player%!"
# - "effect::BLINDNESS::45::1"
# - "sound::ENTITY_ENDER_DRAGON_GROWL::1.0::1.0"
# - "title::&cHey!::&cYou can't do that %player%!::5::20::5"
# - "actionbar::&cNop, sorry %player%"
# Here another example with an auctionhouse plugin.
# In here we only trigger the given message, if the player would type "/ah plugin".
# Normally it would print out the "command is blocked" message, because PAT would have blocked it in our case.
# Therefore, we can also assign a custom response message to it.
# ---
# example-with-auctionhouse:
# triggers:
# - "ah plugin"
# message:
# - "&cThis sub-command does not exist. Please type: &e/ah help"
#example-with-auctionhouse:
# triggers:
# - "ah plugin"
# message:
# - "&cThis sub-command does not exist. Please type: &e/ah help"
# actions:
# - "console::say That's not nice %player%!"
# - "effect::BLINDNESS::45::1"
# - "sound::ENTITY_ENDER_DRAGON_GROWL::1.0::1.0"
# - "title::&cHey!::&cYou can't do that %player%!::5::20::5"
# - "actionbar::&cNop, sorry %player%"
+20 -5
View File
@@ -11,6 +11,7 @@
updater:
enabled: true
period: 10000
auto-update-config: true
updated:
- '&8[&2PAT &7| &2Proxy&8] &aYou are using the newest version! ^^'
outdated:
@@ -19,6 +20,13 @@ updater:
- '&8[&4PAT &7| &4Proxy&8] &cGet the newest version here:'
- '&8[&4PAT &7| &4Proxy&8] &ehttps://www.rayzs.de/products/proantitab/page'
# If this value is set to 'true', the proxy won't communicate with the backend servers anymore.
# In other words, the backend servers won't receive any updates from the proxy about the storage.yml.
# It's here to prevent any unnecessary communication between the proxy and the backend servers, if PAT is being used on the proxy alone.
# For why this can be the case, read the following: https://github.com/RayzsYT/ProAntiTab/wiki/FAQ#can-i-install-pat-just-on-my-proxy-server
# It is NOT recommended to enable this option, unless you know what you are doing.
disable-sync: false
# This is a very necessary feature if you have way too many commands to block and instead decide
# to whitelist specific commands.
# Enabling this will disable ALL commands except for those that are in the (group-)list.
@@ -74,23 +82,30 @@ cancel-blocked-commands:
# Here you can customize your own fake '/plugins' command.
custom-plugins:
enabled: true
# If this is set to true, the command will always be tab-completable,
# even if the command is supposed to be blocked
always-tab-completable: false
commands:
- pl
- plugins
- bukkit:pl
- bukkit:plugins
message:
- '&fPlugins (0):'
# Here you can customize your own fake '/version' command.
custom-version:
enabled: true
# If this is set to true, the command will always be tab-completable,
# even if the command is supposed to be blocked
always-tab-completable: false
commands:
- icanhasbukkit
- about
- version
- ver
- icanhasbukkit
- bukkit:ver
- bukkit:version
message:
- '&fThis server is running CraftBukkit version git-NasaSpigot-294 (MC: X)'
@@ -6,10 +6,23 @@
# custom-responses.yml
#
# Here you can configure a few of the blocked commands a bit further.
# But what exactly is this here? Every command that would normally respond with the typical "command is blocked" message, can be configured in here!
# But how does it work? It's simple. You just provide the a trigger of the command that would be normally blocked.
# Commands that would normally work won't send the messages you have set here.
# This way PAT can offer you full control over certain commands and their normal responses.
# But what exactly is this here? Every command that would normally respond with the typical "command is blocked" message, can be configured in here!
# And how does it work? It's simple. You just provide the a trigger of the command that would be normally blocked.
# Commands that would normally work won't send the messages you have set here.
# This way PAT can offer you full control over certain commands and their normal responses.
# What are these action section at each block?
# This is an additional feature to make your responses much more alive.
# Example actions that can be used are the following:
# Execute console command:
# Syntax: console::command
# Example: console::send %player% fallback
# Send actionbar:
# Syntax: actionbar::text
# Example: actionbar::&cThis is not cool %player%!
# Send title:
# Syntax: title::title::subtitle::5::20::5
# Example: title::&aTest title::&cHello %player%!
# Here are a few examples:
# Example with kits.
@@ -17,19 +30,27 @@
# If this command would work through sub-arguments, then the player would only able to execute the command with the
# listed sub-arguments assigned to it. Everything else will result with the set message in there.
# --
# example-with-kits:
# triggers:
# - "kit *"
# message:
# - "&cThis kit does not exist!"
#example-with-kits:
# triggers:
# - "kit *"
# message:
# - "&cThis kit does not exist!"
# actions:
# - "console::say That's not nice %player%!"
# - "title::Hey!::You can't do that %player%!::30::3000::30"
# - "actionbar::Nop, sorry %player%"
# Here another example with an auctionhouse plugin.
# In here we only trigger the given message, if the player would type "/ah plugin".
# Normally it would print out the "command is blocked" message, because PAT would have blocked it in our case.
# Therefore, we can also assign a custom response message to it.
# ---
# example-with-auctionhouse:
# triggers:
# - "ah plugin"
# message:
# - "&cThis sub-command does not exist. Please type: &e/ah help"
#example-with-auctionhouse:
# triggers:
# - "ah plugin"
# message:
# - "&cThis sub-command does not exist. Please type: &e/ah help"
# actions:
# - "console::say That's not nice %player%!"
# - "title::Hey!::You can't do that %player%!::30::3000::30"
# - "actionbar::Nop, sorry %player%"
+1 -1
View File
@@ -2,7 +2,7 @@ name: ProAntiTab
description: Hide more than just your plugins. Hide almost everything!
author: Rayzs_YT
version: 1.9.0
version: 1.9.2
api-version: 1.13
folia-supported: true
main: de.rayzs.pat.plugin.BukkitLoader