├── src └── main │ ├── java │ └── de │ │ └── rayzs │ │ └── pat │ │ ├── plugin │ │ ├── logger │ │ │ ├── LoggerPriority.java │ │ │ ├── LoggerTemplate.java │ │ │ └── impl │ │ │ │ ├── BukkitLogger.java │ │ │ │ ├── VelocityLogger.java │ │ │ │ └── BungeeLogger.java │ │ ├── metrics │ │ │ └── bStats.java │ │ ├── commands │ │ │ ├── VelocityCommand.java │ │ │ ├── BungeeCommand.java │ │ │ └── BukkitCommand.java │ │ ├── process │ │ │ └── impl │ │ │ │ └── local │ │ │ │ ├── system │ │ │ │ ├── PostDebugCommand.java │ │ │ │ ├── ReloadCommand.java │ │ │ │ ├── NotifyCommand.java │ │ │ │ └── UpdateCommand.java │ │ │ │ ├── modify │ │ │ │ ├── list │ │ │ │ │ ├── ListGroupsCommand.java │ │ │ │ │ ├── ListPrioritiesCommand.java │ │ │ │ │ └── ListCommand.java │ │ │ │ ├── ConvertCommand.java │ │ │ │ ├── CreateGroupCommand.java │ │ │ │ ├── SetPriorityCommand.java │ │ │ │ ├── DeleteGroupCommand.java │ │ │ │ └── ClearCommand.java │ │ │ │ └── info │ │ │ │ ├── PermsCommand.java │ │ │ │ ├── InfoCommand.java │ │ │ │ └── StatsCommand.java │ │ ├── converter │ │ │ ├── StorageConverter.java │ │ │ ├── converters │ │ │ │ ├── PluginHiderPlus.java │ │ │ │ ├── CommandWhitelistConverter.java │ │ │ │ ├── AdvancedPlHideConverter.java │ │ │ │ └── PlHideFree.java │ │ │ └── Converter.java │ │ ├── PluginLoader.java │ │ └── listeners │ │ │ └── velocity │ │ │ └── VelocityPingListener.java │ │ ├── utils │ │ ├── permission │ │ │ ├── PermissionPlugin.java │ │ │ └── PermissionMap.java │ │ ├── scheduler │ │ │ ├── PATSchedulerTask.java │ │ │ ├── impl │ │ │ │ ├── FoliaScheduler.java │ │ │ │ └── BukkitScheduler.java │ │ │ └── PATScheduler.java │ │ ├── adapter │ │ │ ├── ViaVersionAdapter.java │ │ │ └── GroupManagerAdapter.java │ │ ├── sender │ │ │ ├── CommandSender.java │ │ │ ├── CommandSenderAbstract.java │ │ │ └── CommandSenderHandler.java │ │ ├── response │ │ │ └── action │ │ │ │ ├── Action.java │ │ │ │ └── ActionHandler.java │ │ ├── message │ │ │ ├── replacer │ │ │ │ ├── impl │ │ │ │ │ ├── BukkitPlaceholderReplacer.java │ │ │ │ │ └── ProxyPlaceholderReplacer.java │ │ │ │ └── PlaceholderReplacer.java │ │ │ ├── Translator.java │ │ │ └── translators │ │ │ │ ├── VelocityMessageTranslator.java │ │ │ │ ├── BukkitMessageTranslator.java │ │ │ │ └── BungeeMessageTranslator.java │ │ ├── configuration │ │ │ ├── helper │ │ │ │ ├── MultipleMessagesHelper.java │ │ │ │ └── ConfigSectionHelper.java │ │ │ ├── ConfigurationBuilder.java │ │ │ └── yaml │ │ │ │ ├── ConfigurationProvider.java │ │ │ │ └── JsonConfiguration.java │ │ ├── ArrayUtils.java │ │ ├── group │ │ │ └── TinyGroup.java │ │ ├── LimitedList.java │ │ ├── ExpireList.java │ │ ├── subargs │ │ │ ├── ArgumentSource.java │ │ │ ├── Arguments.java │ │ │ ├── ArgumentBuilder.java │ │ │ └── ArgumentStack.java │ │ ├── NumberUtils.java │ │ ├── hooks │ │ │ └── PlaceholderHook.java │ │ ├── TimeConverter.java │ │ ├── ExpireCache.java │ │ └── ConnectionBuilder.java │ │ └── api │ │ ├── communication │ │ ├── Client.java │ │ ├── client │ │ │ ├── impl │ │ │ │ ├── VelocityClientInfo.java │ │ │ │ └── BungeeClientInfo.java │ │ │ └── ClientInfo.java │ │ ├── BackendUpdater.java │ │ └── impl │ │ │ ├── BukkitClient.java │ │ │ ├── BungeeClient.java │ │ │ └── VelocityClient.java │ │ ├── brand │ │ ├── ServerBrand.java │ │ └── CustomServerBrand.java │ │ ├── netty │ │ └── bukkit │ │ │ └── BukkitPacketHandler.java │ │ ├── event │ │ ├── events │ │ │ ├── UpdatePluginEvent.java │ │ │ ├── ServerPlayersChangeEvent.java │ │ │ ├── ReceiveSyncEvent.java │ │ │ ├── bukkit │ │ │ │ ├── FilteredSuggestionEvent.java │ │ │ │ ├── FilteredTabCompletionEvent.java │ │ │ │ └── ExecuteCommandEvent.java │ │ │ ├── FilteredSuggestionEvent.java │ │ │ ├── UpdatePlayerCommandsEvent.java │ │ │ ├── SentSyncEvent.java │ │ │ ├── FilteredTabCompletionEvent.java │ │ │ └── ExecuteCommandEvent.java │ │ └── PATEvent.java │ │ ├── storage │ │ ├── storages │ │ │ ├── ConfigStorage.java │ │ │ ├── PlaceholderStorage.java │ │ │ ├── IgnoredServersStorage.java │ │ │ └── DisabledServersStorage.java │ │ ├── placeholders │ │ │ ├── general │ │ │ │ ├── GeneralNewestVersionPlaceholder.java │ │ │ │ ├── GeneralCurrentVersionPlaceholder.java │ │ │ │ ├── GeneralPrefixPlaceholder.java │ │ │ │ └── GeneralUserPlaceholder.java │ │ │ ├── groups │ │ │ │ ├── ListSizeGroupsPlaceholder.java │ │ │ │ ├── ListGroupsPlaceholder.java │ │ │ │ ├── ListGroupsSortedPlaceholder.java │ │ │ │ └── ListGroupsReversedPlaceholder.java │ │ │ ├── commands │ │ │ │ ├── general │ │ │ │ │ ├── ListSizeCommandsPlaceholder.java │ │ │ │ │ ├── ListSortedCommandsPlaceholder.java │ │ │ │ │ ├── ListReversedCommandsPlaceholder.java │ │ │ │ │ └── ListCommandsPlaceholder.java │ │ │ │ └── group │ │ │ │ │ ├── ListGroupSizeCommandsPlaceholder.java │ │ │ │ │ ├── ListGroupCommandsPlaceholder.java │ │ │ │ │ ├── ListGroupSortedCommandsPlaceholder.java │ │ │ │ │ └── ListGroupReversedCommandsPlaceholder.java │ │ │ └── messages │ │ │ │ ├── UnknownCommandPlaceholder.java │ │ │ │ ├── BlockedSubCommandPlaceholder.java │ │ │ │ └── BlockedBaseCommandPlaceholder.java │ │ ├── config │ │ │ ├── messages │ │ │ │ ├── PrefixSection.java │ │ │ │ ├── CommandFailedSection.java │ │ │ │ ├── NoPermissionSection.java │ │ │ │ ├── OnlyForProxySection.java │ │ │ │ ├── ReloadSection.java │ │ │ │ ├── PostDebugSection.java │ │ │ │ ├── UpdatePermissionsSection.java │ │ │ │ ├── ConvertSection.java │ │ │ │ ├── PermsCheckSection.java │ │ │ │ ├── NotificationSection.java │ │ │ │ ├── ExtractSection.java │ │ │ │ ├── StatsSection.java │ │ │ │ ├── InfoSection.java │ │ │ │ └── ServerListSection.java │ │ │ └── settings │ │ │ │ ├── AllowGroupOverrulingSection.java │ │ │ │ ├── TurnBlacklistToWhitelistSection.java │ │ │ │ ├── DisableSyncSection.java │ │ │ │ ├── UpdateGroupsPerWorldSection.java │ │ │ │ ├── BaseCommandCaseSensitiveSection.java │ │ │ │ ├── UpdateGroupsPerServerSection.java │ │ │ │ ├── CustomUnknownCommandSection.java │ │ │ │ ├── CancelCommandSection.java │ │ │ │ ├── HandleThroughProxySection.java │ │ │ │ ├── AutoLowercaseCommandsSection.java │ │ │ │ ├── PatchExploitSection.java │ │ │ │ ├── BlockNamespaceCommandsSection.java │ │ │ │ ├── CustomBrandSection.java │ │ │ │ ├── UpdateSection.java │ │ │ │ ├── CustomPluginsSection.java │ │ │ │ ├── CustomVersionSection.java │ │ │ │ └── CustomProtocolPingSection.java │ │ ├── blacklist │ │ │ ├── impl │ │ │ │ ├── GeneralIgnoredServers.java │ │ │ │ ├── GeneralBlacklist.java │ │ │ │ └── GroupBlacklist.java │ │ │ └── BlacklistCreator.java │ │ └── StorageTemplate.java │ │ └── command │ │ └── ProCommand.java │ └── resources │ ├── files │ ├── bukkit-storage.yml │ ├── proxy-storage.yml │ ├── how-to-read.txt │ └── proxy-placeholders.yml │ ├── bungee.yml │ └── plugin.yml ├── README.md └── LICENSE /src/main/java/de/rayzs/pat/plugin/logger/LoggerPriority.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.plugin.logger; 2 | 3 | public enum LoggerPriority { INFO, WARNING } 4 | -------------------------------------------------------------------------------- /src/main/resources/files/bukkit-storage.yml: -------------------------------------------------------------------------------- 1 | global: 2 | commands: 3 | - spawn 4 | groups: 5 | examplegroup: 6 | priority: 1 7 | commands: 8 | - tell 9 | - msg -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/permission/PermissionPlugin.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils.permission; 2 | 3 | public enum PermissionPlugin { 4 | LUCKPERMS, GROUPMANAGER, NONE 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/communication/Client.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.communication; 2 | 3 | public interface Client { 4 | String CHANNEL_NAME = "pat:channel"; 5 | void send(Object packet); 6 | } 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ProAntiTab 2 | 3 | ### About 4 | ProAntiTab is a Spigot/Bungeecord Minecraft plugin that helps you to hide unwanted commands from your players. 5 | 6 | ### Support versions 7 | Spigot (+ Forks): 1.8x - 1.20x (latest) 8 | Bungeecord (+ Forks) | Waterfall recommended 9 | -------------------------------------------------------------------------------- /src/main/resources/bungee.yml: -------------------------------------------------------------------------------- 1 | name: ProAntiTab 2 | description: Hides more than just your plugins. 3 | website: https://www.rayzs.de/products/proantitab/page 4 | 5 | author: Rayzs_YT 6 | version: 2.2.1 7 | main: de.rayzs.pat.plugin.BungeeLoader 8 | 9 | softDepends: [LuckPerms, PAPIProxyBridge] -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/brand/ServerBrand.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.brand; 2 | 3 | import de.rayzs.pat.utils.PacketUtils; 4 | 5 | public interface ServerBrand { 6 | void preparePlayer(Object playerObj); 7 | void send(Object playerObj); 8 | PacketUtils.BrandManipulate createPacket(Object playerObj); 9 | void initializeTask(); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/netty/bukkit/BukkitPacketHandler.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.netty.bukkit; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | public interface BukkitPacketHandler { 6 | boolean handleIncomingPacket(Player player, Object packetObj) throws Exception; 7 | boolean handleOutgoingPacket(Player player, Object packetObj) throws Exception; 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/event/events/UpdatePluginEvent.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.event.events; 2 | 3 | import de.rayzs.pat.api.event.PATEvent; 4 | 5 | public abstract class UpdatePluginEvent extends PATEvent { 6 | 7 | public UpdatePluginEvent() { 8 | super(null);; 9 | } 10 | 11 | public UpdatePluginEvent(Object senderObj) { 12 | super(senderObj); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/plugin/metrics/bStats.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.plugin.metrics; 2 | 3 | import de.rayzs.pat.plugin.metrics.impl.*; 4 | import de.rayzs.pat.utils.Reflection; 5 | 6 | public class bStats { 7 | 8 | public static void initialize(Object pluginObj) { 9 | if(Reflection.isProxyServer()) new BungeeMetrics(pluginObj, 20090); 10 | else new BukkitMetrics(pluginObj, 20089); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: ProAntiTab 2 | description: Hides more than just your plugins. 3 | website: https://www.rayzs.de/products/proantitab/page 4 | 5 | author: Rayzs_YT 6 | version: 2.2.1 7 | api-version: 1.13 8 | folia-supported: true 9 | main: de.rayzs.pat.plugin.BukkitLoader 10 | 11 | softdepend: [PlaceholderAPI, LuckPerms, GroupManager, Skript, ViaVersion, ViaBackwards, ViaRewind] 12 | 13 | commands: 14 | proantitab: 15 | aliases: [pat] -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/plugin/logger/LoggerTemplate.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.plugin.logger; 2 | 3 | import java.util.List; 4 | 5 | public interface LoggerTemplate { 6 | 7 | void info(List messages); 8 | void warn(List messages); 9 | 10 | void send(LoggerPriority priority, List messages); 11 | 12 | void info(String message); 13 | void warn(String message); 14 | 15 | void send(LoggerPriority priority, String message); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/scheduler/PATSchedulerTask.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils.scheduler; 2 | 3 | public interface PATSchedulerTask { 4 | 5 | PATSchedulerTask getInstance(boolean async, Runnable runnable, long time, long period); 6 | PATSchedulerTask getInstance(boolean async, Runnable runnable, long time); 7 | PATSchedulerTask getInstance(boolean async, Runnable runnable); 8 | 9 | boolean isActive(); 10 | void setTaskId(int taskId); 11 | 12 | void cancelTask(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/storages/ConfigStorage.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.storages; 2 | 3 | import de.rayzs.pat.api.storage.*; 4 | 5 | public class ConfigStorage extends StorageTemplate { 6 | 7 | public ConfigStorage(String navigatePath) { 8 | super(Storage.Files.CONFIGURATION, navigatePath); 9 | Storage.ConfigSections.SECTIONS.add(this); 10 | } 11 | 12 | @Override 13 | public void save() { getConfig().save(); } 14 | 15 | @Override 16 | public void load() { getConfig().reload(); } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/adapter/ViaVersionAdapter.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils.adapter; 2 | 3 | import de.rayzs.pat.api.storage.Storage; 4 | import com.viaversion.viaversion.api.*; 5 | import java.util.UUID; 6 | 7 | public class ViaVersionAdapter { 8 | 9 | private static ViaAPI API; 10 | 11 | public static void initialize() { 12 | Storage.USE_VIAVERSION = true; 13 | API = Via.getAPI(); 14 | } 15 | 16 | public static int getPlayerProtocol(UUID uuid) { 17 | return API.getPlayerVersion(uuid); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/files/proxy-storage.yml: -------------------------------------------------------------------------------- 1 | disabled-servers: 2 | - server-with-no-pat 3 | global: 4 | commands: 5 | - hub 6 | ignored-servers: 7 | - auth-* 8 | servers: 9 | lobby-*: 10 | commands: 11 | - spawn 12 | faction-1: 13 | commands: 14 | - kit 15 | groups: 16 | examplegroup: 17 | priority: 1 18 | commands: 19 | - tell 20 | - msg 21 | servers: 22 | lobby-*: 23 | commands: 24 | - cosmetics 25 | factions-1: 26 | commands: 27 | - premiumkit 28 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/general/GeneralNewestVersionPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.general; 2 | 3 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 4 | import de.rayzs.pat.api.storage.Storage; 5 | import org.bukkit.entity.Player; 6 | 7 | public class GeneralNewestVersionPlaceholder extends PlaceholderStorage { 8 | 9 | public GeneralNewestVersionPlaceholder() { super("general_version_newest"); } 10 | 11 | @Override 12 | public String onRequest(Player player, String param) { 13 | return Storage.NEWER_VERSION; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/general/GeneralCurrentVersionPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.general; 2 | 3 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 4 | import de.rayzs.pat.api.storage.Storage; 5 | import org.bukkit.entity.Player; 6 | 7 | public class GeneralCurrentVersionPlaceholder extends PlaceholderStorage { 8 | 9 | public GeneralCurrentVersionPlaceholder() { super("general_version_current"); } 10 | 11 | @Override 12 | public String onRequest(Player player, String param) { 13 | return Storage.CURRENT_VERSION; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/messages/PrefixSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.messages; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 5 | 6 | public class PrefixSection extends ConfigStorage { 7 | 8 | public String PREFIX; 9 | 10 | public PrefixSection() { 11 | super("prefix"); 12 | } 13 | 14 | @Override 15 | public void load() { 16 | super.load(); 17 | PREFIX = new ConfigSectionHelper(this, null, "&8[&4ProAntiTab&8]").getOrSet(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/event/events/ServerPlayersChangeEvent.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.event.events; 2 | 3 | import de.rayzs.pat.api.event.PATEvent; 4 | 5 | public abstract class ServerPlayersChangeEvent extends PATEvent { 6 | 7 | private final Type type; 8 | 9 | public ServerPlayersChangeEvent(Object senderObj, Type type) { 10 | super(senderObj); 11 | this.type = type; 12 | } 13 | 14 | public ServerPlayersChangeEvent() { 15 | super(null); 16 | this.type = Type.UNKNOWN; 17 | } 18 | 19 | public enum Type { JOINED, LEFT, UNKNOWN } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/event/PATEvent.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.event; 2 | 3 | public abstract class PATEvent { 4 | 5 | private final Object senderObj; 6 | private boolean cancelled = false; 7 | 8 | public PATEvent(Object senderObj) { 9 | this.senderObj = senderObj; 10 | } 11 | 12 | public abstract void handle(T t); 13 | 14 | public void setCancelled(boolean cancelled) { 15 | this.cancelled = cancelled; 16 | } 17 | public Object getSenderObj() { 18 | return senderObj; 19 | } 20 | 21 | public boolean isCancelled() { 22 | return cancelled; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/settings/AllowGroupOverrulingSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.settings; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 5 | 6 | public class AllowGroupOverrulingSection extends ConfigStorage { 7 | 8 | public boolean ENABLED; 9 | 10 | public AllowGroupOverrulingSection() { 11 | super("allow-group-overruling"); 12 | } 13 | 14 | @Override 15 | public void load() { 16 | super.load(); 17 | ENABLED = new ConfigSectionHelper(this, null, false).getOrSet(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/settings/TurnBlacklistToWhitelistSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.settings; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 5 | 6 | public class TurnBlacklistToWhitelistSection extends ConfigStorage { 7 | 8 | public boolean ENABLED; 9 | 10 | public TurnBlacklistToWhitelistSection() { 11 | super("turn-blacklist-to-whitelist"); 12 | } 13 | 14 | @Override 15 | public void load() { 16 | super.load(); 17 | ENABLED = new ConfigSectionHelper(this, null, false).getOrSet(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/general/GeneralPrefixPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.general; 2 | 3 | import de.rayzs.pat.api.storage.Storage; 4 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 5 | import org.bukkit.entity.Player; 6 | 7 | public class GeneralPrefixPlaceholder extends PlaceholderStorage { 8 | 9 | public GeneralPrefixPlaceholder() { super("general_prefix"); } 10 | 11 | @Override 12 | public String onRequest(Player player, String param) { 13 | if (Storage.ConfigSections.Messages.PREFIX == null) return null; 14 | return Storage.ConfigSections.Messages.PREFIX.PREFIX; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/sender/CommandSender.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils.sender; 2 | 3 | import de.rayzs.pat.utils.group.Group; 4 | 5 | import java.util.List; 6 | import java.util.UUID; 7 | 8 | public interface CommandSender { 9 | 10 | void updateSenderObject(Object senderObj); 11 | Object getSenderObject(); 12 | 13 | boolean isConsole(); 14 | boolean isPlayer(); 15 | 16 | boolean isOperator(); 17 | boolean hasPermission(String permission); 18 | 19 | UUID getUniqueId(); 20 | 21 | String getName(); 22 | String getServerName(); 23 | 24 | List getGroups(); 25 | void updateGroups(); 26 | 27 | void sendMessage(String message); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/plugin/commands/VelocityCommand.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.plugin.commands; 2 | 3 | import com.velocitypowered.api.command.SimpleCommand; 4 | import de.rayzs.pat.plugin.process.CommandProcess; 5 | import java.util.List; 6 | 7 | public class VelocityCommand implements SimpleCommand { 8 | 9 | @Override 10 | public void execute(Invocation invocation) { 11 | CommandProcess.handleCommand(invocation.source(), invocation.arguments(), "bpat"); 12 | } 13 | 14 | @Override 15 | public List suggest(Invocation invocation) { 16 | return CommandProcess.handleTabComplete(invocation.source(), invocation.arguments()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/messages/CommandFailedSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.messages; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 5 | 6 | public class CommandFailedSection extends ConfigStorage { 7 | 8 | public String MESSAGE; 9 | 10 | public CommandFailedSection() { 11 | super("command-failed"); 12 | } 13 | 14 | @Override 15 | public void load() { 16 | super.load(); 17 | MESSAGE = new ConfigSectionHelper(this, null, "&cFailed to execute this command! Use \"/pat\" to see all available commands.").getOrSet(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/groups/ListSizeGroupsPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.groups; 2 | 3 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 4 | import de.rayzs.pat.utils.group.GroupManager; 5 | import org.bukkit.entity.Player; 6 | 7 | public class ListSizeGroupsPlaceholder extends PlaceholderStorage { 8 | 9 | public ListSizeGroupsPlaceholder() { super("list_size_groups"); } 10 | 11 | @Override 12 | public String onRequest(Player player, String param) { 13 | return String.valueOf(GroupManager.getGroups().size()); 14 | } 15 | 16 | @Override 17 | public void load() { 18 | super.load(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/messages/NoPermissionSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.messages; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 5 | 6 | public class NoPermissionSection extends ConfigStorage { 7 | 8 | public String MESSAGE; 9 | 10 | public NoPermissionSection() { 11 | super("no-permissions"); 12 | } 13 | 14 | @Override 15 | public void load() { 16 | super.load(); 17 | MESSAGE = new ConfigSectionHelper(this, null, "&cYou are not allowed to execute this command! Missing permission: &4proantitab.%permission%").getOrSet(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/settings/DisableSyncSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.settings; 2 | 3 | import de.rayzs.pat.utils.Reflection; 4 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 5 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 6 | 7 | public class DisableSyncSection extends ConfigStorage { 8 | 9 | public boolean DISABLED; 10 | 11 | public DisableSyncSection() { 12 | super("disable-sync"); 13 | } 14 | 15 | @Override 16 | public void load() { 17 | super.load(); 18 | 19 | if(!Reflection.isProxyServer()) return; 20 | DISABLED = new ConfigSectionHelper(this, null, false).getOrSet(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/commands/general/ListSizeCommandsPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.commands.general; 2 | 3 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 4 | import de.rayzs.pat.api.storage.Storage; 5 | import org.bukkit.entity.Player; 6 | 7 | public class ListSizeCommandsPlaceholder extends PlaceholderStorage { 8 | 9 | public ListSizeCommandsPlaceholder() { super("list_size_commands"); } 10 | 11 | @Override 12 | public String onRequest(Player player, String param) { 13 | return String.valueOf(Storage.Blacklist.getBlacklist().getCommands().size()); 14 | } 15 | 16 | @Override 17 | public void load() { 18 | super.load(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/messages/OnlyForProxySection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.messages; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 5 | import de.rayzs.pat.utils.Reflection; 6 | 7 | public class OnlyForProxySection extends ConfigStorage { 8 | 9 | public String MESSAGE; 10 | 11 | public OnlyForProxySection() { 12 | super("only-for-proxy"); 13 | } 14 | 15 | @Override 16 | public void load() { 17 | super.load(); 18 | if(Reflection.isProxyServer()) return; 19 | MESSAGE = new ConfigSectionHelper(this, null, "&cThis command works on Bungeecord/Velocity servers only!").getOrSet(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/messages/ReloadSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.messages; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 5 | 6 | public class ReloadSection extends ConfigStorage { 7 | 8 | public String LOADING, DONE; 9 | 10 | public ReloadSection() { 11 | super("reload"); 12 | } 13 | 14 | @Override 15 | public void load() { 16 | super.load(); 17 | LOADING = new ConfigSectionHelper(this, "loading", "&eReloading all configuration files...").getOrSet(); 18 | DONE = new ConfigSectionHelper(this, "done", "&aSuccessfully reloaded all configuration files!").getOrSet(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/event/events/ReceiveSyncEvent.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.event.events; 2 | 3 | import de.rayzs.pat.utils.CommunicationPackets; 4 | import de.rayzs.pat.api.event.PATEvent; 5 | 6 | public abstract class ReceiveSyncEvent extends PATEvent { 7 | 8 | private final CommunicationPackets.PacketBundle packetBundle; 9 | 10 | public ReceiveSyncEvent() { 11 | super(null); 12 | this.packetBundle = null; 13 | } 14 | 15 | public ReceiveSyncEvent(Object senderObj, CommunicationPackets.PacketBundle packetBundle) { 16 | super(senderObj); 17 | this.packetBundle = packetBundle; 18 | } 19 | 20 | public CommunicationPackets.PacketBundle getPacketBundle() { 21 | return packetBundle; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/settings/UpdateGroupsPerWorldSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.settings; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import de.rayzs.pat.utils.Reflection; 5 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 6 | 7 | public class UpdateGroupsPerWorldSection extends ConfigStorage { 8 | 9 | public boolean ENABLED; 10 | 11 | public UpdateGroupsPerWorldSection() { 12 | super("update-groups-per-world"); 13 | } 14 | 15 | @Override 16 | public void load() { 17 | super.load(); 18 | 19 | if (Reflection.isProxyServer()) 20 | return; 21 | 22 | ENABLED = new ConfigSectionHelper(this, null, false).getOrSet(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/response/action/Action.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils.response.action; 2 | 3 | import java.util.UUID; 4 | 5 | public interface Action { 6 | 7 | void executeConsoleCommand(String action, UUID uuid, String command, String message); 8 | void executePlayerCommand(String action, UUID uuid, String command, String message); 9 | void sendTitle(String action, UUID uuid, String command, String title, String subTitle, int fadeIn, int stay, int fadeOut); 10 | void addPotionEffect(String action, UUID uuid, String potionEffectTypeName, int duration, int amplifier); 11 | void playSound(String action, UUID uuid, String soundName, float volume, float pitch); 12 | void sendActionbar(String action, UUID uuid, String command, String message); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/settings/BaseCommandCaseSensitiveSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.settings; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 5 | import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper; 6 | 7 | import java.util.Collections; 8 | 9 | public class BaseCommandCaseSensitiveSection extends ConfigStorage { 10 | 11 | public boolean ENABLED; 12 | 13 | public BaseCommandCaseSensitiveSection() { 14 | super("base-command-case-sensitive"); 15 | } 16 | 17 | @Override 18 | public void load() { 19 | super.load(); 20 | ENABLED = new ConfigSectionHelper(this, null, true).getOrSet(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/event/events/bukkit/FilteredSuggestionEvent.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.event.events.bukkit; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.Event; 5 | import java.util.List; 6 | 7 | public abstract class FilteredSuggestionEvent extends Event { 8 | 9 | private List suggestions; 10 | 11 | public FilteredSuggestionEvent() { 12 | this.suggestions = null; 13 | } 14 | 15 | public FilteredSuggestionEvent(Player player, List suggestions) { 16 | this.suggestions = suggestions; 17 | } 18 | 19 | public List getSuggestions() { 20 | return suggestions; 21 | } 22 | 23 | public void setSuggestions(List suggestions) { 24 | this.suggestions = suggestions; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/plugin/commands/BungeeCommand.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.plugin.commands; 2 | 3 | import de.rayzs.pat.plugin.process.CommandProcess; 4 | import net.md_5.bungee.api.CommandSender; 5 | import net.md_5.bungee.api.plugin.*; 6 | 7 | public class BungeeCommand extends Command implements TabExecutor { 8 | 9 | public BungeeCommand(String name) { 10 | super(name); 11 | } 12 | 13 | @Override 14 | public void execute(CommandSender commandSender, String[] strings) { 15 | CommandProcess.handleCommand(commandSender, strings, "bpat"); 16 | } 17 | 18 | @Override 19 | public Iterable onTabComplete(CommandSender commandSender, String[] strings) { 20 | return CommandProcess.handleTabComplete(commandSender, strings); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/messages/UnknownCommandPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.messages; 2 | 3 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 4 | import de.rayzs.pat.api.storage.Storage; 5 | import de.rayzs.pat.utils.StringUtils; 6 | import org.bukkit.entity.Player; 7 | 8 | public class UnknownCommandPlaceholder extends PlaceholderStorage { 9 | 10 | public UnknownCommandPlaceholder() { super("message_unknowncommand"); } 11 | 12 | @Override 13 | public String onRequest(Player player, String param) { 14 | if (Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.MESSAGE == null) return null; 15 | return StringUtils.getStringList(Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.MESSAGE.getLines(), "\n"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/messages/PostDebugSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.messages; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 5 | 6 | public class PostDebugSection extends ConfigStorage { 7 | 8 | public String SUCCESS, FAILED; 9 | 10 | public PostDebugSection() { 11 | super("post-debug"); 12 | } 13 | 14 | @Override 15 | public void load() { 16 | super.load(); 17 | SUCCESS = new ConfigSectionHelper(this, "success", "&aSuccessfully uploaded debug logs: &e%link% &8(CLICK&8)").getOrSet(); 18 | FAILED = new ConfigSectionHelper(this, "failed", "&cFailed to upload debug logs!").getOrSet(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/messages/BlockedSubCommandPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.messages; 2 | 3 | import de.rayzs.pat.api.storage.Storage; 4 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 5 | import de.rayzs.pat.utils.StringUtils; 6 | import org.bukkit.entity.Player; 7 | 8 | public class BlockedSubCommandPlaceholder extends PlaceholderStorage { 9 | 10 | public BlockedSubCommandPlaceholder() { super("message_sub_blocked"); } 11 | 12 | @Override 13 | public String onRequest(Player player, String param) { 14 | if (Storage.ConfigSections.Settings.CANCEL_COMMAND.SUB_COMMAND_RESPONSE == null) return null; 15 | return StringUtils.getStringList(Storage.ConfigSections.Settings.CANCEL_COMMAND.SUB_COMMAND_RESPONSE.getLines(), "\n"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/event/events/FilteredSuggestionEvent.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.event.events; 2 | 3 | import de.rayzs.pat.api.event.PATEvent; 4 | import java.util.*; 5 | 6 | public abstract class FilteredSuggestionEvent extends PATEvent { 7 | 8 | private List suggestions; 9 | 10 | public FilteredSuggestionEvent() { 11 | super(null); 12 | this.suggestions = null; 13 | } 14 | 15 | public FilteredSuggestionEvent(Object senderObj, List suggestions) { 16 | super(senderObj); 17 | this.suggestions = suggestions; 18 | } 19 | 20 | public List getSuggestions() { 21 | return suggestions; 22 | } 23 | 24 | public void setSuggestions(List suggestions) { 25 | this.suggestions = suggestions; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/commands/group/ListGroupSizeCommandsPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.commands.group; 2 | 3 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 4 | import de.rayzs.pat.utils.group.*; 5 | import org.bukkit.entity.Player; 6 | 7 | public class ListGroupSizeCommandsPlaceholder extends PlaceholderStorage { 8 | 9 | public ListGroupSizeCommandsPlaceholder() { super("list_size_commands_group_"); } 10 | 11 | @Override 12 | public String onRequest(Player player, String param) { 13 | Group group = GroupManager.getGroupByName(param); 14 | if(group == null) return null; 15 | return String.valueOf(group.getCommands().size()); 16 | } 17 | 18 | @Override 19 | public void load() { 20 | super.load(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/messages/BlockedBaseCommandPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.messages; 2 | 3 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 4 | import de.rayzs.pat.api.storage.Storage; 5 | import de.rayzs.pat.utils.StringUtils; 6 | import org.bukkit.entity.Player; 7 | 8 | public class BlockedBaseCommandPlaceholder extends PlaceholderStorage { 9 | 10 | public BlockedBaseCommandPlaceholder() { super("message_base_blocked"); } 11 | 12 | @Override 13 | public String onRequest(Player player, String param) { 14 | if (Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE == null) return null; 15 | return StringUtils.getStringList(Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE.getLines(), "\n"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/storages/PlaceholderStorage.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.storages; 2 | 3 | import de.rayzs.pat.api.storage.*; 4 | import org.bukkit.entity.Player; 5 | 6 | public abstract class PlaceholderStorage extends StorageTemplate { 7 | 8 | private final String request; 9 | 10 | public PlaceholderStorage(String request) { 11 | super(Storage.Files.PLACEHOLDERS, request); 12 | 13 | this.request = request; 14 | Storage.ConfigSections.PLACEHOLDERS.add(this); 15 | } 16 | 17 | @Override 18 | public void save() { getConfig().save(); } 19 | 20 | @Override 21 | public void load() { getConfig().reload(); } 22 | 23 | public String getRequest() { 24 | return request; 25 | } 26 | 27 | public abstract String onRequest(Player player, String param); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/general/GeneralUserPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.general; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 5 | import org.bukkit.entity.Player; 6 | 7 | public class GeneralUserPlaceholder extends PlaceholderStorage { 8 | 9 | public GeneralUserPlaceholder() { super("general_user"); } 10 | 11 | public String CONSOLE; 12 | 13 | @Override 14 | public String onRequest(Player player, String param) { 15 | return player == null ? CONSOLE : player.getName(); 16 | } 17 | 18 | @Override 19 | public void load() { 20 | super.load(); 21 | CONSOLE = new ConfigSectionHelper(this, "console-name", "Server console").getOrSet(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/settings/UpdateGroupsPerServerSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.settings; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import de.rayzs.pat.utils.Reflection; 5 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 6 | 7 | public class UpdateGroupsPerServerSection extends ConfigStorage { 8 | 9 | // Disabled for now 10 | public boolean ENABLED = false; 11 | 12 | public UpdateGroupsPerServerSection() { 13 | super("update-groups-per-server"); 14 | } 15 | 16 | @Override 17 | public void load() { 18 | super.load(); 19 | 20 | /* 21 | if (!Reflection.isProxyServer()) 22 | return; 23 | 24 | ENABLED = new ConfigSectionHelper(this, null, false).getOrSet(); 25 | */ 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/event/events/UpdatePlayerCommandsEvent.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.event.events; 2 | 3 | import de.rayzs.pat.api.event.PATEvent; 4 | import java.util.List; 5 | 6 | public abstract class UpdatePlayerCommandsEvent extends PATEvent { 7 | 8 | private List commands; 9 | private boolean serverBased; 10 | 11 | public UpdatePlayerCommandsEvent() { 12 | super(null);; 13 | } 14 | 15 | public UpdatePlayerCommandsEvent(Object senderObj, List commands, boolean serverBased) { 16 | super(senderObj); 17 | this.commands = commands; 18 | this.serverBased = serverBased; 19 | } 20 | 21 | public List getCommands() { 22 | return commands; 23 | } 24 | 25 | public boolean isServerBased() { 26 | return serverBased; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/message/replacer/impl/BukkitPlaceholderReplacer.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils.message.replacer.impl; 2 | 3 | import de.rayzs.pat.utils.sender.CommandSender; 4 | import me.clip.placeholderapi.PlaceholderAPI; 5 | import org.bukkit.entity.Player; 6 | 7 | public class BukkitPlaceholderReplacer { 8 | 9 | public String process(Object playerObj, String text) { 10 | Player player = null; 11 | 12 | if(playerObj != null) 13 | if(playerObj instanceof CommandSender) { 14 | CommandSender sender = (CommandSender) playerObj; 15 | player = sender.isPlayer() ? (Player) sender.getSenderObject() : null; 16 | } else if(playerObj instanceof Player) 17 | player = (Player) playerObj; 18 | 19 | 20 | return PlaceholderAPI.setPlaceholders(player, text); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/configuration/helper/MultipleMessagesHelper.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils.configuration.helper; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import java.io.Serializable; 5 | import java.util.*; 6 | 7 | public class MultipleMessagesHelper implements Serializable { 8 | 9 | private final ArrayList lines; 10 | 11 | public MultipleMessagesHelper(ConfigStorage config, String path, List input) { 12 | ConfigSectionHelper> sectionHelper = new ConfigSectionHelper<>(config, path, input); 13 | 14 | if(!sectionHelper.exist()) { 15 | lines = new ArrayList<>(input); 16 | sectionHelper.set(lines); 17 | return; 18 | } 19 | 20 | lines = sectionHelper.get(); 21 | } 22 | 23 | public ArrayList getLines() { 24 | return lines; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/groups/ListGroupsPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.groups; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 5 | import de.rayzs.pat.utils.StringUtils; 6 | import de.rayzs.pat.utils.group.*; 7 | import org.bukkit.entity.Player; 8 | 9 | public class ListGroupsPlaceholder extends PlaceholderStorage { 10 | 11 | public ListGroupsPlaceholder() { super("list_groups"); } 12 | 13 | public String SPLITTER; 14 | 15 | @Override 16 | public String onRequest(Player player, String param) { 17 | return StringUtils.getStringList(GroupManager.getGroupNames(), SPLITTER); 18 | } 19 | 20 | @Override 21 | public void load() { 22 | super.load(); 23 | SPLITTER = new ConfigSectionHelper(this, "splitter", "&7, &e").getOrSet(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/communication/client/impl/VelocityClientInfo.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.communication.client.impl; 2 | 3 | import de.rayzs.pat.api.communication.impl.VelocityClient; 4 | import de.rayzs.pat.api.communication.client.ClientInfo; 5 | import de.rayzs.pat.plugin.VelocityLoader; 6 | 7 | public class VelocityClientInfo extends ClientInfo { 8 | 9 | public VelocityClientInfo(String serverId) { 10 | super(serverId); 11 | } 12 | 13 | public VelocityClientInfo(String serverId, String name) { 14 | super(serverId, name); 15 | } 16 | 17 | @Override 18 | public void sendBytes(byte[] bytes) { 19 | VelocityLoader.getServer().getAllServers().stream().filter(server -> 20 | server.getServerInfo().getName().equalsIgnoreCase(getName()) 21 | ).forEach(server -> 22 | server.sendPluginMessage(VelocityClient.getIdentifier(), bytes) 23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/groups/ListGroupsSortedPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.groups; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 5 | import de.rayzs.pat.utils.StringUtils; 6 | import de.rayzs.pat.utils.group.*; 7 | import org.bukkit.entity.Player; 8 | 9 | public class ListGroupsSortedPlaceholder extends PlaceholderStorage { 10 | 11 | public ListGroupsSortedPlaceholder() { super("list_sorted_groups"); } 12 | 13 | public String SPLITTER; 14 | 15 | @Override 16 | public String onRequest(Player player, String param) { 17 | return StringUtils.getSortedStringList(GroupManager.getGroupNames(), SPLITTER); 18 | } 19 | 20 | @Override 21 | public void load() { 22 | super.load(); 23 | SPLITTER = new ConfigSectionHelper(this, "splitter", "&7, &e").getOrSet(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/messages/UpdatePermissionsSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.messages; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 5 | 6 | public class UpdatePermissionsSection extends ConfigStorage { 7 | 8 | public String UPDATE_ALL, UPDATE_SPECIFIC, PLAYER_NOT_ONLINE; 9 | 10 | public UpdatePermissionsSection() { 11 | super("update-permissions"); 12 | } 13 | 14 | @Override 15 | public void load() { 16 | super.load(); 17 | UPDATE_ALL = new ConfigSectionHelper(this, "all-players", "&aUpdated permissions!").getOrSet(); 18 | UPDATE_SPECIFIC = new ConfigSectionHelper(this, "specific-player", "&aUpdated %target%'s permissions!").getOrSet(); 19 | PLAYER_NOT_ONLINE = new ConfigSectionHelper(this, "player-not-online", "&c%target% is not online!").getOrSet(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/groups/ListGroupsReversedPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.groups; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 5 | import de.rayzs.pat.utils.StringUtils; 6 | import de.rayzs.pat.utils.group.*; 7 | import org.bukkit.entity.Player; 8 | 9 | public class ListGroupsReversedPlaceholder extends PlaceholderStorage { 10 | 11 | public ListGroupsReversedPlaceholder() { super("list_reversed_groups"); } 12 | 13 | public String SPLITTER; 14 | 15 | @Override 16 | public String onRequest(Player player, String param) { 17 | return StringUtils.getReversedStringList(GroupManager.getGroupNames(), SPLITTER); 18 | } 19 | 20 | @Override 21 | public void load() { 22 | super.load(); 23 | SPLITTER = new ConfigSectionHelper(this, "splitter", "&7, &e").getOrSet(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/configuration/ConfigurationBuilder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils.configuration; 2 | 3 | import java.util.Collection; 4 | import java.io.File; 5 | 6 | public interface ConfigurationBuilder { 7 | void reload(); 8 | void save(); 9 | String getFilePath(); 10 | ConfigurationBuilder set(String path, String target, Object object); 11 | ConfigurationBuilder set(String target, Object object); 12 | ConfigurationBuilder setAndSave(String path, String target, Object object); 13 | ConfigurationBuilder setAndSave(String target, Object object); 14 | Object getOrSet(String path, String target, Object object); 15 | Object getOrSet(String target, Object object); 16 | Object get(String target); 17 | Object get(String path, String target); 18 | Collection getKeys(boolean deep); 19 | Collection getKeys(String section, boolean deep); 20 | File getFile(); 21 | boolean loadDefault(); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/messages/ConvertSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.messages; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 5 | import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper; 6 | 7 | public class ConvertSection extends ConfigStorage { 8 | 9 | public MultipleMessagesHelper MESSAGE; 10 | 11 | public ConvertSection() { 12 | super("convert"); 13 | } 14 | 15 | public String INVALID_CONVERTER, SUCCESS; 16 | 17 | @Override 18 | public void load() { 19 | super.load(); 20 | 21 | INVALID_CONVERTER = new ConfigSectionHelper(this, "converter-not-found", "&cConverter or necessary files could not be found!").getOrSet(); 22 | SUCCESS = new ConfigSectionHelper(this, "success", "&aSuccessfully converted &e%converter% &ainto the PAT storage.yml!").getOrSet(); 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/settings/CustomUnknownCommandSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.settings; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import de.rayzs.pat.utils.configuration.helper.*; 5 | import de.rayzs.pat.api.storage.Storage; 6 | import java.util.Collections; 7 | 8 | public class CustomUnknownCommandSection extends ConfigStorage { 9 | 10 | public boolean ENABLED; 11 | public MultipleMessagesHelper MESSAGE; 12 | 13 | public CustomUnknownCommandSection() { 14 | super("custom-unknown-command"); 15 | } 16 | 17 | @Override 18 | public void load() { 19 | super.load(); 20 | 21 | if(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) return; 22 | ENABLED = new ConfigSectionHelper(this, "enabled", true).getOrSet(); 23 | MESSAGE = new MultipleMessagesHelper(this, "message", Collections.singletonList("&cThis command does not exist!")); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/event/events/SentSyncEvent.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.event.events; 2 | 3 | import de.rayzs.pat.utils.CommunicationPackets; 4 | import de.rayzs.pat.api.event.PATEvent; 5 | 6 | public abstract class SentSyncEvent extends PATEvent { 7 | 8 | private final CommunicationPackets.PacketBundle packetBundle; 9 | private final String serverName; 10 | 11 | public SentSyncEvent() { 12 | super(null); 13 | this.packetBundle = null; 14 | this.serverName = null; 15 | } 16 | 17 | public SentSyncEvent(Object senderObj, CommunicationPackets.PacketBundle packetBundle, String serverName) { 18 | super(senderObj); 19 | this.packetBundle = packetBundle; 20 | this.serverName = serverName; 21 | } 22 | 23 | public String getServerName() { 24 | return serverName; 25 | } 26 | 27 | public CommunicationPackets.PacketBundle getPacketBundle() { 28 | return packetBundle; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/messages/PermsCheckSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.messages; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import de.rayzs.pat.utils.configuration.helper.*; 5 | 6 | public class PermsCheckSection extends ConfigStorage { 7 | 8 | public String MESSAGE, PLAYER_MISSING, PLAYER_NOT_ONLINE; 9 | 10 | public PermsCheckSection() { 11 | super("perms-check"); 12 | } 13 | 14 | @Override 15 | public void load() { 16 | super.load(); 17 | MESSAGE = new ConfigSectionHelper(this, "message", "&7All of &e%player%'s &7PAT-related permission: &e%permissions%").getOrSet(); 18 | PLAYER_MISSING = new ConfigSectionHelper(this, "player-is-missing", "&cPlease specify the player whose permission you want to check.").getOrSet(); 19 | PLAYER_NOT_ONLINE = new ConfigSectionHelper(this, "player-not-online", "&c%player% is not online!").getOrSet(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/ArrayUtils.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils; 2 | 3 | import java.util.*; 4 | 5 | public class ArrayUtils { 6 | 7 | public static boolean containsIgnoreCase(List list, String element) { 8 | return list.stream().anyMatch(element::equalsIgnoreCase); 9 | } 10 | 11 | public static boolean compareStringArrays(List listA, List listB) { 12 | if(listA == null || listB == null) 13 | return false; 14 | 15 | if (listA.size() != listB.size()) 16 | return false; 17 | 18 | if (Arrays.equals(listA.toArray(), listB.toArray())) 19 | return true; 20 | 21 | Collections.sort(listA); 22 | Collections.sort(listB); 23 | 24 | final int length = listA.size(); 25 | for (int i = 0; i < length; i++) { 26 | if (!listA.get(i).equalsIgnoreCase(listB.get(i))) 27 | return false; 28 | } 29 | 30 | return true; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/commands/general/ListSortedCommandsPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.commands.general; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 5 | import de.rayzs.pat.api.storage.Storage; 6 | import de.rayzs.pat.utils.StringUtils; 7 | import org.bukkit.entity.Player; 8 | 9 | public class ListSortedCommandsPlaceholder extends PlaceholderStorage { 10 | 11 | public ListSortedCommandsPlaceholder() { super("list_sorted_commands"); } 12 | 13 | public String SPLITTER; 14 | 15 | @Override 16 | public String onRequest(Player player, String param) { 17 | return StringUtils.getSortedStringList(Storage.Blacklist.getBlacklist().getCommands(), SPLITTER); 18 | } 19 | 20 | @Override 21 | public void load() { 22 | super.load(); 23 | SPLITTER = new ConfigSectionHelper(this, "splitter", "&7, &e").getOrSet(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/commands/general/ListReversedCommandsPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.commands.general; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 5 | import de.rayzs.pat.api.storage.Storage; 6 | import de.rayzs.pat.utils.StringUtils; 7 | import org.bukkit.entity.Player; 8 | 9 | public class ListReversedCommandsPlaceholder extends PlaceholderStorage { 10 | 11 | public ListReversedCommandsPlaceholder() { super("list_reversed_commands"); } 12 | 13 | public String SPLITTER; 14 | 15 | @Override 16 | public String onRequest(Player player, String param) { 17 | return StringUtils.getReversedStringList(Storage.Blacklist.getBlacklist().getCommands(), SPLITTER); 18 | } 19 | 20 | @Override 21 | public void load() { 22 | super.load(); 23 | SPLITTER = new ConfigSectionHelper(this, "splitter", "&7, &e").getOrSet(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/commands/general/ListCommandsPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.commands.general; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 5 | import de.rayzs.pat.api.storage.Storage; 6 | import de.rayzs.pat.utils.StringUtils; 7 | import de.rayzs.pat.utils.group.GroupManager; 8 | import org.bukkit.entity.Player; 9 | 10 | public class ListCommandsPlaceholder extends PlaceholderStorage { 11 | 12 | public ListCommandsPlaceholder() { super("list_commands"); } 13 | 14 | public String SPLITTER; 15 | 16 | @Override 17 | public String onRequest(Player player, String param) { 18 | return StringUtils.getStringList(Storage.Blacklist.getBlacklist().getCommands(), SPLITTER); 19 | } 20 | 21 | @Override 22 | public void load() { 23 | super.load(); 24 | SPLITTER = new ConfigSectionHelper(this, "splitter", "&7, &e").getOrSet(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/settings/CancelCommandSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.settings; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import de.rayzs.pat.utils.configuration.helper.*; 5 | import java.util.Collections; 6 | 7 | public class CancelCommandSection extends ConfigStorage { 8 | 9 | public boolean ENABLED; 10 | public MultipleMessagesHelper BASE_COMMAND_RESPONSE, SUB_COMMAND_RESPONSE; 11 | 12 | public CancelCommandSection() { 13 | super("cancel-blocked-commands"); 14 | } 15 | 16 | @Override 17 | public void load() { 18 | super.load(); 19 | ENABLED = new ConfigSectionHelper(this, "enabled", true).getOrSet(); 20 | BASE_COMMAND_RESPONSE = new MultipleMessagesHelper(this, "base-command-message", Collections.singletonList("&cThe command %command% is blocked!")); 21 | SUB_COMMAND_RESPONSE = new MultipleMessagesHelper(this, "sub-command-message", Collections.singletonList("&cThis sub-argument is blocked!")); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/blacklist/impl/GeneralIgnoredServers.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.blacklist.impl; 2 | 3 | import de.rayzs.pat.api.storage.storages.IgnoredServersStorage; 4 | 5 | public class GeneralIgnoredServers extends IgnoredServersStorage { 6 | 7 | public GeneralIgnoredServers() { 8 | super("global.ignored-servers"); 9 | } 10 | 11 | @Override 12 | public IgnoredServersStorage add(String server) { 13 | return super.add(server); 14 | } 15 | 16 | @Override 17 | public IgnoredServersStorage remove(String server) { 18 | return super.remove(server); 19 | } 20 | 21 | @Override 22 | public boolean isListed(String server) { 23 | return super.isListed(server); 24 | } 25 | 26 | @Override 27 | public boolean isListEmpty() { 28 | return super.isListEmpty(); 29 | } 30 | 31 | @Override 32 | public void load() { 33 | super.load(); 34 | } 35 | 36 | @Override 37 | public void save() { 38 | super.save(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/plugin/commands/BukkitCommand.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.plugin.commands; 2 | 3 | import de.rayzs.pat.plugin.process.CommandProcess; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.command.*; 6 | import java.util.List; 7 | 8 | public class BukkitCommand implements CommandExecutor, TabCompleter { 9 | 10 | @Override 11 | public boolean onCommand(CommandSender commandSender, Command command, String label, String[] strings) { 12 | if(commandSender instanceof Player) { 13 | Player player = (Player) commandSender; 14 | 15 | CommandProcess.handleCommand(player, strings, label); 16 | return true; 17 | } 18 | 19 | CommandProcess.handleCommand(commandSender, strings, label); 20 | return true; 21 | } 22 | 23 | @Override 24 | public List onTabComplete(CommandSender commandSender, Command command, String label, String[] strings) { 25 | return CommandProcess.handleTabComplete(commandSender, strings); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/event/events/bukkit/FilteredTabCompletionEvent.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.event.events.bukkit; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.Event; 5 | import java.util.List; 6 | 7 | public abstract class FilteredTabCompletionEvent extends Event { 8 | 9 | private String cursor; 10 | private List completion; 11 | 12 | public FilteredTabCompletionEvent() { 13 | this.cursor = null; 14 | this.completion = null; 15 | } 16 | 17 | public FilteredTabCompletionEvent(Player player, String cursor, List completion) { 18 | this.cursor = cursor; 19 | this.completion = completion; 20 | } 21 | 22 | public abstract void handle(FilteredTabCompletionEvent event); 23 | 24 | public String getCursor() { 25 | return cursor; 26 | } 27 | 28 | public List getCompletion() { 29 | return completion; 30 | } 31 | 32 | public void setCompletion(List completion) { 33 | this.completion = completion; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/group/TinyGroup.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils.group; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | public class TinyGroup implements Serializable { 7 | 8 | private final String groupName; 9 | private final int priority; 10 | private final List commands; 11 | 12 | public TinyGroup(String groupName, int priority, List commands) { 13 | this.groupName = groupName; 14 | this.commands = commands; 15 | this.priority = priority; 16 | } 17 | 18 | public void add(String command) { 19 | if(this.commands.contains(command)) return; 20 | this.commands.add(command); 21 | } 22 | 23 | public void addAll(List commands) { 24 | commands.forEach(this::add); 25 | } 26 | 27 | public String getGroupName() { 28 | return groupName; 29 | } 30 | 31 | public int getPriority() { 32 | return priority; 33 | } 34 | 35 | public List getCommands() { 36 | return commands; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/configuration/helper/ConfigSectionHelper.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils.configuration.helper; 2 | 3 | import de.rayzs.pat.utils.configuration.ConfigurationBuilder; 4 | import de.rayzs.pat.api.storage.StorageTemplate; 5 | 6 | public class ConfigSectionHelper { 7 | 8 | private final ConfigurationBuilder configuration; 9 | private final String path; 10 | private final Object obj; 11 | 12 | public ConfigSectionHelper(StorageTemplate config, String path, Object obj) { 13 | this.configuration = config.getConfig(); 14 | this.path = config.getNavigatePath() + (path != null ? "." + path : ""); ; 15 | this.obj = obj; 16 | } 17 | 18 | public boolean exist() { 19 | return get() != null; 20 | } 21 | 22 | public void set(Object obj) { 23 | configuration.setAndSave(path, obj); 24 | } 25 | 26 | public T get() { 27 | return (T) configuration.get(path); 28 | } 29 | 30 | public T getOrSet() { 31 | return (T) configuration.getOrSet(path, obj); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/commands/group/ListGroupCommandsPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.commands.group; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 5 | import de.rayzs.pat.utils.StringUtils; 6 | import de.rayzs.pat.utils.group.*; 7 | import org.bukkit.entity.Player; 8 | 9 | public class ListGroupCommandsPlaceholder extends PlaceholderStorage { 10 | 11 | public ListGroupCommandsPlaceholder() { super("list_commands_group_"); } 12 | 13 | public String SPLITTER; 14 | 15 | @Override 16 | public String onRequest(Player player, String param) { 17 | Group group = GroupManager.getGroupByName(param); 18 | if(group == null) return null; 19 | 20 | return StringUtils.getStringList(group.getCommands(), SPLITTER); 21 | } 22 | 23 | @Override 24 | public void load() { 25 | super.load(); 26 | SPLITTER = new ConfigSectionHelper(this, "splitter", "&7, &e").getOrSet(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/event/events/FilteredTabCompletionEvent.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.event.events; 2 | 3 | import de.rayzs.pat.api.event.PATEvent; 4 | import java.util.*; 5 | 6 | public abstract class FilteredTabCompletionEvent extends PATEvent { 7 | 8 | private String cursor; 9 | private List completion; 10 | 11 | public FilteredTabCompletionEvent() { 12 | super(null); 13 | this.cursor = null; 14 | this.completion = null; 15 | } 16 | 17 | public FilteredTabCompletionEvent(Object senderObj, String cursor, List completion) { 18 | super(senderObj); 19 | this.cursor = cursor; 20 | this.completion = completion; 21 | } 22 | 23 | public abstract void handle(FilteredTabCompletionEvent event); 24 | 25 | public String getCursor() { 26 | return cursor; 27 | } 28 | 29 | public List getCompletion() { 30 | return completion; 31 | } 32 | 33 | public void setCompletion(List completion) { 34 | this.completion = completion; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/LimitedList.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils; 2 | 3 | import java.util.ArrayDeque; 4 | import java.util.function.Consumer; 5 | 6 | public class LimitedList { 7 | 8 | private ArrayDeque list = new ArrayDeque<>(); 9 | private final int maxCapacity; 10 | 11 | public LimitedList(int maxCapacity) { 12 | this.maxCapacity = maxCapacity; 13 | } 14 | 15 | public LimitedList(LimitedList list) { 16 | this.maxCapacity = list.maxCapacity; 17 | this.list = new ArrayDeque<>(list.getList()); 18 | } 19 | 20 | public void add(T element) { 21 | if (list.size() == maxCapacity) { 22 | list.removeFirst(); 23 | } 24 | 25 | list.add(element); 26 | } 27 | 28 | public void iterate(Consumer action) { 29 | list.forEach(action); 30 | } 31 | 32 | public int getSize() { 33 | return list.size(); 34 | } 35 | 36 | public int getMaxCapacity() { 37 | return maxCapacity; 38 | } 39 | 40 | private ArrayDeque getList() { 41 | return list; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/commands/group/ListGroupSortedCommandsPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.commands.group; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 5 | import de.rayzs.pat.utils.StringUtils; 6 | import de.rayzs.pat.utils.group.*; 7 | import org.bukkit.entity.Player; 8 | 9 | public class ListGroupSortedCommandsPlaceholder extends PlaceholderStorage { 10 | 11 | public ListGroupSortedCommandsPlaceholder() { super("list_sorted_commands_group_"); } 12 | 13 | public String SPLITTER; 14 | 15 | @Override 16 | public String onRequest(Player player, String param) { 17 | Group group = GroupManager.getGroupByName(param); 18 | if(group == null) return null; 19 | 20 | return StringUtils.getSortedStringList(group.getCommands(), SPLITTER); 21 | } 22 | 23 | @Override 24 | public void load() { 25 | super.load(); 26 | SPLITTER = new ConfigSectionHelper(this, "splitter", "&7, &e").getOrSet(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/placeholders/commands/group/ListGroupReversedCommandsPlaceholder.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.placeholders.commands.group; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.PlaceholderStorage; 5 | import de.rayzs.pat.utils.StringUtils; 6 | import de.rayzs.pat.utils.group.*; 7 | import org.bukkit.entity.Player; 8 | 9 | public class ListGroupReversedCommandsPlaceholder extends PlaceholderStorage { 10 | 11 | public ListGroupReversedCommandsPlaceholder() { super("list_reversed_commands_group_"); } 12 | 13 | public String SPLITTER; 14 | 15 | @Override 16 | public String onRequest(Player player, String param) { 17 | Group group = GroupManager.getGroupByName(param); 18 | if(group == null) return null; 19 | 20 | return StringUtils.getReversedStringList(group.getCommands(), SPLITTER); 21 | } 22 | 23 | @Override 24 | public void load() { 25 | super.load(); 26 | SPLITTER = new ConfigSectionHelper(this, "splitter", "&7, &e").getOrSet(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Alihan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/ExpireList.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | import com.google.common.cache.*; 5 | 6 | public class ExpireList { 7 | 8 | private final Cache cache; 9 | 10 | public ExpireList(long expireTime, TimeUnit timeUnit) { 11 | cache = CacheBuilder.newBuilder().concurrencyLevel(2).expireAfterWrite(expireTime, timeUnit).build(); 12 | } 13 | 14 | public ExpireList(ExpireList expireList) { 15 | cache = expireList.getCache(); 16 | } 17 | 18 | public boolean add(T t) { 19 | if(contains(t)) return false; 20 | 21 | cache.put(t, (byte) 0); 22 | return true; 23 | } 24 | 25 | public void addIgnoreIfContains(T t) { 26 | cache.put(t, (byte) 0); 27 | } 28 | 29 | public int getSize() { 30 | cache.cleanUp(); 31 | return (int) cache.size(); 32 | } 33 | 34 | public Cache getCache() { 35 | return cache; 36 | } 37 | 38 | public boolean contains(T t) { 39 | return cache.getIfPresent(t) != null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/messages/NotificationSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.messages; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import de.rayzs.pat.utils.configuration.helper.*; 5 | import de.rayzs.pat.utils.Reflection; 6 | import java.util.Collections; 7 | 8 | public class NotificationSection extends ConfigStorage { 9 | 10 | public String ENABLED, DISABLED; 11 | public MultipleMessagesHelper ALERT; 12 | 13 | public NotificationSection() { 14 | super("notification"); 15 | } 16 | 17 | @Override 18 | public void load() { 19 | super.load(); 20 | ENABLED = new ConfigSectionHelper(this, "enabled", "&aEnabled notifications").getOrSet(); 21 | DISABLED = new ConfigSectionHelper(this, "disabled", "&cDisabled notifications").getOrSet(); 22 | ALERT = new MultipleMessagesHelper(this, "alert", Collections.singletonList("&8[&4ALERT&8] &c%player% &8(&7" + (Reflection.isProxyServer() ? "server: &e%server%" : "world: &e%world%") + "&8) &ctried to execute the following blocked command: &4%command%")); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/event/events/bukkit/ExecuteCommandEvent.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.event.events.bukkit; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.Cancellable; 5 | import org.bukkit.event.Event; 6 | 7 | public abstract class ExecuteCommandEvent extends Event implements Cancellable { 8 | 9 | private final String command; 10 | private boolean blocked; 11 | 12 | public ExecuteCommandEvent() { 13 | this.blocked = false; 14 | this.command = null; 15 | } 16 | 17 | public ExecuteCommandEvent(Player player, String command, boolean blocked) { 18 | this.blocked = blocked; 19 | this.command = command; 20 | } 21 | 22 | public String getCommand() { 23 | return command; 24 | } 25 | 26 | public boolean isBlocked() { 27 | return blocked; 28 | } 29 | 30 | public void setBlocked(boolean blocked) { 31 | this.blocked = blocked; 32 | } 33 | 34 | @Override 35 | public boolean isCancelled() { 36 | return blocked; 37 | } 38 | 39 | @Override 40 | public void setCancelled(boolean cancel) { 41 | this.blocked = cancel; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/plugin/process/impl/local/system/PostDebugCommand.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.plugin.process.impl.local.system; 2 | 3 | import de.rayzs.pat.api.command.ProCommand; 4 | import de.rayzs.pat.plugin.logger.Logger; 5 | import de.rayzs.pat.utils.sender.CommandSender; 6 | import de.rayzs.pat.api.storage.Storage; 7 | import java.util.*; 8 | 9 | public class PostDebugCommand extends ProCommand { 10 | 11 | public PostDebugCommand() { 12 | super( 13 | "postdebug", 14 | "" 15 | ); 16 | } 17 | 18 | @Override 19 | public boolean execute(CommandSender sender, String[] args) { 20 | 21 | try { 22 | sender.sendMessage(Storage.ConfigSections.Messages.POST_DEBUG.SUCCESS.replace("%link%", Objects.requireNonNull(Logger.post()))); 23 | } catch (Exception exception) { 24 | sender.sendMessage(Storage.ConfigSections.Messages.POST_DEBUG.FAILED); 25 | exception.printStackTrace(); 26 | } 27 | 28 | return true; 29 | } 30 | 31 | @Override 32 | public List tabComplete(CommandSender sender, String[] args) { 33 | return List.of(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/message/Translator.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils.message; 2 | 3 | import de.rayzs.pat.utils.StringUtils; 4 | import net.kyori.adventure.text.Component; 5 | import net.kyori.adventure.text.minimessage.MiniMessage; 6 | import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; 7 | 8 | public interface Translator { 9 | 10 | MiniMessage miniMessage = MiniMessage.miniMessage(); 11 | 12 | String translate(String text); 13 | 14 | void send(Object target, String text); 15 | 16 | void sendActionbar(Object target, String text); 17 | 18 | void sendTitle(Object target, String title, String subtitle, int fadeIn, int stay, int fadeOut); 19 | 20 | void playSound(Object target, String soundKey, float volume, float pitch) throws Exception; 21 | 22 | default Component toComponent(String text) { 23 | text = StringUtils.replace(text, "§", "&"); 24 | 25 | Component legacy = LegacyComponentSerializer.legacyAmpersand().deserialize(text); 26 | text = StringUtils.replace(miniMessage.serialize(legacy), "\\", ""); 27 | 28 | return miniMessage.deserialize(text); 29 | } 30 | 31 | void close(); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/settings/HandleThroughProxySection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.settings; 2 | 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 4 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 5 | import de.rayzs.pat.utils.Reflection; 6 | 7 | public class HandleThroughProxySection extends ConfigStorage { 8 | 9 | public boolean ENABLED; 10 | 11 | public boolean LOAD_FROM_ENV; 12 | public String ENV_NAME; 13 | 14 | public String TOKEN; 15 | 16 | public HandleThroughProxySection() { 17 | super("handle-through-proxy"); 18 | } 19 | 20 | @Override 21 | public void load() { 22 | super.load(); 23 | if(Reflection.isProxyServer()) return; 24 | 25 | ENABLED = new ConfigSectionHelper(this, "enabled", false).getOrSet(); 26 | TOKEN = new ConfigSectionHelper(this, "token", "insert-token-of-proxy-here").getOrSet(); 27 | 28 | LOAD_FROM_ENV = new ConfigSectionHelper(this, "load-from-env.enabled", false).getOrSet(); 29 | ENV_NAME = new ConfigSectionHelper(this, "load-from-env.name", "PAT_TOKEN").getOrSet(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/event/events/ExecuteCommandEvent.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.event.events; 2 | 3 | import de.rayzs.pat.api.event.PATEvent; 4 | 5 | public abstract class ExecuteCommandEvent extends PATEvent { 6 | 7 | private final String command; 8 | private boolean blocked, notify; 9 | 10 | public ExecuteCommandEvent() { 11 | super(null); 12 | this.blocked = false; 13 | this.notify = false; 14 | this.command = null; 15 | } 16 | 17 | public ExecuteCommandEvent(Object senderObj, String command, boolean blocked, boolean notify) { 18 | super(senderObj); 19 | this.blocked = blocked; 20 | this.command = command; 21 | this.notify = notify; 22 | } 23 | 24 | public void setDoesNotify(boolean notify) { 25 | this.notify = notify; 26 | } 27 | 28 | public String getCommand() { 29 | return command; 30 | } 31 | 32 | public boolean isBlocked() { 33 | return blocked; 34 | } 35 | 36 | public boolean doesNotify() { 37 | return notify; 38 | } 39 | 40 | public void setBlocked(boolean blocked) { 41 | this.blocked = blocked; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/settings/AutoLowercaseCommandsSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.settings; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import de.rayzs.pat.utils.Reflection; 5 | import de.rayzs.pat.utils.StringUtils; 6 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 7 | import de.rayzs.pat.utils.permission.PermissionUtil; 8 | 9 | public class AutoLowercaseCommandsSection extends ConfigStorage { 10 | 11 | public boolean ENABLED; 12 | 13 | public AutoLowercaseCommandsSection() { 14 | super("auto-lowercase-commands"); 15 | } 16 | 17 | @Override 18 | public void load() { 19 | super.load(); 20 | 21 | if (Reflection.isProxyServer()) 22 | return; 23 | 24 | ENABLED = new ConfigSectionHelper(this, "enabled", true).getOrSet(); 25 | } 26 | 27 | public boolean isCommand(String command) { 28 | if(!ENABLED) return false; 29 | 30 | return !StringUtils.isLowercased(command); 31 | } 32 | 33 | public boolean doesBypass(Object targetObj) { 34 | return !ENABLED || PermissionUtil.hasPermission(targetObj, "auto-lowercase"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/subargs/ArgumentSource.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils.subargs; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | 7 | public class ArgumentSource { 8 | 9 | private final ArgumentBuilder GENERAL = new ArgumentBuilder(this); 10 | 11 | public final List INPUTS = new ArrayList<>(); 12 | public final HashMap ARGUMENT_STACKS = new HashMap<>(); 13 | 14 | public ArgumentBuilder getGeneralArgument() { 15 | /* Experimental removal 16 | ArgumentBuilder copiedGeneralArguments = new ArgumentBuilder(this); 17 | GENERAL.getInputs().forEach(copiedGeneralArguments::buildArgumentStacks); 18 | return copiedGeneralArguments; 19 | */ 20 | return GENERAL; 21 | } 22 | 23 | public List getOptions(String input) { 24 | return GENERAL.getResult(input); 25 | } 26 | 27 | public void clearArguments() { 28 | GENERAL.clearAllArguments(); 29 | } 30 | 31 | public void buildArguments(String input) { 32 | GENERAL.buildArgumentStacks(input); 33 | } 34 | 35 | public List getAllInputs() { 36 | return GENERAL.getInputs(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/communication/client/impl/BungeeClientInfo.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.communication.client.impl; 2 | 3 | import de.rayzs.pat.api.communication.client.ClientInfo; 4 | import de.rayzs.pat.api.communication.Client; 5 | import de.rayzs.pat.plugin.BungeeLoader; 6 | import de.rayzs.pat.plugin.logger.Logger; 7 | import net.md_5.bungee.api.ProxyServer; 8 | 9 | public class BungeeClientInfo extends ClientInfo { 10 | 11 | public BungeeClientInfo(String serverId) { 12 | super(serverId); 13 | } 14 | 15 | public BungeeClientInfo(String serverId, String name) { 16 | super(serverId, name); 17 | } 18 | 19 | @Override 20 | public void sendBytes(byte[] bytes) { 21 | try { 22 | ProxyServer server = BungeeLoader.getPlugin().getProxy(); 23 | 24 | server.getServers().entrySet().stream().filter(entry -> 25 | entry.getKey().equalsIgnoreCase(getName()) 26 | ).forEach(entry -> 27 | entry.getValue().sendData(Client.CHANNEL_NAME, bytes) 28 | ); 29 | 30 | } catch (NoClassDefFoundError exception) { 31 | Logger.warning("Failed to send data to backend servers! :c"); 32 | } 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/messages/ExtractSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.messages; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import de.rayzs.pat.utils.Reflection; 5 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 6 | import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper; 7 | 8 | public class ExtractSection extends ConfigStorage { 9 | 10 | public MultipleMessagesHelper MESSAGE; 11 | 12 | public ExtractSection() { 13 | super("extract"); 14 | } 15 | 16 | public String USAGE, PLUGIN_NOT_FOUND, SUCCESS; 17 | 18 | @Override 19 | public void load() { 20 | super.load(); 21 | 22 | if (Reflection.isProxyServer()) { 23 | return; 24 | } 25 | 26 | USAGE = new ConfigSectionHelper(this, "usage", "&7Usage: &f/pat extract [plugin] &7or &f ").getOrSet(); 27 | PLUGIN_NOT_FOUND = new ConfigSectionHelper(this, "plugin-not-found", "&cPlugin %plugin% not found!").getOrSet(); 28 | SUCCESS = new ConfigSectionHelper(this, "success", "&aSuccessfully extracted &e%amount% &anew commands from %plugin%!").getOrSet(); 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/communication/BackendUpdater.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.communication; 2 | 3 | import de.rayzs.pat.api.storage.Storage; 4 | import de.rayzs.pat.utils.scheduler.*; 5 | import org.bukkit.Bukkit; 6 | 7 | public class BackendUpdater { 8 | 9 | private static PATSchedulerTask TASK; 10 | 11 | public static void handle() { 12 | if(isRunning() || !shouldRun() || !Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) return; 13 | start(); 14 | } 15 | 16 | public static boolean isRunning() { 17 | return TASK != null && TASK.isActive(); 18 | } 19 | 20 | public static void start() { 21 | if(isRunning()) return; 22 | 23 | TASK = PATScheduler.createScheduler(() -> { 24 | if (shouldRun()) 25 | Communicator.sendRequest(); 26 | else 27 | stop(); 28 | }, 5, 20); 29 | } 30 | 31 | public static void stop() { 32 | if(TASK == null || !TASK.isActive()) return; 33 | TASK.cancelTask(); 34 | TASK = null; 35 | } 36 | 37 | private static boolean shouldRun() { 38 | int onlinePlayerSize = Bukkit.getOnlinePlayers().size(); 39 | return onlinePlayerSize >= 1; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/NumberUtils.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils; 2 | 3 | public class NumberUtils { 4 | 5 | private static final char[] EXCEPTIONS = {'.', ',', 'k', 'm', 'b'}; 6 | 7 | public static boolean isBetween(int n, int l, int r) { 8 | int min = Math.min(l, r); 9 | int max = Math.max(l, r); 10 | 11 | return n >= min && n <= max; 12 | } 13 | 14 | public static boolean isDigit(String str) { 15 | if (str == null || str.isBlank()) 16 | return false; 17 | 18 | int length = str.length(); 19 | 20 | for (int i = 0; i < length; i++) { 21 | char c = str.charAt(i); 22 | 23 | if (isExceptionalDigit(c)) 24 | continue; 25 | 26 | if (!Character.isDigit(c)) 27 | return false; 28 | } 29 | return true; 30 | } 31 | 32 | private static boolean isExceptionalDigit(char c) { 33 | for (char q : EXCEPTIONS) { 34 | if (c == q) { 35 | return true; 36 | } 37 | 38 | if (Character.isAlphabetic(c) && c == Character.toUpperCase(q)) { 39 | return true; 40 | } 41 | } 42 | 43 | return false; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/messages/StatsSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.messages; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import de.rayzs.pat.utils.configuration.helper.*; 5 | import de.rayzs.pat.utils.Reflection; 6 | 7 | import java.util.Arrays; 8 | 9 | public class StatsSection extends ConfigStorage { 10 | 11 | public String NO_SERVER, SPLITTER, SERVER; 12 | public MultipleMessagesHelper STATISTIC; 13 | 14 | public StatsSection() { 15 | super("stats"); 16 | } 17 | 18 | @Override 19 | public void load() { 20 | super.load(); 21 | if(!Reflection.isProxyServer()) return; 22 | NO_SERVER = new ConfigSectionHelper(this, "no-server", "&cNone!").getOrSet(); 23 | SPLITTER = new ConfigSectionHelper(this, "message.splitter", "&7, ").getOrSet(); 24 | SERVER = new ConfigSectionHelper(this, "message.server", "&f%servername% &8(%updated%)").getOrSet(); 25 | STATISTIC = new MultipleMessagesHelper(this, "message.statistic", Arrays.asList( 26 | "&7Last sync sent to &f%server_count% &7servers. &8&o(%last_sync_time% ago)", 27 | "&7Sent to servers: &f%servers%" 28 | )); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/StorageTemplate.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage; 2 | 3 | import de.rayzs.pat.utils.configuration.*; 4 | import java.io.Serializable; 5 | 6 | public abstract class StorageTemplate implements Serializable { 7 | 8 | private final String navigatePath; 9 | private final ConfigurationBuilder configuration; 10 | 11 | public StorageTemplate(ConfigurationBuilder configuration, String navigatePath) { 12 | this.navigatePath = navigatePath; 13 | this.configuration = configuration; 14 | this.load(); 15 | } 16 | 17 | public StorageTemplate setIfEmpty(String target, Object obj) { 18 | configuration.getOrSet(target, obj); 19 | return this; 20 | } 21 | 22 | public StorageTemplate set(String target, Object obj) { 23 | configuration.setAndSave(target, obj); 24 | return this; 25 | } 26 | 27 | public Object get(String target, Object obj) { 28 | configuration.getOrSet(target, obj); 29 | return this; 30 | } 31 | 32 | public ConfigurationBuilder getConfig() { 33 | return configuration; 34 | } 35 | public String getNavigatePath() { return navigatePath; } 36 | 37 | public abstract void save(); 38 | public abstract void load(); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/plugin/converter/StorageConverter.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.plugin.converter; 2 | 3 | import de.rayzs.pat.plugin.converter.converters.*; 4 | import org.jetbrains.annotations.NotNull; 5 | import java.util.*; 6 | 7 | public class StorageConverter { 8 | 9 | private StorageConverter() {} 10 | 11 | private static final Map converters = new HashMap<>(); 12 | 13 | 14 | public static void initialize() { 15 | 16 | if (!converters.isEmpty()) { 17 | return; 18 | } 19 | 20 | registerConverter(new AdvancedPlHideConverter()); 21 | registerConverter(new CommandWhitelistConverter()); 22 | registerConverter(new PluginHiderPlus()); 23 | registerConverter(new PlHideFree()); 24 | registerConverter(new PlHidePro()); 25 | } 26 | 27 | public static Set getConverters() { 28 | return converters.keySet(); 29 | } 30 | 31 | public static Converter getConverter(@NotNull String name) { 32 | return converters.get(name); 33 | } 34 | 35 | public static void registerConverter(@NotNull Converter converter) { 36 | if (!converter.exists()) return; 37 | 38 | converters.putIfAbsent(converter.getPluginName(), converter); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/plugin/process/impl/local/system/ReloadCommand.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.plugin.process.impl.local.system; 2 | 3 | import de.rayzs.pat.api.communication.BackendUpdater; 4 | import de.rayzs.pat.api.brand.CustomServerBrand; 5 | import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist; 6 | import de.rayzs.pat.utils.configuration.updater.ConfigUpdater; 7 | import de.rayzs.pat.utils.group.GroupManager; 8 | import de.rayzs.pat.api.command.ProCommand; 9 | import de.rayzs.pat.api.storage.Storage; 10 | import de.rayzs.pat.utils.sender.CommandSender; 11 | import de.rayzs.pat.utils.Reflection; 12 | import java.util.List; 13 | 14 | public class ReloadCommand extends ProCommand { 15 | 16 | public ReloadCommand() { 17 | super( 18 | "reload", 19 | "rl" 20 | ); 21 | } 22 | 23 | @Override 24 | public boolean execute(CommandSender sender, String[] args) { 25 | sender.sendMessage(Storage.ConfigSections.Messages.RELOAD.LOADING); 26 | Storage.reload(); 27 | sender.sendMessage(Storage.ConfigSections.Messages.RELOAD.DONE); 28 | return true; 29 | } 30 | 31 | @Override 32 | public List tabComplete(CommandSender sender, String[] args) { 33 | return null; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/settings/PatchExploitSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.settings; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import de.rayzs.pat.utils.configuration.helper.*; 5 | import de.rayzs.pat.utils.StringUtils; 6 | import java.util.Collections; 7 | 8 | public class PatchExploitSection extends ConfigStorage { 9 | 10 | public boolean ENABLED; 11 | public ConfigSectionHelper ALERT_MESSAGE, KICK_MESSAGE; 12 | 13 | public PatchExploitSection() { 14 | super("patch-exploits"); 15 | } 16 | 17 | @Override 18 | public void load() { 19 | super.load(); 20 | ENABLED = new ConfigSectionHelper(this, "enabled", true).getOrSet(); 21 | ALERT_MESSAGE = new ConfigSectionHelper<>(this, "alert-message", "%prefix% &4%player% &ctried to crash/lag the server."); 22 | KICK_MESSAGE = new ConfigSectionHelper(this, "kick-message", "&cFailed to read packet! Please reconnect."); 23 | } 24 | 25 | public boolean isMalicious(String text) { 26 | if(!ENABLED) return false; 27 | 28 | return text.length() > 256 29 | || text.contains("nbt") 30 | && (StringUtils.countMatches('[', text) > 15 || StringUtils.countMatches('{', text) > 25); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/brand/CustomServerBrand.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.brand; 2 | 3 | import de.rayzs.pat.api.brand.impl.*; 4 | import de.rayzs.pat.api.storage.Storage; 5 | import de.rayzs.pat.utils.PacketUtils; 6 | import de.rayzs.pat.utils.Reflection; 7 | 8 | public class CustomServerBrand { 9 | 10 | public static final String CHANNEL_NAME = Reflection.getMinor() < 13 ? "MC|Brand" : "minecraft:brand"; 11 | private static final ServerBrand SERVER_BRAND = Reflection.isVelocityServer() ? new VelocityServerBrand() : Reflection.isProxyServer() ? new BungeeServerBrand() : new BukkitServerBrand(); 12 | 13 | public static void initialize() { refreshTask(); } 14 | public static void refreshTask() { SERVER_BRAND.initializeTask(); } 15 | public static void preparePlayer(Object playerObj) { SERVER_BRAND.preparePlayer(playerObj); } 16 | public static void sendBrandToPlayer(Object playerObj) { SERVER_BRAND.send(playerObj); } 17 | 18 | public static PacketUtils.BrandManipulate createBrandPacket(Object playerObj) { return SERVER_BRAND.createPacket(playerObj); } 19 | public static boolean isEnabled() { return Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED; } 20 | 21 | public static boolean isBrandTag(String tag) { 22 | return tag.equals("MC|Brand") || tag.equals("minecraft:brand"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/message/replacer/PlaceholderReplacer.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils.message.replacer; 2 | 3 | import de.rayzs.pat.utils.message.replacer.impl.*; 4 | import de.rayzs.pat.api.storage.Storage; 5 | import java.util.function.Consumer; 6 | 7 | public class PlaceholderReplacer { 8 | 9 | private static BukkitPlaceholderReplacer BUKKIT_PLACEHOLDER_REPLACER = null; 10 | private static ProxyPlaceholderReplacer PROXY_PLACEHOLDER_REPLACER = null; 11 | 12 | public static String replace(Object playerObj, String text) { 13 | if (!Storage.USE_PLACEHOLDERAPI) 14 | return text; 15 | 16 | if (!text.contains("%")) 17 | return text; 18 | 19 | if (BUKKIT_PLACEHOLDER_REPLACER == null) 20 | BUKKIT_PLACEHOLDER_REPLACER = new BukkitPlaceholderReplacer(); 21 | 22 | return BUKKIT_PLACEHOLDER_REPLACER.process(playerObj, text); 23 | } 24 | 25 | public static boolean process(Object playerObj, String text, Consumer consumer) { 26 | if (!Storage.USE_PAPIPROXYBRIDGE) 27 | return false; 28 | 29 | if (!text.contains("%")) return false; 30 | 31 | if (PROXY_PLACEHOLDER_REPLACER == null) 32 | PROXY_PLACEHOLDER_REPLACER = new ProxyPlaceholderReplacer(); 33 | 34 | return PROXY_PLACEHOLDER_REPLACER.process(playerObj, text, consumer); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/utils/sender/CommandSenderAbstract.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.utils.sender; 2 | 3 | import de.rayzs.pat.utils.ExpireCache; 4 | import de.rayzs.pat.utils.group.Group; 5 | import de.rayzs.pat.utils.group.GroupManager; 6 | 7 | import java.util.List; 8 | import java.util.concurrent.TimeUnit; 9 | 10 | public abstract class CommandSenderAbstract implements CommandSender { 11 | 12 | private static final byte KEY = (byte) 0; 13 | 14 | private final ExpireCache> groups = new ExpireCache<>(1, TimeUnit.HOURS); 15 | private Object senderObj; 16 | 17 | public CommandSenderAbstract(Object senderObj) { 18 | this.senderObj = senderObj; 19 | } 20 | 21 | @Override 22 | public void updateSenderObject(Object senderObj) { 23 | this.senderObj = senderObj; 24 | } 25 | 26 | @Override 27 | public Object getSenderObject() { 28 | return senderObj; 29 | } 30 | 31 | @Override 32 | public List getGroups() { 33 | final List groupList = groups.get(KEY); 34 | 35 | if (groupList == null) { 36 | return groups.putAndGet(KEY, GroupManager.getPlayerGroups(getSenderObject())); 37 | } 38 | 39 | return groupList; 40 | } 41 | 42 | protected void setGroups(List groups) { 43 | this.groups.putIgnoreIfContains(KEY, groups); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/settings/BlockNamespaceCommandsSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.settings; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import de.rayzs.pat.utils.StringUtils; 5 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; 6 | import de.rayzs.pat.utils.permission.PermissionUtil; 7 | 8 | public class BlockNamespaceCommandsSection extends ConfigStorage { 9 | 10 | public boolean ENABLED, ALWAYS_BLOCK_COMMAND; 11 | 12 | public BlockNamespaceCommandsSection() { 13 | super("block-namespace-commands"); 14 | } 15 | 16 | @Override 17 | public void load() { 18 | super.load(); 19 | ENABLED = new ConfigSectionHelper(this, "enabled", true).getOrSet(); 20 | ALWAYS_BLOCK_COMMAND = new ConfigSectionHelper(this, "always-block-command", true).getOrSet(); 21 | } 22 | 23 | public boolean doesAlwaysBlock(String command) { 24 | return ALWAYS_BLOCK_COMMAND && isCommand(command); 25 | } 26 | 27 | public boolean isCommand(String command) { 28 | if (!ENABLED) { 29 | return false; 30 | } 31 | 32 | return StringUtils.getFirstArg(command).contains(":"); 33 | } 34 | 35 | public boolean doesBypass(Object targetObj) { 36 | return !ENABLED || PermissionUtil.hasPermission(targetObj, "namespace"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/blacklist/BlacklistCreator.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.blacklist; 2 | 3 | import de.rayzs.pat.api.storage.blacklist.impl.*; 4 | import de.rayzs.pat.api.storage.Storage; 5 | 6 | public class BlacklistCreator { 7 | 8 | public static GeneralBlacklist createGeneralBlacklist() { 9 | return new GeneralBlacklist("commands"); 10 | } 11 | 12 | public static GeneralBlacklist createGeneralBlacklist(String server) { 13 | return new GeneralBlacklist("servers." + server + ".commands"); 14 | } 15 | 16 | public static GroupBlacklist createGroupBlacklist(String group) { 17 | return new GroupBlacklist(group, "commands"); 18 | } 19 | 20 | public static GroupBlacklist createGroupBlacklist(String group, String server, boolean ignoreExist) { 21 | if (!exist(group, server) && !ignoreExist) 22 | return null; 23 | 24 | return new GroupBlacklist(group, "servers." + server + ".commands"); 25 | } 26 | 27 | public static boolean exist(String server) { 28 | Object obj = Storage.Blacklist.getBlacklist().getConfig().get("global.servers." + server); 29 | return obj != null; 30 | } 31 | 32 | public static boolean exist(String group, String server) { 33 | Object obj = Storage.Blacklist.getBlacklist().getConfig().get("groups." + group + ".servers." + server); 34 | return obj != null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/plugin/process/impl/local/modify/list/ListGroupsCommand.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.plugin.process.impl.local.modify.list; 2 | 3 | import de.rayzs.pat.utils.group.GroupManager; 4 | import de.rayzs.pat.api.command.ProCommand; 5 | import de.rayzs.pat.api.storage.Storage; 6 | import de.rayzs.pat.utils.*; 7 | import de.rayzs.pat.utils.sender.CommandSender; 8 | 9 | import java.util.List; 10 | 11 | public class ListGroupsCommand extends ProCommand { 12 | 13 | public ListGroupsCommand() { 14 | super( 15 | "listgroups", 16 | "lg" 17 | ); 18 | } 19 | 20 | @Override 21 | public boolean execute(CommandSender sender, String[] args) { 22 | String groupsListMessage = StringUtils.getStringList( 23 | GroupManager.getGroupNames(), 24 | Storage.ConfigSections.Messages.GROUP.LIST_SPLITTER 25 | ); 26 | 27 | String message = Storage.ConfigSections.Messages.GROUP.LIST_GROUP_MESSAGE; 28 | message = StringUtils.replace(message, 29 | "%size%", String.valueOf(GroupManager.getGroups().size()), 30 | "%groups%", groupsListMessage 31 | ); 32 | 33 | sender.sendMessage(message); 34 | return true; 35 | } 36 | 37 | @Override 38 | public List tabComplete(CommandSender sender, String[] args) { 39 | return null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/settings/CustomBrandSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.settings; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import de.rayzs.pat.utils.configuration.helper.*; 5 | import java.util.Arrays; 6 | 7 | public class CustomBrandSection extends ConfigStorage { 8 | 9 | public boolean ENABLED; 10 | public int REPEAT_DELAY; 11 | public MultipleMessagesHelper BRANDS; 12 | 13 | public CustomBrandSection() { 14 | super("custom-server-brand"); 15 | } 16 | 17 | @Override 18 | public void load() { 19 | super.load(); 20 | ENABLED = new ConfigSectionHelper(this, "enabled", false).getOrSet(); 21 | REPEAT_DELAY = new ConfigSectionHelper(this, "repeat-delay", 3).getOrSet(); 22 | BRANDS = new MultipleMessagesHelper(this, "brands", Arrays.asList( 23 | "&f&lP&froAntiTab |", 24 | "&fP&lr&foAntiTab /", 25 | "&fPr&lo&fAntiTab -", 26 | "&fPro&lA&fntiTab |", 27 | "&fProA&ln&ftiTab \\", 28 | "&fProAn<&fiTab |", 29 | "&fProAnt&li&fTab /", 30 | "&fProAnti&lT&fab -", 31 | "&fProAnti&lT&fab \\", 32 | "&fProAntiT&la&fb |", 33 | "&fProAntiTa&lb&f /", 34 | "&fProAntiTab -", 35 | "&fProAntiTab \\" 36 | )); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/storages/IgnoredServersStorage.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.storages; 2 | 3 | import de.rayzs.pat.utils.Reflection; 4 | import de.rayzs.pat.api.storage.*; 5 | import java.util.*; 6 | 7 | public class IgnoredServersStorage extends StorageTemplate { 8 | 9 | private List servers = new ArrayList<>(); 10 | 11 | public IgnoredServersStorage(String navigatePath) { 12 | super(Storage.Files.STORAGE, navigatePath); 13 | } 14 | 15 | public IgnoredServersStorage add(String server) { 16 | server = server.toLowerCase(); 17 | if(!servers.contains(server)) 18 | servers.add(server); 19 | return this; 20 | } 21 | 22 | public IgnoredServersStorage remove(String server) { 23 | server = server.toLowerCase(); 24 | servers.remove(server); 25 | return this; 26 | } 27 | 28 | public boolean isListed(String server) { 29 | if(servers.isEmpty()) return false; 30 | return Storage.isServer(server, servers); 31 | } 32 | 33 | public boolean isListEmpty() { 34 | return servers.isEmpty(); 35 | } 36 | 37 | @Override 38 | public void save() { getConfig().save(); } 39 | 40 | @Override 41 | public void load() { 42 | if(!Reflection.isProxyServer()) return; 43 | getConfig().reload(); 44 | servers = (ArrayList) getConfig().getOrSet(getNavigatePath(), servers); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/command/ProCommand.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.command; 2 | 3 | import de.rayzs.pat.utils.*; 4 | import de.rayzs.pat.utils.sender.CommandSender; 5 | 6 | import java.util.*; 7 | 8 | public abstract class ProCommand { 9 | 10 | private final String name; 11 | private final List aliases; 12 | 13 | protected boolean proxyOnly = false, serverCommand = false; 14 | 15 | public ProCommand(String name, String... aliases) { 16 | this.name = name.toLowerCase(); 17 | this.aliases = aliases != null && !aliases[0].isBlank() ? Arrays.asList(aliases) : new ArrayList<>(); 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public boolean isProxyOnly() { 25 | return proxyOnly; 26 | } 27 | 28 | public boolean isServerCommand() { 29 | return serverCommand; 30 | } 31 | 32 | public List getAliases() { 33 | return aliases; 34 | } 35 | 36 | public boolean isCommand(String label) { 37 | String commandName = StringUtils.getFirstArg(label); 38 | 39 | if (name.equalsIgnoreCase(commandName)) 40 | return true; 41 | 42 | return !aliases.isEmpty() && aliases.stream().anyMatch(commandName::equalsIgnoreCase); 43 | } 44 | 45 | public abstract boolean execute(CommandSender sender, String[] args); 46 | public abstract List tabComplete(CommandSender sender, String[] args); 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/api/storage/config/settings/UpdateSection.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.api.storage.config.settings; 2 | 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage; 4 | import de.rayzs.pat.utils.configuration.helper.*; 5 | import java.util.*; 6 | 7 | public class UpdateSection extends ConfigStorage { 8 | 9 | public boolean ENABLED, AUTO_UPDATE_CONFIG; 10 | public int PERIOD; 11 | public MultipleMessagesHelper OUTDATED, UPDATED; 12 | 13 | public UpdateSection() { 14 | super("updater"); 15 | } 16 | 17 | @Override 18 | public void load() { 19 | super.load(); 20 | ENABLED = new ConfigSectionHelper(this, "enabled", true).getOrSet(); 21 | PERIOD = new ConfigSectionHelper(this, "period", 10000).getOrSet(); 22 | AUTO_UPDATE_CONFIG = new ConfigSectionHelper(this, "auto-update-config", true).getOrSet(); 23 | UPDATED = new MultipleMessagesHelper(this, "updated", Collections.singletonList("&aYou are using the newest version! ^^")); 24 | OUTDATED = new MultipleMessagesHelper(this, "outdated", Arrays.asList( 25 | "&8[&4ProAntiTab&8] &cThere is a new version available! (%newest_version%)", 26 | "&8[&4ProAntiTab&8] &cYou are still using the %current_version%.", 27 | "&8[&4ProAntiTab&8] &cGet the newest version here:", 28 | "&8[&4ProAntiTab&8] &ehttps://www.rayzs.de/products/proantitab/page")); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/de/rayzs/pat/plugin/PluginLoader.java: -------------------------------------------------------------------------------- 1 | package de.rayzs.pat.plugin; 2 | 3 | import de.rayzs.pat.utils.CommandsCache; 4 | 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.UUID; 8 | 9 | public interface PluginLoader { 10 | 11 | void handleReload(); 12 | boolean doesCommandExist(String command); 13 | 14 | HashMap getCommandsCacheMap(); 15 | 16 | void delayedPermissionsReload(); 17 | 18 | void updateCommandCache(); 19 | 20 | List getServerNames(); 21 | 22 | Object getConsoleSender(); 23 | 24 | Object getPlayerObjByName(String name); 25 | Object getPlayerObjByUUID(UUID uuid); 26 | 27 | UUID getUUIDByName(String playerName); 28 | String getNameByUUID(UUID uuid); 29 | 30 | String getPlayerServerName(UUID uuid); 31 | 32 | boolean isPlayerOnline(String playerName); 33 | boolean doesPlayerExist(String playerName); 34 | 35 | List getOnlinePlayerNames(String server); 36 | 37 | List getPlayerIdsByServer(String server); 38 | List getPlayerIds(); 39 | 40 | List getPlayerNames(); 41 | List getOnlinePlayerNames(); 42 | List getOfflinePlayerNames(); 43 | 44 | List getPluginCommands(String pluginName, boolean useColons); 45 | 46 | /** 47 | *
48 |      * %n = Plugin name
49 |      * %v = Plugin version
50 |      */
51 |     List getPluginNames(String format);
52 | }
53 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/api/communication/client/ClientInfo.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.api.communication.client;
 2 | 
 3 | import de.rayzs.pat.utils.TimeConverter;
 4 | 
 5 | public abstract class ClientInfo {
 6 | 
 7 |     private String id, name;
 8 | 
 9 |     private boolean sentFeedback = false;
10 |     private long syncTime = System.currentTimeMillis();
11 | 
12 |     public ClientInfo(String serverId) {
13 |         this.id = serverId;
14 |     }
15 | 
16 |     public ClientInfo(String serverId, String name) {
17 |         this.id = serverId;
18 |         this.name = name;
19 |     }
20 | 
21 |     public abstract void sendBytes(byte[] bytes);
22 | 
23 |     public void setName(String name) {
24 |         this.name = name;
25 |     }
26 | 
27 |     public void setId(String serverId) {
28 |         this.id = serverId;
29 |     }
30 | 
31 |     public String getName() {
32 |         return name;
33 |     }
34 | 
35 |     public boolean compareId(String id) {
36 |         return this.id.equals(id);
37 |     }
38 | 
39 |     public void syncTime() {
40 |         syncTime = System.currentTimeMillis();
41 |     }
42 | 
43 |     public String getSyncTime() {
44 |         return TimeConverter.calcAndGetTime(syncTime);
45 |     }
46 | 
47 |     public void setFeedback(boolean state) {
48 |         this.sentFeedback = state;
49 |     }
50 | 
51 |     public boolean hasSentFeedback() {
52 |         return sentFeedback;
53 |     }
54 | 
55 |     public String getId() {
56 |         return id;
57 |     }
58 | }
59 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/converter/converters/PluginHiderPlus.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.converter.converters;
 2 | 
 3 | import de.rayzs.pat.api.storage.Storage;
 4 | import de.rayzs.pat.plugin.converter.Converter;
 5 | import de.rayzs.pat.utils.sender.CommandSender;
 6 | 
 7 | import java.util.ArrayList;
 8 | import java.util.List;
 9 | 
10 | public class PluginHiderPlus extends Converter {
11 | 
12 |     public PluginHiderPlus() {
13 |         super("PluginHider+", "PluginHiderPlus", "config");
14 |     }
15 | 
16 |     @Override
17 |     public void apply(CommandSender sender) {
18 | 
19 |         boolean blacklist = (boolean) config.get("reverse-suggestionsWhitelist");
20 |         Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.getConfig().setAndSave("turn-blacklist-to-whitelist", !blacklist);
21 | 
22 |         List commands = (ArrayList) config.get("suggestionsWhitelist");
23 | 
24 |         if (blacklist) {
25 |             List blockedCommands = (ArrayList) config.get("blockedCommands.everyone.commands");
26 |             commands.addAll(blockedCommands);
27 |         }
28 | 
29 |         applyStorage(Storage.Blacklist.getBlacklist(), commands);
30 |         sender.sendMessage("&e&lNotice: &7Since PluginHider+ both blocks certain commands and whitelist a few, the conversion into PAT's storage.yml format won't be accurate. Only whitelisted commands have been added, and blocked commands for everyone if the plugin was used in blacklist mode.");
31 |     }
32 | }
33 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/hooks/PlaceholderHook.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.hooks;
 2 | 
 3 | import me.clip.placeholderapi.expansion.PlaceholderExpansion;
 4 | import de.rayzs.pat.plugin.logger.Logger;
 5 | import de.rayzs.pat.api.storage.Storage;
 6 | import de.rayzs.pat.plugin.BukkitLoader;
 7 | import org.jetbrains.annotations.*;
 8 | import org.bukkit.entity.Player;
 9 | 
10 | public class PlaceholderHook extends PlaceholderExpansion {
11 | 
12 |     public PlaceholderHook() {
13 |         Storage.USE_PLACEHOLDERAPI = true;
14 |         Storage.ConfigSections.Placeholders.initialize();
15 |         Logger.info("Successfully hooked into PlaceholderAPI!");
16 |     }
17 | 
18 |     @Override
19 |     public @NotNull String getIdentifier() {
20 |         return "pat";
21 |     }
22 | 
23 |     @Override
24 |     public boolean persist() {
25 |         return true;
26 |     }
27 | 
28 |     @Override
29 |     public boolean canRegister() {
30 |         return true;
31 |     }
32 | 
33 |     @Override
34 |     public @NotNull String getAuthor() {
35 |         return BukkitLoader.getPlugin().getDescription().getAuthors().get(0);
36 |     }
37 | 
38 |     @Override
39 |     public @NotNull String getVersion() {
40 |         return BukkitLoader.getPlugin().getDescription().getVersion();
41 |     }
42 | 
43 |     @Override
44 |     public @Nullable String onPlaceholderRequest(Player player, @NotNull String request) {
45 |         return Storage.ConfigSections.Placeholders.findAndReplace(player, request.toLowerCase());
46 |     }
47 | }
48 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/process/impl/local/info/PermsCommand.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.process.impl.local.info;
 2 | 
 3 | import de.rayzs.pat.utils.permission.PermissionUtil;
 4 | import de.rayzs.pat.api.command.ProCommand;
 5 | import de.rayzs.pat.api.storage.Storage;
 6 | import de.rayzs.pat.utils.sender.CommandSender;
 7 | import java.util.*;
 8 | 
 9 | public class PermsCommand extends ProCommand {
10 | 
11 |     public PermsCommand() {
12 |         super(
13 |                 "perms",
14 |                 ""
15 |         );
16 |     }
17 | 
18 |     @Override
19 |     public boolean execute(CommandSender sender, String[] args) {
20 |         if (args.length == 0)
21 |             return false;
22 | 
23 |         String name = args[0];
24 |         UUID uuid = Storage.getLoader().getUUIDByName(name);
25 | 
26 |         boolean online = uuid != null;
27 | 
28 |         if (online) {
29 |             name = Storage.getLoader().getNameByUUID(uuid);
30 |         }
31 | 
32 |         sender.sendMessage((online
33 |                         ? Storage.ConfigSections.Messages.PERMS_CHECK.MESSAGE.replace("%permissions%", PermissionUtil.getPermissionsAsString(uuid))
34 |                         : Storage.ConfigSections.Messages.PERMS_CHECK.PLAYER_NOT_ONLINE
35 |                 ).replace("%player%", name)
36 |         );
37 | 
38 |         return true;
39 |     }
40 | 
41 |     @Override
42 |     public List tabComplete(CommandSender sender, String[] args) {
43 |         return args.length < 2 ? Storage.getLoader().getPlayerNames() : null;
44 |     }
45 | }
46 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/converter/Converter.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.converter;
 2 | 
 3 | import de.rayzs.pat.api.storage.storages.BlacklistStorage;
 4 | import de.rayzs.pat.utils.configuration.ConfigurationBuilder;
 5 | import de.rayzs.pat.utils.configuration.Configurator;
 6 | import de.rayzs.pat.utils.sender.CommandSender;
 7 | 
 8 | import java.io.File;
 9 | import java.util.List;
10 | 
11 | public abstract class Converter {
12 | 
13 |     private final String pluginName, fileName, folderPath;
14 |     protected final ConfigurationBuilder config;
15 | 
16 |     public Converter(String pluginName, String folderName, String fileName) {
17 |         this.pluginName = pluginName;
18 |         this.fileName = fileName;
19 |         this.folderPath = "./plugins/" + folderName;
20 |         this.config = exists() ? Configurator.get(fileName, folderPath) : null;
21 |     }
22 | 
23 |     public String getPluginName() {
24 |         return pluginName;
25 |     }
26 | 
27 |     public boolean exists() {
28 |         return new File(folderPath, fileName + ".yml").exists();
29 |     }
30 | 
31 |     protected void applyStorage(BlacklistStorage storage, List commands) {
32 |         for (String command : commands) {
33 |             boolean exist = command.contains(" ")
34 |                     ? storage.getCommands().contains(command)
35 |                     : storage.isListed(command);
36 | 
37 |             if (exist) continue;
38 | 
39 |             storage.add(command);
40 |         }
41 | 
42 |         storage.save();
43 |     }
44 | 
45 |     public abstract void apply(CommandSender sender);
46 | }
47 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/logger/impl/BukkitLogger.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.logger.impl;
 2 | 
 3 | import de.rayzs.pat.utils.message.MessageTranslator;
 4 | import de.rayzs.pat.plugin.BukkitLoader;
 5 | import de.rayzs.pat.plugin.logger.*;
 6 | import org.bukkit.Bukkit;
 7 | import java.util.*;
 8 | 
 9 | public class BukkitLogger implements LoggerTemplate {
10 | 
11 |     private final java.util.logging.Logger logger = BukkitLoader.getPluginLogger();
12 | 
13 |     @Override
14 |     public void info(List messages) {
15 |         messages.forEach(this::info);
16 |     }
17 | 
18 |     @Override
19 |     public void warn(List messages) {
20 |         messages.forEach(this::warn);
21 |     }
22 | 
23 |     @Override
24 |     public void send(LoggerPriority priority, List messages) {
25 |         messages.forEach(message -> send(priority, message));
26 |     }
27 | 
28 |     @Override
29 |     public void info(String message) {
30 |         send(LoggerPriority.INFO, message);
31 |     }
32 | 
33 |     @Override
34 |     public void warn(String message) {
35 |         send(LoggerPriority.WARNING, message);
36 |     }
37 | 
38 |     @Override
39 |     public void send(LoggerPriority priority, String message) {
40 |         message = MessageTranslator.replaceMessage(message);
41 | 
42 |         if (message.contains("§")) {
43 |             MessageTranslator.send(Bukkit.getServer().getConsoleSender(), message);
44 |             return;
45 |         }
46 | 
47 |         switch (priority) {
48 |             case INFO -> logger.info(message);
49 |             case WARNING -> logger.warning(message);
50 |         }
51 |     }
52 | }


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/logger/impl/VelocityLogger.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.logger.impl;
 2 | 
 3 | import de.rayzs.pat.utils.message.MessageTranslator;
 4 | import de.rayzs.pat.plugin.VelocityLoader;
 5 | import de.rayzs.pat.plugin.logger.*;
 6 | import org.slf4j.Logger;
 7 | import java.util.*;
 8 | 
 9 | public class VelocityLogger implements LoggerTemplate {
10 | 
11 |     private final Logger logger = VelocityLoader.getPluginLogger();
12 | 
13 |     @Override
14 |     public void info(List messages) {
15 |         messages.forEach(this::info);
16 |     }
17 | 
18 |     @Override
19 |     public void warn(List messages) {
20 |         messages.forEach(this::warn);
21 |     }
22 | 
23 |     @Override
24 |     public void send(LoggerPriority priority, List messages) {
25 |         messages.forEach(message -> send(priority, message));
26 |     }
27 | 
28 |     @Override
29 |     public void info(String message) {
30 |         send(LoggerPriority.INFO, message);
31 |     }
32 | 
33 |     @Override
34 |     public void warn(String message) {
35 |         send(LoggerPriority.WARNING, message);
36 |     }
37 | 
38 |     @Override
39 |     public void send(LoggerPriority priority, String message) {
40 |         message = MessageTranslator.replaceMessage(message);
41 | 
42 |         if (message.contains("§")) {
43 |             MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), message);
44 |             return;
45 |         }
46 | 
47 |         switch (priority) {
48 |             case INFO -> logger.info(message);
49 |             case WARNING -> logger.warn(message);
50 |         }
51 |     }
52 | }


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/api/storage/config/messages/InfoSection.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.api.storage.config.messages;
 2 | 
 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage;
 4 | import de.rayzs.pat.utils.configuration.helper.*;
 5 | import java.util.Arrays;
 6 | 
 7 | public class InfoSection extends ConfigStorage {
 8 | 
 9 |     public String VERSION_OUTDATED, VERSION_UPDATED, SYNC_TIME, SYNC_DISABLED;
10 |     public MultipleMessagesHelper MESSAGE;
11 | 
12 |     public InfoSection() {
13 |         super("info");
14 |     }
15 | 
16 |     @Override
17 |     public void load() {
18 |         super.load();
19 | 
20 |         VERSION_UPDATED = new ConfigSectionHelper(this, "version.updated", "&aLatest version").getOrSet();
21 |         VERSION_OUTDATED = new ConfigSectionHelper(this, "version.outdated", "&cOutdated (%newest_version%)").getOrSet();
22 |         SYNC_TIME = new ConfigSectionHelper(this, "proxy-sync.time", "&e%time%").getOrSet();
23 |         SYNC_DISABLED = new ConfigSectionHelper(this, "proxy-sync.disabled", "&cDisabled").getOrSet();
24 | 
25 |         MESSAGE = new MultipleMessagesHelper(this, "message",
26 |                 Arrays.asList(
27 |                         "&7Necessary information about &fPAT&8:"
28 |                         , "&7  Version: &e%current_version%"
29 |                         , "&7  Status: %version_status%"
30 |                         , "&7  Last sync with proxy: &e%sync_time%"
31 |                         , "&7  Proxy sync-token: &e%token%"
32 |                         , "&7  Proxy-received server name: &e%sync_server_name%"
33 |                 )
34 |         );
35 |     }
36 | }
37 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/logger/impl/BungeeLogger.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.logger.impl;
 2 | 
 3 | import de.rayzs.pat.utils.message.MessageTranslator;
 4 | import de.rayzs.pat.plugin.BungeeLoader;
 5 | import net.md_5.bungee.api.ProxyServer;
 6 | import de.rayzs.pat.plugin.logger.*;
 7 | import java.util.*;
 8 | 
 9 | public class BungeeLogger implements LoggerTemplate {
10 | 
11 |     private final java.util.logging.Logger logger = BungeeLoader.getPluginLogger();
12 | 
13 |     @Override
14 |     public void info(List messages) {
15 |         messages.forEach(this::info);
16 |     }
17 | 
18 |     @Override
19 |     public void warn(List messages) {
20 |         messages.forEach(this::warn);
21 |     }
22 | 
23 |     @Override
24 |     public void send(LoggerPriority priority, List messages) {
25 |         messages.forEach(message -> send(priority, message));
26 |     }
27 | 
28 |     @Override
29 |     public void info(String message) {
30 |         send(LoggerPriority.INFO, message);
31 |     }
32 | 
33 |     @Override
34 |     public void warn(String message) {
35 |         send(LoggerPriority.WARNING, message);
36 |     }
37 | 
38 |     @Override
39 |     public void send(LoggerPriority priority, String message) {
40 |         message = MessageTranslator.replaceMessage(message);
41 | 
42 |         if (message.contains("§")) {
43 |             MessageTranslator.send(ProxyServer.getInstance().getConsole(), message);
44 |             return;
45 |         }
46 | 
47 |         switch (priority) {
48 |             case INFO -> logger.info(message);
49 |             case WARNING -> logger.warning(message);
50 |         }
51 |     }
52 | }


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/scheduler/impl/FoliaScheduler.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.scheduler.impl;
 2 | 
 3 | import de.rayzs.pat.utils.scheduler.PATSchedulerTask;
 4 | import io.papermc.paper.threadedregions.scheduler.*;
 5 | import de.rayzs.pat.plugin.BukkitLoader;
 6 | import org.bukkit.Bukkit;
 7 | 
 8 | public class FoliaScheduler implements PATSchedulerTask {
 9 | 
10 |     private static final GlobalRegionScheduler SCHEDULER = Bukkit.getGlobalRegionScheduler();
11 | 
12 |     private ScheduledTask task;
13 | 
14 |     @Override
15 |     public PATSchedulerTask getInstance(boolean async, Runnable runnable, long time, long period) {
16 |         this.task = SCHEDULER.runAtFixedRate(BukkitLoader.getPlugin(), __ -> runnable.run(), time, period);
17 |         return this;
18 |     }
19 | 
20 |     @Override
21 |     public PATSchedulerTask getInstance(boolean async, Runnable runnable, long time) {
22 |         this.task = SCHEDULER.runDelayed(BukkitLoader.getPlugin(), __ -> runnable.run(), time);
23 |         return this;
24 |     }
25 | 
26 |     @Override
27 |     public PATSchedulerTask getInstance(boolean async, Runnable runnable) {
28 |         this.task = SCHEDULER.run(BukkitLoader.getPlugin(), __ -> runnable.run());
29 |         return this;
30 |     }
31 | 
32 |     @Override
33 |     public boolean isActive() {
34 |         return !this.task.isCancelled();
35 |     }
36 | 
37 |     @Override
38 |     public void setTaskId(int taskId) {
39 |         if(taskId == -1 || taskId == -5) {
40 |             cancelTask();
41 |         }
42 |     }
43 | 
44 |     @Override
45 |     public void cancelTask() {
46 |         this.task.cancel();
47 |     }
48 | }
49 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/api/storage/blacklist/impl/GeneralBlacklist.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.api.storage.blacklist.impl;
 2 | 
 3 | import de.rayzs.pat.api.storage.storages.BlacklistStorage;
 4 | import de.rayzs.pat.api.storage.StorageTemplate;
 5 | import java.util.List;
 6 | 
 7 | public class GeneralBlacklist extends BlacklistStorage {
 8 | 
 9 |     public GeneralBlacklist(String navigatePath) { super("global." + navigatePath); }
10 | 
11 |     @Override
12 |     public List getCommands() {
13 |         return super.getCommands();
14 |     }
15 | 
16 |     @Override
17 |     public BlacklistStorage add(String command) {
18 |         return super.add(command);
19 |     }
20 | 
21 |     @Override
22 |     public BlacklistStorage remove(String command) {
23 |         return super.remove(command);
24 |     }
25 | 
26 |     @Override
27 |     public BlacklistStorage clear() {
28 |         return super.clear();
29 |     }
30 | 
31 |     @Override
32 |     public StorageTemplate setIfEmpty(String target, Object obj) {
33 |         return super.setIfEmpty(target, obj);
34 |     }
35 | 
36 |     @Override
37 |     public StorageTemplate set(String target, Object obj) {
38 |         return super.set(target, obj);
39 |     }
40 | 
41 |     @Override
42 |     public void setList(List commands) {
43 |         super.setList(commands);
44 |     }
45 | 
46 |     @Override
47 |     public Object get(String target, Object obj) {
48 |         return super.get(target, obj);
49 |     }
50 | 
51 |     @Override
52 |     public void save() {
53 |         super.save();
54 |     }
55 | 
56 |     @Override
57 |     public void load() {
58 |         super.load();
59 |     }
60 | }
61 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/api/storage/blacklist/impl/GroupBlacklist.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.api.storage.blacklist.impl;
 2 | 
 3 | import de.rayzs.pat.api.storage.storages.BlacklistStorage;
 4 | import de.rayzs.pat.api.storage.StorageTemplate;
 5 | import java.util.List;
 6 | 
 7 | public class GroupBlacklist extends BlacklistStorage {
 8 | 
 9 |     public GroupBlacklist(String group, String navigatePath) { super("groups." + group + "." + navigatePath); }
10 | 
11 |     @Override
12 |     public List getCommands() {
13 |         return super.getCommands();
14 |     }
15 | 
16 |     @Override
17 |     public BlacklistStorage add(String command) {
18 |         return super.add(command);
19 |     }
20 | 
21 |     @Override
22 |     public BlacklistStorage remove(String command) { return super.remove(command); }
23 | 
24 |     @Override
25 |     public BlacklistStorage clear() {
26 |         return super.clear();
27 |     }
28 | 
29 |     @Override
30 |     public StorageTemplate setIfEmpty(String target, Object obj) {
31 |         return super.setIfEmpty(target, obj);
32 |     }
33 | 
34 |     @Override
35 |     public StorageTemplate set(String target, Object obj) {
36 |         return super.set(target, obj);
37 |     }
38 | 
39 |     @Override
40 |     public void setList(List commands) {
41 |         super.setList(commands);
42 |     }
43 | 
44 |     @Override
45 |     public Object get(String target, Object obj) {
46 |         return super.get(target, obj);
47 |     }
48 | 
49 |     @Override
50 |     public void save() {
51 |         super.save();
52 |     }
53 | 
54 |     @Override
55 |     public void load() {
56 |         super.load();
57 |     }
58 | }
59 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/api/storage/config/settings/CustomPluginsSection.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.api.storage.config.settings;
 2 | 
 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage;
 4 | import de.rayzs.pat.utils.StringUtils;
 5 | import de.rayzs.pat.utils.configuration.helper.*;
 6 | import java.util.*;
 7 | 
 8 | public class CustomPluginsSection extends ConfigStorage {
 9 | 
10 |     public boolean ENABLED, ALWAYS_TAB_COMPLETABLE;
11 |     public MultipleMessagesHelper MESSAGE, COMMANDS;
12 | 
13 |     public CustomPluginsSection() {
14 |         super("custom-plugins");
15 |     }
16 | 
17 |     @Override
18 |     public void load() {
19 |         super.load();
20 |         ENABLED = new ConfigSectionHelper(this, "enabled", true).getOrSet();
21 |         ALWAYS_TAB_COMPLETABLE = new ConfigSectionHelper(this, "always-tab-completable", false).getOrSet();
22 |         COMMANDS = new MultipleMessagesHelper(this, "commands", Arrays.asList("pl", "plugins"));
23 |         MESSAGE = new MultipleMessagesHelper(this, "message", Collections.singletonList("&fPlugins (0):"));
24 |     }
25 | 
26 |     public boolean isTabCompletable(String command) {
27 |         if (!isCommand(command))
28 |             return false;
29 | 
30 |         return ALWAYS_TAB_COMPLETABLE;
31 |     }
32 | 
33 |     public boolean isCommand(String command) {
34 |         if(!ENABLED) return false;
35 |         command = StringUtils.getFirstArg(command);
36 | 
37 |         for (String currentCommand : COMMANDS.getLines()) {
38 |             if (currentCommand.equalsIgnoreCase(command))
39 |                 return true;
40 |         }
41 |         return false;
42 |     }
43 | }
44 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/api/storage/config/messages/ServerListSection.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.api.storage.config.messages;
 2 | 
 3 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
 4 | import de.rayzs.pat.api.storage.storages.ConfigStorage;
 5 | import de.rayzs.pat.utils.Reflection;
 6 | 
 7 | public class ServerListSection extends ConfigStorage {
 8 | 
 9 |     public String SERVER_DOES_NOT_EXIST, GROUP_DOES_NOT_EXIST;
10 |     public String LIST_SERVER_MESSAGE, LIST_SERVER_SPLITTER, LIST_GROUP_MESSAGE, LIST_GROUP_SPLITTER;
11 | 
12 |     public ServerListSection() {
13 |         super("server-list");
14 |     }
15 | 
16 |     @Override
17 |     public void load() {
18 |         super.load();
19 |         if(!Reflection.isProxyServer()) return;
20 | 
21 |         SERVER_DOES_NOT_EXIST = new ConfigSectionHelper(this, "server-not-found", "&cThe server %server% does not have any commands!").getOrSet();
22 |         GROUP_DOES_NOT_EXIST = new ConfigSectionHelper(this, "group-does-not-exist", "&cGroup %group% does not exist for %server%!").getOrSet();
23 | 
24 |         LIST_SERVER_MESSAGE = new ConfigSectionHelper(this, "list.server.message", "&7Listed commands of %server% (&f%size%&7)&8: &f%commands%").getOrSet();
25 |         LIST_SERVER_SPLITTER = new ConfigSectionHelper(this, "list.server.splitter", "&7, &f").getOrSet();
26 | 
27 |         LIST_GROUP_MESSAGE = new ConfigSectionHelper(this, "list.group.message", "&7Listed commands of %group% from %server% (&f%size%&7)&8: &f%commands%").getOrSet();
28 |         LIST_GROUP_SPLITTER = new ConfigSectionHelper(this, "list.group.splitter", "&7, &f").getOrSet();
29 |     }
30 | }
31 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/api/storage/storages/DisabledServersStorage.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.api.storage.storages;
 2 | 
 3 | import de.rayzs.pat.api.storage.Storage;
 4 | import de.rayzs.pat.api.storage.StorageTemplate;
 5 | import de.rayzs.pat.utils.Reflection;
 6 | 
 7 | import java.util.ArrayList;
 8 | import java.util.List;
 9 | 
10 | public class DisabledServersStorage extends StorageTemplate {
11 | 
12 |     private List servers = new ArrayList<>();
13 | 
14 |     public DisabledServersStorage() {
15 |         super(Storage.Files.STORAGE, "disabled-servers");
16 |     }
17 | 
18 |     public DisabledServersStorage add(String server) {
19 |         server = server.toLowerCase();
20 | 
21 |         if (!servers.contains(server)) {
22 |             servers.add(server);
23 |         }
24 | 
25 |         return this;
26 |     }
27 | 
28 |     public DisabledServersStorage remove(String server) {
29 |         server = server.toLowerCase();
30 |         servers.remove(server);
31 |         return this;
32 |     }
33 | 
34 |     public boolean isListed(String server) {
35 |         if (servers.isEmpty()) {
36 |             return false;
37 |         }
38 | 
39 |         return Storage.isServer(server, servers);
40 |     }
41 | 
42 |     public boolean isListEmpty() {
43 |         return servers.isEmpty();
44 |     }
45 | 
46 |     @Override
47 |     public void save() { getConfig().save(); }
48 | 
49 |     @Override
50 |     public void load() {
51 | 
52 |         if (!Reflection.isProxyServer()) {
53 |             return;
54 |         }
55 | 
56 |         getConfig().reload();
57 |         servers = (ArrayList) getConfig().getOrSet(getNavigatePath(), servers);
58 |    }
59 | }
60 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/TimeConverter.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils;
 2 | 
 3 | public class TimeConverter {
 4 | 
 5 |     private static final int SECOND = 1000, MINUTE = SECOND * 60, HOUR = MINUTE * 60, DAY = HOUR * 24, WEEK = DAY * 7;
 6 | 
 7 |     public static String calcAndGetTime(long time) {
 8 |         long upTime = (System.currentTimeMillis() - time);
 9 |         int weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0, ms = (int) upTime;
10 | 
11 |         while (ms >= SECOND) {
12 |             if (ms >= WEEK) {
13 |                 weeks++;
14 |                 ms -= WEEK;
15 |             } else if (ms >= DAY) {
16 |                 days++;
17 |                 ms -= DAY;
18 |             } else if (ms >= HOUR) {
19 |                 hours++;
20 |                 ms -= HOUR;
21 |             } else if (ms >= MINUTE) {
22 |                 minutes++;
23 |                 ms -= MINUTE;
24 |             } else {
25 |                 seconds++;
26 | 
27 |                 if (seconds >= 60) {
28 |                     seconds = 0;
29 |                     minutes++;
30 |                 }
31 | 
32 |                 ms = ms - SECOND;
33 |             }
34 |         }
35 | 
36 |         StringBuilder uptimeText = new StringBuilder();
37 |         if (weeks > 0) uptimeText.append(weeks + "w, ");
38 |         else if (days > 0) uptimeText.append(days + "d, ");
39 |         else if (hours > 0) uptimeText.append(hours + "h, ");
40 |         else if (minutes > 0) uptimeText.append(minutes + "m, ");
41 |         else if (seconds > 0) uptimeText.append(seconds + "s");
42 |         else uptimeText.append(ms + "ms");
43 | 
44 |         return uptimeText.toString();
45 |     }
46 | }
47 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/converter/converters/CommandWhitelistConverter.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.converter.converters;
 2 | 
 3 | import de.rayzs.pat.api.storage.Storage;
 4 | import de.rayzs.pat.api.storage.storages.BlacklistStorage;
 5 | import de.rayzs.pat.plugin.converter.Converter;
 6 | import de.rayzs.pat.utils.group.Group;
 7 | import de.rayzs.pat.utils.group.GroupManager;
 8 | import de.rayzs.pat.utils.sender.CommandSender;
 9 | 
10 | import java.util.ArrayList;
11 | import java.util.List;
12 | 
13 | public class CommandWhitelistConverter extends Converter {
14 | 
15 |     public CommandWhitelistConverter() {
16 |         super("CommandWhitelist", "CommandWhitelist", "config");
17 |     }
18 | 
19 |     @Override
20 |     public void apply(CommandSender sender) {
21 |         List groups = config.getKeys("groups", false).stream().toList();
22 | 
23 |         for (String groupName : groups) {
24 |             List commands = new ArrayList<>();
25 | 
26 |             final List l1 = (ArrayList) config.get("groups." + groupName + ".commands");
27 |             final List l2 = (ArrayList) config.get("groups." + groupName + ".subcommands");
28 | 
29 |             commands.addAll(l1);
30 |             commands.addAll(l2);
31 | 
32 |             BlacklistStorage storage;
33 | 
34 |             if (groupName.equalsIgnoreCase("default")) {
35 |                 storage = Storage.Blacklist.getBlacklist();
36 |             } else {
37 |                 Group group = GroupManager.registerAndGetGroup(groupName);
38 |                 storage = group.getGeneralGroupBlacklist();
39 |             }
40 | 
41 |             applyStorage(storage, commands);
42 |         }
43 |     }
44 | }
45 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/api/storage/config/settings/CustomVersionSection.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.api.storage.config.settings;
 2 | 
 3 | import de.rayzs.pat.api.storage.storages.ConfigStorage;
 4 | import de.rayzs.pat.utils.configuration.helper.*;
 5 | import de.rayzs.pat.utils.StringUtils;
 6 | import java.util.*;
 7 | 
 8 | public class CustomVersionSection extends ConfigStorage {
 9 | 
10 |     public boolean ENABLED, ALWAYS_TAB_COMPLETABLE;
11 |     public MultipleMessagesHelper MESSAGE, COMMANDS;
12 | 
13 |     public CustomVersionSection() {
14 |         super("custom-version");
15 |     }
16 | 
17 |     @Override
18 |     public void load() {
19 |         super.load();
20 |         ENABLED = new ConfigSectionHelper(this, "enabled", true).getOrSet();
21 |         ALWAYS_TAB_COMPLETABLE = new ConfigSectionHelper(this, "always-tab-completable", false).getOrSet();
22 |         COMMANDS = new MultipleMessagesHelper(this, "commands", Arrays.asList("icanhasbukkit", "about", "ver", "version"));
23 |         MESSAGE = new MultipleMessagesHelper(this, "message", Collections.singletonList("&fThis server is running CraftBukkit version git-NasaSpigot-294 (MC: X)"));
24 |     }
25 | 
26 |     public boolean isTabCompletable(String command) {
27 |         if (!isCommand(command))
28 |             return false;
29 | 
30 |         return ALWAYS_TAB_COMPLETABLE;
31 |     }
32 | 
33 |     public boolean isCommand(String command) {
34 |         if(!ENABLED) return false;
35 |         command = StringUtils.getFirstArg(command);
36 | 
37 |         for (String currentCommand : COMMANDS.getLines()) {
38 |             if (currentCommand.equalsIgnoreCase(command))
39 |                 return true;
40 |         }
41 |         return false;
42 |     }
43 | }
44 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/subargs/Arguments.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.subargs;
 2 | 
 3 | import de.rayzs.pat.api.storage.Storage;
 4 | 
 5 | import java.util.Collections;
 6 | import java.util.List;
 7 | import java.util.Map;
 8 | 
 9 | public class Arguments {
10 | 
11 |     public static Arguments ARGUMENTS = new Arguments();
12 | 
13 |     public ArgumentSource CHAT_ARGUMENTS = new ArgumentSource();
14 |     public ArgumentSource TAB_ARGUMENTS = new ArgumentSource();
15 | 
16 |     public List getResultChat(String input) {
17 |         return CHAT_ARGUMENTS.getGeneralArgument().getResult(input);
18 |     }
19 | 
20 |     public List getResultTab(String input) {
21 |         return TAB_ARGUMENTS.getGeneralArgument().getResult(input);
22 |     }
23 | 
24 |     public void buildArgumentStacks(String input) {
25 |         Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(input);
26 |         if (type != Storage.Blacklist.BlockType.NEGATE) {
27 |             input = Storage.Blacklist.BlockTypeFetcher.modify(input, type);
28 |         }
29 | 
30 |         switch (type) {
31 |             case TAB:
32 |                 TAB_ARGUMENTS.getGeneralArgument().buildArgumentStacks(input);
33 |                 break;
34 | 
35 |             case CHAT:
36 |                 CHAT_ARGUMENTS.getGeneralArgument().buildArgumentStacks(input);
37 |                 break;
38 | 
39 |             case BOTH: default:
40 |                 CHAT_ARGUMENTS.buildArguments(input);
41 |                 TAB_ARGUMENTS.buildArguments(input);
42 |                 break;
43 |         }
44 |     }
45 | 
46 |     public void clearArguments() {
47 |         CHAT_ARGUMENTS.clearArguments();
48 |         TAB_ARGUMENTS.clearArguments();
49 |     }
50 | }
51 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/process/impl/local/modify/ConvertCommand.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.process.impl.local.modify;
 2 | 
 3 | import de.rayzs.pat.api.command.ProCommand;
 4 | import de.rayzs.pat.api.storage.Storage;
 5 | import de.rayzs.pat.plugin.converter.Converter;
 6 | import de.rayzs.pat.plugin.converter.StorageConverter;
 7 | import de.rayzs.pat.utils.StringUtils;
 8 | import de.rayzs.pat.utils.sender.CommandSender;
 9 | 
10 | import java.util.List;
11 | 
12 | public class ConvertCommand extends ProCommand {
13 | 
14 |     public ConvertCommand() {
15 |         super(
16 |                 "convert",
17 |                 ""
18 |         );
19 |     }
20 | 
21 |     @Override
22 |     public boolean execute(CommandSender sender, String[] args) {
23 | 
24 |         if (args.length != 1)
25 |             return false;
26 | 
27 |         String converterName = args[0];
28 |         Converter converter = StorageConverter.getConverter(converterName);
29 |         if (converter == null) {
30 |             sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.CONVERT.INVALID_CONVERTER,
31 |                     "%converter%", converterName)
32 |             );
33 | 
34 |             return true;
35 |         }
36 | 
37 |         converterName = converter.getPluginName();
38 |         sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.CONVERT.SUCCESS,
39 |                 "%converter%", converterName)
40 |         );
41 | 
42 |         converter.apply(sender);
43 |         Storage.reload();
44 |         return true;
45 |     }
46 | 
47 |     @Override
48 |     public List tabComplete(CommandSender sender, String[] args) {
49 |         return StorageConverter.getConverters().stream().toList();
50 |     }
51 | }
52 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/api/communication/impl/BukkitClient.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.api.communication.impl;
 2 | 
 3 | import de.rayzs.pat.utils.scheduler.PATScheduler;
 4 | import org.bukkit.plugin.messaging.PluginMessageListener;
 5 | import de.rayzs.pat.utils.CommunicationPackets;
 6 | import de.rayzs.pat.plugin.BukkitLoader;
 7 | import de.rayzs.pat.api.communication.*;
 8 | import org.bukkit.entity.Player;
 9 | import org.bukkit.*;
10 | 
11 | public class BukkitClient implements Client, PluginMessageListener {
12 | 
13 |     private static final Server SERVER = Bukkit.getServer();
14 | 
15 |     public BukkitClient() {
16 |         SERVER.getMessenger().registerIncomingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME, this);
17 |         SERVER.getMessenger().registerOutgoingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME);
18 |     }
19 | 
20 |     @Override
21 |     public void send(Object packet) {
22 |         try {
23 | 
24 |             SERVER.sendPluginMessage(BukkitLoader.getPlugin(), CHANNEL_NAME, CommunicationPackets.convertToBytes(packet));
25 | 
26 |         } catch (Throwable throwable) {
27 |             throwable.printStackTrace();
28 |         }
29 |     }
30 | 
31 |     @Override
32 |     public void onPluginMessageReceived(String channel, Player player, byte[] bytes) {
33 | 
34 |         if (!channel.equals(CHANNEL_NAME))
35 |             return;
36 | 
37 |         try {
38 |             Object packetObj = CommunicationPackets.buildFromBytes(bytes);
39 | 
40 |             if (!CommunicationPackets.isPacket(packetObj))
41 |                 return;
42 | 
43 |             PATScheduler.createScheduler(() -> Communicator.receiveInformation("proxy", packetObj));
44 | 
45 |         } catch (Throwable throwable) {
46 |             throwable.printStackTrace();
47 |         }
48 |     }
49 | }
50 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/message/replacer/impl/ProxyPlaceholderReplacer.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.message.replacer.impl;
 2 | 
 3 | import de.rayzs.pat.utils.sender.CommandSender;
 4 | import net.william278.papiproxybridge.api.PlaceholderAPI;
 5 | import java.util.function.Consumer;
 6 | import de.rayzs.pat.utils.*;
 7 | import java.util.UUID;
 8 | 
 9 | public class ProxyPlaceholderReplacer {
10 | 
11 |     private final PlaceholderAPI placeholderAPI;
12 | 
13 |     public ProxyPlaceholderReplacer() {
14 |         placeholderAPI = PlaceholderAPI.createInstance();
15 |         placeholderAPI.setRequestTimeout(1500);
16 |     }
17 | 
18 |     public boolean process(Object playerObj, String text, Consumer consumer) {
19 |         UUID uuid = null;
20 | 
21 |         if(playerObj != null)
22 | 
23 |             if (playerObj instanceof CommandSender) {
24 | 
25 |                 uuid = ((CommandSender) playerObj).getUniqueId();
26 | 
27 |             } else if (Reflection.isVelocityServer()) {
28 | 
29 |                 if (playerObj instanceof com.velocitypowered.api.proxy.Player)
30 |                     uuid = ((com.velocitypowered.api.proxy.Player) playerObj).getUniqueId();
31 | 
32 |             } else if (Reflection.isProxyServer()) {
33 | 
34 |                 if (playerObj instanceof net.md_5.bungee.api.connection.ProxiedPlayer)
35 |                     uuid = ((net.md_5.bungee.api.connection.ProxiedPlayer) playerObj).getUniqueId();
36 | 
37 |             } else {
38 |                 if (playerObj instanceof org.bukkit.entity.Player)
39 |                     uuid = ((org.bukkit.entity.Player) playerObj).getUniqueId();
40 |             }
41 | 
42 |         if(uuid == null) return false;
43 |         placeholderAPI.formatPlaceholders(text, uuid).thenAccept(consumer);
44 | 
45 |         return true;
46 |     }
47 | }
48 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/process/impl/local/info/InfoCommand.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.process.impl.local.info;
 2 | 
 3 | import de.rayzs.pat.api.communication.Communicator;
 4 | import de.rayzs.pat.api.command.ProCommand;
 5 | import de.rayzs.pat.api.storage.Storage;
 6 | import de.rayzs.pat.utils.*;
 7 | import de.rayzs.pat.utils.sender.CommandSender;
 8 | 
 9 | import java.util.List;
10 | 
11 | public class InfoCommand extends ProCommand {
12 | 
13 |     public InfoCommand() {
14 |         super(
15 |                 "info",
16 |                 ""
17 |         );
18 |     }
19 | 
20 |     @Override
21 |     public boolean execute(CommandSender sender, String[] args) {
22 | 
23 |         String message = StringUtils.getStringList(Storage.ConfigSections.Messages.INFO.MESSAGE.getLines(), "\n");
24 | 
25 |         String syncTime =  Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED || Reflection.isProxyServer()
26 |                 ? Storage.ConfigSections.Messages.INFO.SYNC_TIME.replace("%time%", TimeConverter.calcAndGetTime(Reflection.isProxyServer()
27 |                 ? Communicator.LAST_DATA_UPDATE : Communicator.LAST_BUKKIT_SYNC))
28 |                 : Storage.ConfigSections.Messages.INFO.SYNC_DISABLED;
29 | 
30 |         String versionStatus = Storage.OUTDATED
31 |                 ? Storage.ConfigSections.Messages.INFO.VERSION_OUTDATED
32 |                 : Storage.ConfigSections.Messages.INFO.VERSION_UPDATED;
33 | 
34 |         message = StringUtils.replace(message,
35 |                 "%sync_time%", syncTime,
36 |                 "%version_status%", versionStatus
37 |         );
38 | 
39 |         sender.sendMessage(message);
40 |         return true;
41 |     }
42 | 
43 |     @Override
44 |     public List tabComplete(CommandSender sender, String[] args) {
45 |         return List.of();
46 |     }
47 | }
48 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/response/action/ActionHandler.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.response.action;
 2 | 
 3 | import de.rayzs.pat.utils.response.action.impl.*;
 4 | import de.rayzs.pat.utils.Reflection;
 5 | import java.util.UUID;
 6 | 
 7 | public class ActionHandler {
 8 | 
 9 |     private static final Action ACTION = Reflection.isProxyServer() ? Reflection.isVelocityServer()
10 |             ? new VelocityAction() : new BungeeAction()
11 |             : Reflection.getMinor() <= 16
12 |             ? new OldBukkitAction() : new ModernBukkitAction();
13 | 
14 |     public static void initialize() {}
15 | 
16 |     public static void executeConsoleCommand(String action, UUID uuid, String command, String message) {
17 |         ACTION.executeConsoleCommand(action, uuid, command, message);
18 |     }
19 | 
20 |     public static void executePlayerCommand(String action, UUID uuid, String command, String message) {
21 |         ACTION.executePlayerCommand(action, uuid, command, message);
22 |     }
23 | 
24 |     public static void sendTitle(String action, UUID uuid, String command, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
25 |         ACTION.sendTitle(action, uuid, command, title, subTitle, fadeIn, stay, fadeOut);
26 |     }
27 | 
28 |     public static void addPotionEffect(String action, UUID uuid, String potionEffectType, int duration, int amplifier) {
29 |         ACTION.addPotionEffect(action, uuid, potionEffectType, duration, amplifier);
30 |     }
31 | 
32 |     public static void playSound(String action, UUID uuid, String soundName, float volume, float pitch) {
33 |         ACTION.playSound(action, uuid, soundName, volume, pitch);
34 |     }
35 | 
36 |     public static void sendActionbar(String action, UUID uuid, String command, String message) {
37 |         ACTION.sendActionbar(action, uuid, command, message);
38 |     }
39 | }
40 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/process/impl/local/system/NotifyCommand.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.process.impl.local.system;
 2 | 
 3 | import de.rayzs.pat.api.command.ProCommand;
 4 | import de.rayzs.pat.api.storage.Storage;
 5 | import de.rayzs.pat.utils.sender.CommandSender;
 6 | import de.rayzs.pat.utils.Reflection;
 7 | 
 8 | import java.util.List;
 9 | 
10 | public class NotifyCommand extends ProCommand {
11 | 
12 |     public NotifyCommand() {
13 |         super(
14 |                 "notify",
15 |                 ""
16 |         );
17 |     }
18 | 
19 |     @Override
20 |     public boolean execute(CommandSender sender, String[] args) {
21 | 
22 |         boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !Reflection.isProxyServer();
23 | 
24 |         if (backend) {
25 |             sender.sendMessage(Storage.ConfigSections.Messages.NO_PROXY.MESSAGE);
26 |             return true;
27 |         }
28 | 
29 |         boolean enabled = false;
30 | 
31 |         if (sender.isConsole()) {
32 |             enabled = Storage.SEND_CONSOLE_NOTIFICATION;
33 |             Storage.SEND_CONSOLE_NOTIFICATION = !Storage.SEND_CONSOLE_NOTIFICATION;
34 |         } else {
35 |             enabled = Storage.NOTIFY_PLAYERS.contains(sender.getUniqueId());
36 | 
37 |             if (enabled)
38 |                 Storage.NOTIFY_PLAYERS.remove(sender.getUniqueId());
39 |             else
40 |                 Storage.NOTIFY_PLAYERS.add(sender.getUniqueId());
41 |         }
42 | 
43 |         String message = enabled
44 |                 ? Storage.ConfigSections.Messages.NOTIFICATION.DISABLED
45 |                 : Storage.ConfigSections.Messages.NOTIFICATION.ENABLED;
46 | 
47 |         sender.sendMessage(message);
48 |         return true;
49 |     }
50 | 
51 |     @Override
52 |     public List tabComplete(CommandSender sender, String[] args) {
53 |         return null;
54 |     }
55 | }
56 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/subargs/ArgumentBuilder.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.subargs;
 2 | 
 3 | import de.rayzs.pat.utils.StringUtils;
 4 | 
 5 | import java.util.*;
 6 | 
 7 | public class ArgumentBuilder {
 8 | 
 9 |     private final ArgumentSource source;
10 | 
11 |     public ArgumentBuilder(ArgumentSource source) {
12 |         this.source = source;
13 |     }
14 | 
15 |     public List getInputs() {
16 |         return source.INPUTS;
17 |     }
18 | 
19 |     public List getResult(String input) {
20 |         String firstInputArg = StringUtils.getFirstArg(input);
21 | 
22 |         for (Map.Entry entry : source.ARGUMENT_STACKS.entrySet()) {
23 |             if (!entry.getKey().equals(firstInputArg))
24 |                 continue;
25 | 
26 |             return source.ARGUMENT_STACKS.get(entry.getKey()).getResult(input);
27 |         }
28 | 
29 |         return Collections.emptyList();
30 |     }
31 | 
32 |     public void clearAllArguments() {
33 |         source.INPUTS.clear();
34 |         source.ARGUMENT_STACKS.clear();
35 |     }
36 | 
37 |     public void buildArgumentStacks(String input) {
38 |         if (!input.contains(" "))
39 |             return;
40 | 
41 |         if(!source.INPUTS.contains(input))
42 |             source.INPUTS.add(input);
43 | 
44 |         boolean first = true;
45 |         ArgumentStack argumentStack = null;
46 | 
47 |         for (String s : input.split(" ")) {
48 |             if (!first) {
49 |                 argumentStack = argumentStack.createAndGetArgumentStack(s);
50 |                 continue;
51 |             }
52 | 
53 |             argumentStack = source.ARGUMENT_STACKS.get(s);
54 |             if (argumentStack == null) {
55 |                 argumentStack = new ArgumentStack();
56 |                 source.ARGUMENT_STACKS.put(s, argumentStack);
57 |             }
58 | 
59 |             first = false;
60 |         }
61 |     }
62 | }
63 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/scheduler/impl/BukkitScheduler.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.scheduler.impl;
 2 | 
 3 | import de.rayzs.pat.utils.scheduler.PATSchedulerTask;
 4 | import de.rayzs.pat.plugin.BukkitLoader;
 5 | import org.bukkit.Bukkit;
 6 | 
 7 | public class BukkitScheduler implements PATSchedulerTask {
 8 | 
 9 |     private int taskId = -1;
10 | 
11 |     @Override
12 |     public PATSchedulerTask getInstance(boolean async, Runnable runnable, long time, long period) {
13 |         this.taskId = async
14 |                 ? Bukkit.getScheduler().scheduleAsyncRepeatingTask(BukkitLoader.getPlugin(), runnable, time, period)
15 |                 : Bukkit.getScheduler().scheduleSyncRepeatingTask(BukkitLoader.getPlugin(), runnable, time, period);
16 |         return this;
17 |     }
18 | 
19 |     @Override
20 |     public PATSchedulerTask getInstance(boolean async, Runnable runnable, long time) {
21 |         this.taskId = async
22 |                 ? Bukkit.getScheduler().scheduleAsyncDelayedTask(BukkitLoader.getPlugin(), runnable, time)
23 |                 : Bukkit.getScheduler().scheduleSyncDelayedTask(BukkitLoader.getPlugin(), runnable, time);
24 |         return this;
25 |     }
26 | 
27 |     @Override
28 |     public PATSchedulerTask getInstance(boolean async, Runnable runnable) {
29 |         this.taskId = async
30 |                 ? Bukkit.getScheduler().scheduleAsyncDelayedTask(BukkitLoader.getPlugin(), runnable)
31 |                 : Bukkit.getScheduler().scheduleSyncDelayedTask(BukkitLoader.getPlugin(), runnable);
32 |         return this;
33 |     }
34 | 
35 |     @Override
36 |     public boolean isActive() {
37 |         return this.taskId != 1;
38 |     }
39 | 
40 |     @Override
41 |     public void setTaskId(int taskId) {
42 |         this.taskId = taskId;
43 |     }
44 | 
45 |     @Override
46 |     public void cancelTask() {
47 |         Bukkit.getScheduler().cancelTask(taskId);
48 |         this.taskId = -1;
49 |     }
50 | }
51 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/permission/PermissionMap.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.permission;
 2 | 
 3 | import java.util.*;
 4 | import java.util.stream.Collectors;
 5 | 
 6 | public class PermissionMap {
 7 | 
 8 |     private final UUID uuid;
 9 |     private final HashMap permissionMap = new HashMap<>();
10 | 
11 |     public PermissionMap(UUID uuid) {
12 |         this.uuid = uuid;
13 |     }
14 | 
15 |     public void remove(String permission) {
16 |         permissionMap.remove(permission);
17 |     }
18 | 
19 |     public Map getPermissionMap() {
20 |         return permissionMap;
21 |     }
22 | 
23 |     public Set getHashedPermissions() {
24 |         return permissionMap.keySet().stream().filter(permissionMap::get).collect(Collectors.toSet());
25 |     }
26 | 
27 |     public void clear() {
28 |         permissionMap.clear();
29 |     }
30 | 
31 |     public void setState(String permission, boolean permitted) {
32 |         permissionMap.put(permission, permitted);
33 |     }
34 | 
35 |     public void setStateIfEmpty(String permission, boolean permitted) {
36 |         permissionMap.putIfAbsent(permission, permitted);
37 |     }
38 | 
39 |     public boolean isPermitted(String permission) {
40 |         return getPermissionState(permission) == PermissionState.PERMITTED;
41 |     }
42 | 
43 |     public PermissionState getPermissionState(String permission) {
44 |         if (!hasPermissionState(permission)) {
45 |             return PermissionState.EMPTY;
46 |         }
47 | 
48 |         return permissionMap.get(permission)
49 |                 ? PermissionState.PERMITTED
50 |                 : PermissionState.DENIED;
51 |     }
52 | 
53 |     public boolean hasPermissionState(String permission) {
54 |         return permissionMap.containsKey(permission);
55 |     }
56 | 
57 |     public UUID getUUID() {
58 |         return uuid;
59 |     }
60 | 
61 |     enum PermissionState { PERMITTED, DENIED, EMPTY }
62 | }
63 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/process/impl/local/modify/CreateGroupCommand.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.process.impl.local.modify;
 2 | 
 3 | import de.rayzs.pat.api.command.ProCommand;
 4 | import de.rayzs.pat.api.storage.Storage;
 5 | import de.rayzs.pat.utils.sender.CommandSender;
 6 | import de.rayzs.pat.utils.Reflection;
 7 | import de.rayzs.pat.utils.StringUtils;
 8 | import de.rayzs.pat.utils.group.Group;
 9 | import de.rayzs.pat.utils.group.GroupManager;
10 | 
11 | import java.util.Collections;
12 | import java.util.List;
13 | 
14 | public class CreateGroupCommand extends ProCommand {
15 | 
16 |     public CreateGroupCommand() {
17 |         super(
18 |                 "creategroup",
19 |                 "cg"
20 |         );
21 |     }
22 | 
23 |     @Override
24 |     public boolean execute(CommandSender sender, String[] args) {
25 | 
26 |         if (args.length == 0) {
27 |             return false;
28 |         }
29 | 
30 |         boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !Reflection.isProxyServer();
31 | 
32 |         if (backend) {
33 |             sender.sendMessage(Storage.ConfigSections.Messages.NO_PROXY.MESSAGE);
34 |             return true;
35 |         }
36 | 
37 |         String groupName = args[0];
38 |         Group group = GroupManager.getGroupByName(groupName);
39 |         boolean registered = group != null;
40 | 
41 |         if (!registered) {
42 |             GroupManager.registerGroup(groupName);
43 |         } else groupName = group.getGroupName();
44 | 
45 |         String message = registered ? Storage.ConfigSections.Messages.GROUP.ALREADY_EXIST : Storage.ConfigSections.Messages.GROUP.CREATE;
46 |         message = StringUtils.replace(message, "%group%", groupName);
47 | 
48 |         sender.sendMessage(message);
49 |         return true;
50 |     }
51 | 
52 |     @Override
53 |     public List tabComplete(CommandSender sender, String[] args) {
54 |         return Collections.emptyList();
55 |     }
56 | }
57 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/ExpireCache.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils;
 2 | 
 3 | import java.util.concurrent.TimeUnit;
 4 | import com.google.common.cache.*;
 5 | 
 6 | public class ExpireCache {
 7 | 
 8 |     private final Cache cache;
 9 | 
10 |     public ExpireCache(long expireTime, TimeUnit timeUnit) {
11 |         cache = CacheBuilder.newBuilder().concurrencyLevel(2).expireAfterWrite(expireTime, timeUnit).build();
12 |     }
13 | 
14 |     public ExpireCache(ExpireCache expireList) {
15 |         cache = expireList.getCache();
16 |     }
17 | 
18 |     public boolean put(T t, K k) {
19 |         if (contains(t)) {
20 |             return false;
21 |         }
22 | 
23 |         cache.put(t, k);
24 |         return true;
25 |     }
26 | 
27 |     public boolean remove(T t) {
28 |         if (!contains(t)) {
29 |             return false;
30 |         }
31 |         
32 |         cache.invalidate(t);
33 |         return true;
34 |     }
35 | 
36 |     public K putAndGet(T t, K k) {
37 |         put(t, k);
38 |         return k;
39 |     }
40 | 
41 |     public void clear() {
42 |         cache.cleanUp();
43 |     }
44 | 
45 |     public void putIgnoreIfContains(T t, K k) {
46 |         cache.put(t, k);
47 |     }
48 | 
49 |     public K get(T t) {
50 |         Object result = cache.getIfPresent(t);;
51 |         return result == null ? null : (K) result;
52 |     }
53 | 
54 |     public K getOrDefault(T t, K k) {
55 |         Object result = cache.getIfPresent(t);;
56 |         return result == null ? k : (K) result;
57 |     }
58 | 
59 |     public int getSize() {
60 |         cache.cleanUp();
61 |         return (int) cache.size();
62 |     }
63 | 
64 |     public Cache getCache() {
65 |         return cache;
66 |     }
67 | 
68 |     public boolean contains(T t) {
69 |         return cache.getIfPresent(t) != null;
70 |     }
71 | 
72 |     public boolean containsValue(K k) {
73 |         return cache.asMap().containsValue(k);
74 |     }
75 | }


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/api/communication/impl/BungeeClient.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.api.communication.impl;
 2 | 
 3 | import net.md_5.bungee.api.event.PluginMessageEvent;
 4 | import de.rayzs.pat.utils.CommunicationPackets;
 5 | import net.md_5.bungee.api.connection.Server;
 6 | import net.md_5.bungee.api.config.ServerInfo;
 7 | import net.md_5.bungee.api.plugin.Listener;
 8 | import net.md_5.bungee.event.EventHandler;
 9 | import de.rayzs.pat.plugin.BungeeLoader;
10 | import de.rayzs.pat.api.communication.*;
11 | import net.md_5.bungee.api.ProxyServer;
12 | 
13 | public class BungeeClient implements Client, Listener {
14 | 
15 |     private static final ProxyServer SERVER = ProxyServer.getInstance();
16 | 
17 |     public BungeeClient() {
18 |         SERVER.registerChannel(CHANNEL_NAME);
19 |         SERVER.getPluginManager().registerListener(BungeeLoader.getPlugin(), this);
20 |     }
21 | 
22 |     @Override
23 |     public void send(Object packet) {
24 |         for (ServerInfo serverInfo : ProxyServer.getInstance().getServers().values()) {
25 | 
26 |             try {
27 | 
28 |                 serverInfo.sendData(CHANNEL_NAME, CommunicationPackets.convertToBytes(packet));
29 | 
30 |             } catch (Throwable throwable) {
31 |                 throwable.printStackTrace();
32 |             }
33 | 
34 |         }
35 |     }
36 | 
37 |     @EventHandler
38 |     public void onQueryReceive(PluginMessageEvent event) {
39 |         if (!event.getTag().equalsIgnoreCase(CHANNEL_NAME))
40 |             return;
41 | 
42 |         try {
43 | 
44 |             Object packetObj = CommunicationPackets.buildFromBytes(event.getData());
45 | 
46 |             if (!CommunicationPackets.isPacket(packetObj))
47 |                 return;
48 | 
49 |             Server server = (Server) event.getSender();
50 |             Communicator.receiveInformation(server.getInfo().getName(), packetObj);
51 | 
52 |         } catch (Throwable throwable) {
53 |             throwable.printStackTrace();
54 |         }
55 | 
56 |     }
57 | }
58 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/scheduler/PATScheduler.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.scheduler;
 2 | 
 3 | import de.rayzs.pat.utils.scheduler.impl.*;
 4 | import de.rayzs.pat.utils.Reflection;
 5 | 
 6 | public class PATScheduler {
 7 | 
 8 |     public static PATSchedulerTask createScheduler(Runnable runnable, long time, long period) {
 9 |         return Reflection.isFoliaServer()
10 |                 ? new FoliaScheduler().getInstance(false, runnable, time, period)
11 |                 : new BukkitScheduler().getInstance(false, runnable, time, period);
12 |     }
13 | 
14 |     public static PATSchedulerTask createScheduler(Runnable runnable, long time) {
15 |         return Reflection.isFoliaServer()
16 |                 ? new FoliaScheduler().getInstance(false, runnable, time)
17 |                 : new BukkitScheduler().getInstance(false, runnable, time);
18 |     }
19 | 
20 |     public static PATSchedulerTask createScheduler(Runnable runnable) {
21 |         return Reflection.isFoliaServer()
22 |                 ? new FoliaScheduler().getInstance(false, runnable)
23 |                 : new BukkitScheduler().getInstance(false, runnable);
24 |     }
25 | 
26 |     public static PATSchedulerTask createAsyncScheduler(Runnable runnable, long time, long period) {
27 |         return Reflection.isFoliaServer()
28 |                 ? new FoliaScheduler().getInstance(true, runnable, time, period)
29 |                 : new BukkitScheduler().getInstance(true, runnable, time, period);
30 |     }
31 | 
32 |     public static PATSchedulerTask createAsyncScheduler(Runnable runnable, long time) {
33 |         return Reflection.isFoliaServer()
34 |                 ? new FoliaScheduler().getInstance(true, runnable, time)
35 |                 : new BukkitScheduler().getInstance(true, runnable, time);
36 |     }
37 | 
38 |     public static PATSchedulerTask createAsyncScheduler(Runnable runnable) {
39 |         return Reflection.isFoliaServer()
40 |                 ? new FoliaScheduler().getInstance(true, runnable)
41 |                 : new BukkitScheduler().getInstance(true, runnable);
42 |     }
43 | }
44 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/message/translators/VelocityMessageTranslator.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.message.translators;
 2 | 
 3 | import net.kyori.adventure.key.Key;
 4 | import net.kyori.adventure.sound.Sound;
 5 | import net.kyori.adventure.text.minimessage.MiniMessage;
 6 | import com.velocitypowered.api.command.CommandSource;
 7 | import de.rayzs.pat.utils.message.*;
 8 | import net.kyori.adventure.title.Title;
 9 | 
10 | import java.time.Duration;
11 | 
12 | public class VelocityMessageTranslator implements Translator {
13 | 
14 |     @Override
15 |     public String translate(String text) {
16 |         return MiniMessage.miniMessage().serialize(miniMessage.deserialize(MessageTranslator.translateLegacy(text)));
17 |     }
18 | 
19 |     @Override
20 |     public void send(Object target, String text) {
21 |         if (target instanceof CommandSource source) {
22 |             source.sendMessage(toComponent(text));
23 |         }
24 |     }
25 | 
26 |     @Override
27 |     public void sendActionbar(Object target, String text) {
28 |         if (target instanceof CommandSource source) {
29 |             source.sendActionBar(toComponent(text));
30 |         }
31 |     }
32 | 
33 |     @Override
34 |     public void sendTitle(Object target, String titleStr, String subtitleStr, int fadeIn, int stay, int fadeOut) {
35 |         Title.Times times = Title.Times.times(Duration.ofMillis(fadeIn), Duration.ofMillis(stay), Duration.ofMillis(fadeOut));
36 |         Title title = Title.title(toComponent(titleStr), toComponent(subtitleStr), times);
37 | 
38 |         if (target instanceof CommandSource source) {
39 |             source.showTitle(title);
40 |         }
41 |     }
42 | 
43 |     @Override
44 |     public void playSound(Object target, String soundKey, float volume, float pitch) throws Exception {
45 |         if (target instanceof CommandSource source) {
46 |             Sound sound = Sound.sound(Key.key(soundKey), Sound.Source.MASTER, 1f, 1f);
47 | 
48 |             source.playSound(sound, Sound.Emitter.self());
49 |         }
50 |     }
51 | 
52 |     @Override
53 |     public void close() { }
54 | }
55 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/api/communication/impl/VelocityClient.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.api.communication.impl;
 2 | 
 3 | import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
 4 | import com.velocitypowered.api.event.connection.PluginMessageEvent;
 5 | import com.velocitypowered.api.proxy.server.RegisteredServer;
 6 | import de.rayzs.pat.utils.CommunicationPackets;
 7 | import com.velocitypowered.api.event.Subscribe;
 8 | import de.rayzs.pat.plugin.VelocityLoader;
 9 | import de.rayzs.pat.api.communication.*;
10 | import com.velocitypowered.api.proxy.*;
11 | 
12 | public class VelocityClient implements Client {
13 | 
14 |     private static final ProxyServer SERVER = VelocityLoader.getServer();
15 |     private static final MinecraftChannelIdentifier IDENTIFIER = MinecraftChannelIdentifier.from(CHANNEL_NAME);
16 | 
17 |     public VelocityClient() {
18 |         SERVER.getChannelRegistrar().register(IDENTIFIER);
19 |         SERVER.getEventManager().register(VelocityLoader.getInstance(), this);
20 |     }
21 | 
22 |     @Override
23 |     public void send(Object packet) {
24 |         for (RegisteredServer registeredServer : SERVER.getAllServers()) {
25 | 
26 |             try {
27 | 
28 |                 registeredServer.sendPluginMessage(IDENTIFIER, CommunicationPackets.convertToBytes(packet));
29 | 
30 |             } catch (Throwable throwable) {
31 |                 throwable.printStackTrace();
32 |             }
33 | 
34 |         }
35 |     }
36 | 
37 |     @Subscribe
38 |     public void onQueryReceive(PluginMessageEvent event) {
39 |         if (event.getIdentifier() != IDENTIFIER)
40 |             return;
41 | 
42 |         Object packetObj = CommunicationPackets.buildFromBytes(event.getData());
43 | 
44 |         if (!CommunicationPackets.isPacket(packetObj))
45 |             return;
46 | 
47 |         ServerConnection server = (ServerConnection) event.getSource();
48 |         Communicator.receiveInformation(server.getServerInfo().getName(), packetObj);
49 |     }
50 | 
51 |     public static MinecraftChannelIdentifier getIdentifier() {
52 |         return IDENTIFIER;
53 |     }
54 | }
55 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/converter/converters/AdvancedPlHideConverter.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.converter.converters;
 2 | 
 3 | import de.rayzs.pat.api.storage.Storage;
 4 | import de.rayzs.pat.api.storage.storages.BlacklistStorage;
 5 | import de.rayzs.pat.plugin.converter.Converter;
 6 | import de.rayzs.pat.utils.group.Group;
 7 | import de.rayzs.pat.utils.group.GroupManager;
 8 | import de.rayzs.pat.utils.sender.CommandSender;
 9 | 
10 | import java.util.ArrayList;
11 | import java.util.List;
12 | 
13 | public class AdvancedPlHideConverter extends Converter {
14 | 
15 |     public AdvancedPlHideConverter() {
16 |         super("AdvancedPlHide", "AdvancedPlHide", "config");
17 |     }
18 | 
19 |     @Override
20 |     public void apply(CommandSender sender) {
21 |         List groups = config.getKeys("groups", false).stream().toList();
22 | 
23 |         for (String groupName : groups) {
24 |             List commands = (ArrayList) config.get("groups."+ groupName + ".tabcomplete");
25 |             BlacklistStorage storage;
26 | 
27 |             if (groupName.equalsIgnoreCase("default")) {
28 |                 storage = Storage.Blacklist.getBlacklist();
29 |             } else {
30 |                 Group group = GroupManager.registerAndGetGroup(groupName);
31 |                 storage = group.getGeneralGroupBlacklist();
32 |             }
33 | 
34 |             applyStorage(storage, commands);
35 | 
36 |         }
37 | 
38 |         sender.sendMessage("&e&lNotice: &7AdvanedPlHide works based on permissions whether to whitelist or blacklist commands from a group. Due to the fact that this cannot be detected by PAT and formatted in the exact way, all commands have been interpreted as whitelisted commands instead. Also, since PAT groups are only intended to whitelist commands, all created groups based on AdvancedPlHide have been created with the intention of whitelisting commands instead. If you wish to change that, please check out the GitHub wiki on how to use the storage.yml of PAT the intended way. (https://github.com/RayzsYT/ProAntiTab/wiki/How-to#introduction)");
39 |     }
40 | }
41 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/configuration/yaml/ConfigurationProvider.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.configuration.yaml;
 2 | 
 3 | import java.util.*;
 4 | import java.io.*;
 5 | 
 6 | public abstract class ConfigurationProvider {
 7 | 
 8 |     /*
 9 |         Copyright (c) 2012, md_5. All rights reserved.
10 |         Original code from Bungeecord source:
11 |         https://github.com/SpigotMC/BungeeCord/blob/master/config/src/main/java/net/md_5/bungee/config/ConfigurationProvider.java
12 |      */
13 | 
14 |     private static final Map, ConfigurationProvider> providers = new HashMap<>();
15 | 
16 |     static {
17 |         try {
18 |             providers.put(YamlConfiguration.class, new YamlConfiguration());
19 |         } catch (NoClassDefFoundError noClassDefFoundError) {}
20 |         try {
21 |             providers.put(JsonConfiguration.class, new JsonConfiguration());
22 |         } catch (NoClassDefFoundError noClassDefFoundError) {}
23 |     }
24 | 
25 |     public abstract Configuration load(String paramString, Configuration paramConfiguration);
26 | 
27 |     public abstract Configuration load(String paramString);
28 | 
29 |     public abstract Configuration load(InputStream paramInputStream, Configuration paramConfiguration);
30 | 
31 |     public abstract Configuration load(InputStream paramInputStream);
32 | 
33 |     public abstract Configuration load(Reader paramReader, Configuration paramConfiguration);
34 | 
35 |     public abstract Configuration load(Reader paramReader);
36 | 
37 |     public abstract Configuration load(File paramFile, Configuration paramConfiguration) throws IOException;
38 | 
39 |     public abstract Configuration load(File paramFile) throws IOException;
40 | 
41 |     public abstract void save(Configuration paramConfiguration, Writer paramWriter);
42 | 
43 |     public abstract void save(Configuration paramConfiguration, File paramFile) throws IOException;
44 | 
45 |     public static ConfigurationProvider getProvider(Class provider) {
46 |         return providers.get(provider);
47 |     }
48 | }
49 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/process/impl/local/modify/list/ListPrioritiesCommand.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.process.impl.local.modify.list;
 2 | 
 3 | import de.rayzs.pat.api.command.ProCommand;
 4 | import de.rayzs.pat.api.storage.Storage;
 5 | import de.rayzs.pat.utils.sender.CommandSender;
 6 | import de.rayzs.pat.utils.StringUtils;
 7 | import de.rayzs.pat.utils.group.Group;
 8 | import de.rayzs.pat.utils.group.GroupManager;
 9 | 
10 | import java.util.List;
11 | 
12 | public class ListPrioritiesCommand extends ProCommand {
13 | 
14 |     public ListPrioritiesCommand() {
15 |         super(
16 |                 "listpriorities",
17 |                 "lp"
18 |         );
19 |     }
20 | 
21 |     @Override
22 |     public boolean execute(CommandSender sender, String[] args) {
23 | 
24 |         String groupsPriorityListMessage = buildGroupPriorityMessage(
25 |                 GroupManager.getGroups(),
26 |                 Storage.ConfigSections.Messages.GROUP.LIST_PRIORITY_SPLITTER,
27 |                 Storage.ConfigSections.Messages.GROUP.LIST_PRIORITY_GROUPS
28 |         );
29 | 
30 |         String message = StringUtils.replace(groupsPriorityListMessage,
31 |                 "%size%", String.valueOf(GroupManager.getGroups().size()),
32 |                 "%groups%", groupsPriorityListMessage
33 |         );
34 | 
35 |         sender.sendMessage(message);
36 |         return true;
37 |     }
38 | 
39 |     @Override
40 |     public List tabComplete(CommandSender sender, String[] args) {
41 |         return args.length < 2 ? GroupManager.getGroupNames() : null;
42 |     }
43 | 
44 |     private String buildGroupPriorityMessage(List list, String splitter, String format) {
45 |         StringBuilder builder = new StringBuilder();
46 |         boolean end;
47 |         Group group;
48 | 
49 |         for (int i = 0; i < list.size(); i++) {
50 |             end = i >= list.size() - 1;
51 |             group = list.get(i);
52 | 
53 |             builder.append(format.replace("%group%", group.getGroupName()).replace("%priority%", String.valueOf(group.getPriority())));
54 |             if (!end && splitter != null) builder.append(splitter);
55 |         }
56 | 
57 |         return builder.toString();
58 |     }
59 | }
60 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/sender/CommandSenderHandler.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.sender;
 2 | 
 3 | import de.rayzs.pat.utils.ExpireCache;
 4 | import de.rayzs.pat.utils.Reflection;
 5 | import de.rayzs.pat.utils.sender.impl.*;
 6 | 
 7 | import java.util.UUID;
 8 | import java.util.concurrent.TimeUnit;
 9 | 
10 | public class CommandSenderHandler {
11 | 
12 |     public static final UUID CONSOLE_UUID = UUID.randomUUID();
13 | 
14 |     private static final ExpireCache CACHE = new ExpireCache<>(1, TimeUnit.HOURS);
15 | 
16 | 
17 |     public static CommandSender getSenderFromUUID(UUID uuid) {
18 |         return CACHE.get(uuid);
19 |     }
20 | 
21 |     public static CommandSender from(Object senderObj) {
22 |         UUID uuid = extractUUID(senderObj);
23 | 
24 |         if (CACHE.contains(uuid)) {
25 |             return CACHE.get(uuid);
26 |         }
27 | 
28 |         CommandSender sender;
29 | 
30 |         if (Reflection.isProxyServer()) {
31 |             sender = Reflection.isVelocityServer()
32 |                     ? new VelocitySender(senderObj)
33 |                     : new BungeeSender(senderObj);
34 |         } else {
35 |             sender = new BukkitSender(senderObj);
36 |         }
37 | 
38 |         if (sender.getUniqueId() == null) {
39 |             return null;
40 |         }
41 | 
42 |         return CACHE.putAndGet(uuid, sender);
43 |     }
44 | 
45 |     private static UUID extractUUID(Object targetObj) {
46 | 
47 |         if (Reflection.isProxyServer()) {
48 | 
49 |             if (Reflection.isVelocityServer()) {
50 |                 return targetObj instanceof com.velocitypowered.api.proxy.Player
51 |                         ? ((com.velocitypowered.api.proxy.Player) targetObj).getUniqueId()
52 |                         : CONSOLE_UUID;
53 |             }
54 | 
55 |             return targetObj instanceof net.md_5.bungee.api.connection.ProxiedPlayer
56 |                     ? ((net.md_5.bungee.api.connection.ProxiedPlayer) targetObj).getUniqueId()
57 |                     : CONSOLE_UUID;
58 | 
59 |         }
60 | 
61 |         if (targetObj instanceof org.bukkit.entity.Player) {
62 |             return ((org.bukkit.entity.Player) targetObj).getUniqueId();
63 |         }
64 | 
65 |         return CONSOLE_UUID;
66 |     }
67 | }


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/process/impl/local/modify/SetPriorityCommand.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.process.impl.local.modify;
 2 | 
 3 | import de.rayzs.pat.api.command.ProCommand;
 4 | import de.rayzs.pat.api.storage.Storage;
 5 | import de.rayzs.pat.utils.sender.CommandSender;
 6 | import de.rayzs.pat.utils.Reflection;
 7 | import de.rayzs.pat.utils.group.Group;
 8 | import de.rayzs.pat.utils.group.GroupManager;
 9 | 
10 | import java.util.List;
11 | 
12 | public class SetPriorityCommand extends ProCommand {
13 | 
14 |     public SetPriorityCommand() {
15 |         super(
16 |                 "setpriority",
17 |                 "sp"
18 |         );
19 |     }
20 | 
21 |     @Override
22 |     public boolean execute(CommandSender sender, String[] args) {
23 | 
24 |         boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !Reflection.isProxyServer();
25 | 
26 |         if (backend) {
27 |             sender.sendMessage(Storage.ConfigSections.Messages.NO_PROXY.MESSAGE);
28 |             return true;
29 |         }
30 | 
31 |         if (args.length < 2) {
32 |             return false;
33 |         }
34 | 
35 |         String groupName = args[0];
36 |         Group group = GroupManager.getGroupByName(groupName);
37 | 
38 |         if (group == null) {
39 |             sender.sendMessage(Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST.replace("%group%", groupName));
40 |             return true;
41 |         }
42 | 
43 |         String priorityStr = args[1];
44 | 
45 |         try {
46 |             int priority = Integer.parseInt(priorityStr);
47 | 
48 |             if (priority > 0) {
49 |                 group.setPriority(priority);
50 | 
51 |                 GroupManager.sort();
52 |                 Storage.handleChange();
53 | 
54 |                 sender.sendMessage(Storage.ConfigSections.Messages.GROUP.PRIORITY_SUCCESS.replace("%group%", group.getGroupName()).replace("%priority%", priorityStr));
55 |                 return true;
56 |             }
57 | 
58 |         } catch (Exception ignored) {}
59 | 
60 |         sender.sendMessage(Storage.ConfigSections.Messages.GROUP.PRIORITY_FAILED.replace("%group%", groupName).replace("%priority%", priorityStr));
61 |         return true;
62 |     }
63 | 
64 |     @Override
65 |     public List tabComplete(CommandSender sender, String[] args) {
66 |         return args.length < 2 ? GroupManager.getGroupNames() : null;
67 |     }
68 | }
69 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/subargs/ArgumentStack.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.subargs;
 2 | 
 3 | import de.rayzs.pat.plugin.modules.SubArgsModule;
 4 | import de.rayzs.pat.utils.StringUtils;
 5 | 
 6 | import java.util.ArrayList;
 7 | import java.util.HashMap;
 8 | import java.util.List;
 9 | import java.util.Map;
10 | 
11 | public class ArgumentStack {
12 | 
13 |     private final HashMap argumentStacks = new HashMap<>();
14 |     private final List suggestions = new ArrayList<>();
15 | 
16 |     public List getResult(String input) {
17 |         String current;
18 |         while (input.contains(" ")) {
19 |             current = input.split(" ")[0];
20 | 
21 |             if (suggestions.contains("%online_players%"))
22 |                 current = StringUtils.replaceElementsFromString(current, SubArgsModule.getPlayerNames(), "%online_players%");
23 |             if (suggestions.contains("%hidden_online_players%"))
24 |                 current = StringUtils.replaceElementsFromString(current, SubArgsModule.getPlayerNames(), "%hidden_online_players%");
25 | 
26 |             input = StringUtils.replaceFirst(input, current, "");
27 |             input = input.startsWith(" ") ? StringUtils.replaceFirst(input, " ", "") : input;
28 | 
29 |             for (Map.Entry entry : argumentStacks.entrySet()) {
30 |                 if (!entry.getKey().startsWith(current)) continue;
31 | 
32 |                 if (entry.getKey().contains("%online_players%"))
33 |                     input = StringUtils.replaceElementsFromString(input, SubArgsModule.getPlayerNames(), "%online_players%");
34 |                 if (entry.getKey().contains("%hidden_online_players%"))
35 |                     input = StringUtils.replaceElementsFromString(input, SubArgsModule.getPlayerNames(), "%hidden_online_players%");
36 | 
37 |                 return entry.getValue().getResult(input);
38 |             }
39 |         }
40 | 
41 |         return suggestions;
42 |     }
43 | 
44 |     public ArgumentStack createAndGetArgumentStack(String origin) {
45 | 
46 |         if (!suggestions.contains(origin))
47 |             suggestions.add(origin);
48 | 
49 |         if (!argumentStacks.containsKey(origin)) {
50 |             ArgumentStack argumentStack = new ArgumentStack();
51 |             argumentStacks.put(origin, argumentStack);
52 |             return argumentStack;
53 |         }
54 | 
55 |         return argumentStacks.get(origin);
56 |     }
57 | }


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/converter/converters/PlHideFree.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.converter.converters;
 2 | 
 3 | import de.rayzs.pat.api.storage.Storage;
 4 | import de.rayzs.pat.api.storage.storages.BlacklistStorage;
 5 | import de.rayzs.pat.plugin.converter.Converter;
 6 | import de.rayzs.pat.utils.group.Group;
 7 | import de.rayzs.pat.utils.group.GroupManager;
 8 | import de.rayzs.pat.utils.sender.CommandSender;
 9 | 
10 | import java.util.ArrayList;
11 | import java.util.List;
12 | 
13 | public class PlHideFree extends Converter {
14 | 
15 |     public PlHideFree() {
16 |         super("PlHide", "Pl-Hide-Free", "config");
17 |     }
18 | 
19 |     @Override
20 |     public void apply(CommandSender sender) {
21 |         List groups = config.getKeys("groups", false).stream().toList();
22 | 
23 |         for (String groupName : groups) {
24 |             List execution = (ArrayList) config.get("groups." + groupName + ".commands");
25 |             List commands = execution.stream().filter(s -> !s.startsWith("!") && !s.equalsIgnoreCase("*")).map(this::translate).toList();
26 | 
27 |             BlacklistStorage storage;
28 | 
29 |             if (groupName.equalsIgnoreCase("default")) {
30 |                 storage = Storage.Blacklist.getBlacklist();
31 |             } else {
32 |                 Group group = GroupManager.registerAndGetGroup(groupName);
33 |                 storage = group.getGeneralGroupBlacklist();
34 |             }
35 | 
36 |             applyStorage(storage, commands);
37 | 
38 |         }
39 | 
40 |         sender.sendMessage("§e§lNotice: §7Since PAT is mainly focussed on either blocking or whitelisting commands entirely, PAT is viewing and converting the file such that commands are only working in whitelist mode. If you wish to use ProAntiTab in blacklist mode instead, then please checkout the wiki! (https://github.com/RayzsYT/ProAntiTab/wiki/How-to#introduction)");
41 |     }
42 | 
43 |     private String translate(String input) {
44 |         if (input.contains(" ")) {
45 |             if (input.endsWith("~")) {
46 |                 return translate(input.substring(0, input.length() - 1) + "_-");
47 |             }
48 | 
49 |             if (input.endsWith("*")) {
50 |                 return input.substring(0, input.length() - 2);
51 |             } else if (input.contains("*")) {
52 |                 return input.substring(0, input.indexOf('*') - 1);
53 |             }
54 |         }
55 | 
56 |         return input;
57 |     }
58 | }
59 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/process/impl/local/modify/list/ListCommand.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.process.impl.local.modify.list;
 2 | 
 3 | import de.rayzs.pat.api.command.ProCommand;
 4 | import de.rayzs.pat.api.storage.Storage;
 5 | import de.rayzs.pat.utils.sender.CommandSender;
 6 | import de.rayzs.pat.utils.StringUtils;
 7 | import de.rayzs.pat.utils.group.*;
 8 | import java.util.List;
 9 | 
10 | public class ListCommand extends ProCommand {
11 | 
12 |     public ListCommand() {
13 |         super(
14 |                 "list",
15 |                 "ls"
16 |         );
17 |     }
18 | 
19 |     @Override
20 |     public boolean execute(CommandSender sender, String[] args) {
21 | 
22 |         if (args.length == 0) {
23 |             String commandsListMessage = StringUtils.getStringList(
24 |                     Storage.Blacklist.getBlacklist().getCommands(),
25 |                     Storage.ConfigSections.Messages.BLACKLIST.LIST_SPLITTER
26 |             );
27 | 
28 |             String message = Storage.ConfigSections.Messages.BLACKLIST.LIST_MESSAGE;
29 |             message = StringUtils.replace(message,
30 |                     "%size%", String.valueOf(Storage.Blacklist.getBlacklist().getCommands().size()),
31 |                     "%commands%", commandsListMessage
32 |             );
33 | 
34 |             sender.sendMessage(message);
35 |             return true;
36 |         }
37 | 
38 |         String groupName = args[0];
39 |         Group group = GroupManager.getGroupByName(groupName);
40 | 
41 |         if (group == null) {
42 |             sender.sendMessage(Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST.replace("%group%", groupName));
43 |             return true;
44 |         }
45 | 
46 |         String commandsListMessage = StringUtils.getStringList(
47 |                 group.getCommands(),
48 |                 Storage.ConfigSections.Messages.GROUP.LIST_SPLITTER
49 |         );
50 | 
51 |         String message = Storage.ConfigSections.Messages.GROUP.LIST_MESSAGE;
52 |         message = StringUtils.replace(message,
53 |                 "%group%", groupName,
54 |                 "%size%", String.valueOf(group.getCommands().size()),
55 |                 "%commands%", commandsListMessage
56 |         );
57 | 
58 |         sender.sendMessage(message);
59 |         return true;
60 |     }
61 | 
62 |     @Override
63 |     public List tabComplete(CommandSender sender, String[] args) {
64 |         return args.length < 2 ? GroupManager.getGroupNames() : null;
65 |     }
66 | }
67 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/message/translators/BukkitMessageTranslator.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.message.translators;
 2 | 
 3 | import net.kyori.adventure.platform.bukkit.BukkitAudiences;
 4 | import net.kyori.adventure.audience.Audience;
 5 | import de.rayzs.pat.plugin.BukkitLoader;
 6 | import net.kyori.adventure.title.Title;
 7 | import org.bukkit.Sound;
 8 | import org.bukkit.command.CommandSender;
 9 | import de.rayzs.pat.utils.message.*;
10 | import org.bukkit.entity.Player;
11 | 
12 | import java.time.Duration;
13 | 
14 | public class BukkitMessageTranslator implements Translator {
15 | 
16 |     private BukkitAudiences audiences;
17 | 
18 |     public BukkitMessageTranslator() {
19 |         audiences = BukkitAudiences.create(BukkitLoader.getPlugin());
20 |     }
21 | 
22 |     @Override
23 |     public String translate(String text) {
24 |         return miniMessage.serialize(miniMessage.deserialize(MessageTranslator.translateLegacy(text)));
25 |     }
26 | 
27 |     @Override
28 |     public void send(Object target, String text) {
29 |         Audience audience = target instanceof Player ? audiences.player((Player) target) : audiences.sender((CommandSender) target);
30 | 
31 |         audience.sendMessage(toComponent(text));
32 |     }
33 | 
34 |     @Override
35 |     public void sendActionbar(Object target, String text) {
36 |         Audience audience = target instanceof Player ? audiences.player((Player) target) : audiences.sender((CommandSender) target);
37 | 
38 |         audience.sendActionBar(toComponent(text));
39 |     }
40 | 
41 |     @Override
42 |     public void sendTitle(Object target, String titleStr, String subtitleStr, int fadeIn, int stay, int fadeOut) {
43 |         Audience audience = target instanceof Player ? audiences.player((Player) target) : audiences.sender((CommandSender) target);
44 | 
45 |         Title.Times times = Title.Times.times(Duration.ofMillis(fadeIn), Duration.ofMillis(stay), Duration.ofMillis(fadeOut));
46 |         Title title = Title.title(toComponent(titleStr), toComponent(subtitleStr), times);
47 | 
48 |         audience.showTitle(title);
49 |     }
50 | 
51 |     @Override
52 |     public void playSound(Object target, String soundKey, float volume, float pitch) throws Exception {
53 |         if (target instanceof Player player) {
54 |             Sound sound = Sound.valueOf(soundKey);
55 | 
56 |             player.playSound(player.getLocation(), sound, volume, pitch);
57 |         }
58 |     }
59 | 
60 |     @Override
61 |     public void close() {
62 |         audiences.close();
63 |         audiences = null;
64 |     }
65 | }
66 | 


--------------------------------------------------------------------------------
/src/main/resources/files/how-to-read.txt:
--------------------------------------------------------------------------------
 1 | Confused about the display of missing parts in the console?
 2 | It's actually quite easy to read and I'll show you how its done! :D
 3 | 
 4 | Missing parts are written in this format right here: xyz.zyx.idk
 5 | A more befitting example would be something like:
 6 | --> test-feature.enabled
 7 | 
 8 | In the config.yml, this would look like this:
 9 | 
10 | 
11 |     test-feature:
12 |       enabled: true
13 | 
14 | 
15 | Here's another example of this format:
16 | --> info.version.updated
17 | 
18 | In the config.yml, this would look like this:
19 | 
20 | 
21 |     info:
22 |       version:
23 |         updated: ...
24 | 
25 | 
26 | -----------------------------------------------------------------------
27 | 
28 | 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.
29 | Inserting the missing parts to your current config.yml. But how and what exactly?
30 | 
31 | Well, it's actually quite easy. Just take a look on what is missing.
32 | If PAT says, something like this is missing:
33 | - test-feature.enabled
34 | - test-feature.message
35 | - test-feature.failed
36 | 
37 | Then this basically just means, that the entire section for "test-feature" is missing.
38 | In other words, check the "comparable-config.yml" and look for the "test-feature" section.
39 | It would look like this for example:
40 | 
41 | 
42 |     test-feature:
43 |       enabled: true
44 |       message: "Hello World"
45 |       failed: "Error ;c"
46 | 
47 | 
48 | Just copy the entire thing and paste it somewhere in the config.yml.
49 | Once you've reloaded the plugin then, using "/(b)pat reload", everything should work fine.
50 | 
51 | If something went wrong, PAT will let you know! ^^
52 | 
53 | 
54 | Here's a more close to your case example. Let's say your config.yml looks like this:
55 | 
56 |     handle-through-proxy:
57 |       ...
58 | 
59 |     turn-blacklist-to-whitelist: true
60 | 
61 |     custom-protocol-ping:
62 |       ...
63 | 
64 | 
65 | and now let's say PAT says that "base-command-case-sensitive" is missing.
66 | Then this would be what PAT is looking for as solution:
67 | 
68 |     handle-through-proxy:
69 |       ...
70 | 
71 |     turn-blacklist-to-whitelist: true
72 | 
73 |     base-command-case-sensitive: true/false
74 | 
75 |     custom-protocol-ping:
76 |       ...
77 | 
78 | 
79 | On how exactly it needs to be implemented can be seen in the comparison-config.yml file,
80 | as this is the original version which would be generated by default.


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/api/storage/config/settings/CustomProtocolPingSection.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.api.storage.config.settings;
 2 | 
 3 | import de.rayzs.pat.plugin.logger.Logger;
 4 | import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
 5 | import de.rayzs.pat.api.storage.storages.ConfigStorage;
 6 | import de.rayzs.pat.utils.Reflection;
 7 | import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper;
 8 | 
 9 | import java.util.Arrays;
10 | 
11 | public class CustomProtocolPingSection extends ConfigStorage {
12 | 
13 |     public boolean ENABLED, ALWAYS_SHOW, HIDE_PLAYERS, USE_EXTEND_AS_MAX_COUNT, USE_CUSTOM_PLAYERLIST;
14 |     public String PROTOCOL;
15 | 
16 |     public MultipleMessagesHelper PLAYERLIST;
17 | 
18 |     public int EXTEND_COUNT;
19 | 
20 |     public CustomProtocolPingSection() {
21 |         super("custom-protocol-ping");
22 |     }
23 | 
24 |     @Override
25 |     public void load() {
26 |         super.load();
27 | 
28 |         if (!Reflection.isProxyServer() && (!Reflection.isPaper() || Reflection.getMinor() < 12))
29 |             return;
30 | 
31 |         ENABLED = new ConfigSectionHelper(this, "enabled", true).getOrSet();
32 |         ALWAYS_SHOW = new ConfigSectionHelper(this, "always-show", Reflection.isProxyServer() || Reflection.isPaper()).getOrSet();
33 |         USE_EXTEND_AS_MAX_COUNT = new ConfigSectionHelper(this, "use-as-maxplayers", false).getOrSet();
34 |         PROTOCOL = new ConfigSectionHelper(this, "protocol", "&f&lProAntiTab &7(&a%online%&7/&c%max%&7)").getOrSet();
35 |         EXTEND_COUNT = new ConfigSectionHelper(this, "extend-online-count", 1).getOrSet();
36 | 
37 |         HIDE_PLAYERS = new ConfigSectionHelper(this, "hide-players", true).getOrSet();
38 | 
39 |         USE_CUSTOM_PLAYERLIST = new ConfigSectionHelper(this, "custom-playerlist.enabled", false).getOrSet();
40 |         PLAYERLIST = new MultipleMessagesHelper(this, "custom-playerlist.list", Arrays.asList(
41 |                 "&8> &7Online players: &f%online%&7/&c%max%",
42 |                 "&8> &7Using &fProAntiTab"
43 |         ));
44 | 
45 | 
46 | 
47 |         if (HIDE_PLAYERS && USE_CUSTOM_PLAYERLIST) {
48 |             Logger.warning("You can't use both 'hide-players' and 'custom-playerlist' at the same time! (Section: custom-protocol-ping)");
49 |             Logger.warning("You gotta choose what feature from those two you want to use.");
50 |             Logger.warning("In order to avoid any problems, the 'custom-playerlist' feature has been temporarily disabled.");
51 |         }
52 |     }
53 | }
54 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/process/impl/local/info/StatsCommand.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.process.impl.local.info;
 2 | 
 3 | import de.rayzs.pat.api.communication.client.ClientInfo;
 4 | import de.rayzs.pat.api.communication.Communicator;
 5 | import de.rayzs.pat.api.command.ProCommand;
 6 | import de.rayzs.pat.api.storage.Storage;
 7 | import de.rayzs.pat.utils.*;
 8 | import de.rayzs.pat.utils.sender.CommandSender;
 9 | 
10 | import java.util.List;
11 | 
12 | public class StatsCommand extends ProCommand {
13 | 
14 |     public StatsCommand() {
15 |         super(
16 |                 "stats",
17 |                 ""
18 |         );
19 | 
20 |         proxyOnly = true;
21 |     }
22 | 
23 |     @Override
24 |     public boolean execute(CommandSender sender, String[] args) {
25 |         boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !Reflection.isProxyServer();
26 | 
27 |         if(backend) {
28 |             sender.sendMessage(Storage.ConfigSections.Messages.NO_PROXY.MESSAGE);
29 |             return true;
30 |         }
31 | 
32 |         final int length = Communicator.CLIENTS.size() - 1;
33 |         boolean tmpFound = false;
34 | 
35 |         StringBuilder statsBuilder = new StringBuilder();
36 | 
37 |         for (int i = 0; i < Communicator.CLIENTS.size(); i++) {
38 |             ClientInfo client = Communicator.CLIENTS.get(i);
39 | 
40 |             if (!client.hasSentFeedback())
41 |                 continue;
42 | 
43 |             if (!tmpFound)
44 |                 tmpFound = true;
45 | 
46 |             statsBuilder.append(StringUtils.replace(Storage.ConfigSections.Messages.STATS.SERVER,
47 |                     "%updated%", client.getSyncTime(), "%servername%", client.getName()
48 |             ));
49 | 
50 |             if (i <= length)
51 |                 statsBuilder.append(Storage.ConfigSections.Messages.STATS.SPLITTER);
52 |         }
53 | 
54 |         final boolean found = tmpFound;
55 | 
56 |         Storage.ConfigSections.Messages.STATS.STATISTIC.getLines().forEach(message -> {
57 | 
58 |             message = StringUtils.replace(message,
59 |                     "%server_count%", String.valueOf(Communicator.SERVER_DATA_SYNC_COUNT),
60 |                     "%last_sync_time%", TimeConverter.calcAndGetTime(Communicator.LAST_DATA_UPDATE),
61 |                     "%servers%", found ? statsBuilder.toString() : Storage.ConfigSections.Messages.STATS.NO_SERVER
62 |             );
63 | 
64 |             sender.sendMessage(message);
65 |         });
66 | 
67 |         return true;
68 |     }
69 | 
70 |     @Override
71 |     public List tabComplete(CommandSender sender, String[] args) {
72 |         return List.of();
73 |     }
74 | }
75 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/listeners/velocity/VelocityPingListener.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.listeners.velocity;
 2 | 
 3 | import com.velocitypowered.api.event.proxy.ProxyPingEvent;
 4 | import com.velocitypowered.api.proxy.server.ServerPing;
 5 | import com.velocitypowered.api.proxy.ProxyServer;
 6 | import com.velocitypowered.api.event.Subscribe;
 7 | import de.rayzs.pat.api.storage.Storage;
 8 | import java.util.UUID;
 9 | 
10 | public class VelocityPingListener {
11 | 
12 |     private static ProxyServer server;
13 |     private static final UUID RANDOM_UUID = UUID.randomUUID();
14 | 
15 |     public VelocityPingListener(ProxyServer server) {
16 |         VelocityPingListener.server = server;
17 |     }
18 | 
19 |     @Subscribe
20 |     public void onProxyPing(ProxyPingEvent event) {
21 |         if (!Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.ENABLED) return;
22 | 
23 |         ServerPing oldPing = event.getPing();
24 |         ServerPing.Builder builder = oldPing.asBuilder();
25 | 
26 |         int online = server.getPlayerCount(),
27 |                 max = server.getConfiguration().getShowMaxPlayers(),
28 |                 protocol = Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.ALWAYS_SHOW ? -1 : oldPing.getVersion().getProtocol(),
29 |                 extend = online + Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.EXTEND_COUNT;
30 | 
31 | 
32 |         builder.version(new ServerPing.Version(protocol,
33 |                 replaceString(Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PROTOCOL, online, extend, max))
34 |         );
35 | 
36 |         if (Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.USE_EXTEND_AS_MAX_COUNT)
37 |             builder.maximumPlayers(extend);
38 | 
39 |         if (Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.HIDE_PLAYERS)
40 |             builder.clearSamplePlayers();
41 |         else if (Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.USE_CUSTOM_PLAYERLIST) {
42 |             builder.clearSamplePlayers();
43 |             Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PLAYERLIST.getLines().forEach(line ->
44 |                     builder.samplePlayers(new ServerPing.SamplePlayer(replaceString(line, online, extend, max), RANDOM_UUID))
45 |             );
46 |         }
47 | 
48 |         event.setPing(builder.build());
49 |     }
50 | 
51 | 
52 |     private String replaceString(String string, int online, int onlineExtend, int max) {
53 |         return string
54 |                 .replace("&", "§")
55 |                 .replace("%online_extended%", String.valueOf(onlineExtend))
56 |                 .replace("%online%", String.valueOf(online))
57 |                 .replace("%max%", String.valueOf(max));
58 |     }
59 | }
60 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/process/impl/local/modify/DeleteGroupCommand.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.process.impl.local.modify;
 2 | 
 3 | import de.rayzs.pat.api.command.ProCommand;
 4 | import de.rayzs.pat.api.storage.Storage;
 5 | import de.rayzs.pat.utils.sender.CommandSender;
 6 | import de.rayzs.pat.utils.ExpireCache;
 7 | import de.rayzs.pat.utils.Reflection;
 8 | import de.rayzs.pat.utils.StringUtils;
 9 | import de.rayzs.pat.utils.group.Group;
10 | import de.rayzs.pat.utils.group.GroupManager;
11 | 
12 | import java.util.List;
13 | import java.util.UUID;
14 | import java.util.concurrent.TimeUnit;
15 | 
16 | public class DeleteGroupCommand extends ProCommand {
17 | 
18 |     private final ExpireCache CONFIRMATION = new ExpireCache<>(4, TimeUnit.SECONDS);
19 | 
20 |     public DeleteGroupCommand() {
21 |         super(
22 |                 "deletegroup",
23 |                 "dg"
24 |         );
25 |     }
26 | 
27 |     @Override
28 |     public boolean execute(CommandSender sender, String[] args) {
29 | 
30 |         if (args.length == 0) {
31 |             return false;
32 |         }
33 | 
34 |         boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !Reflection.isProxyServer();
35 | 
36 |         if (backend) {
37 |             sender.sendMessage(Storage.ConfigSections.Messages.NO_PROXY.MESSAGE);
38 |             return true;
39 |         }
40 | 
41 |         String groupName = args[0];
42 |         Group group = GroupManager.getGroupByName(groupName);
43 |         boolean registered = group != null;
44 | 
45 |         if (!registered) {
46 |             sender.sendMessage(Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST.replace("%group%", groupName));
47 |             return true;
48 |         }
49 | 
50 |         groupName = group.getGroupName();
51 | 
52 |         String confirmationString = "deletegroup " + groupName;
53 | 
54 |         if (!CONFIRMATION.getOrDefault(sender.getUniqueId(), "").equals(confirmationString)) {
55 |             CONFIRMATION.put(sender.getUniqueId(), confirmationString);
56 |             sender.sendMessage(Storage.ConfigSections.Messages.GROUP.DELETE_CONFIRM);
57 |             return true;
58 |         }
59 | 
60 |         GroupManager.unregisterGroup(groupName);
61 |         CONFIRMATION.remove(sender.getUniqueId());
62 | 
63 |         String message = registered ? Storage.ConfigSections.Messages.GROUP.DELETE : Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST;
64 |         message = StringUtils.replace(message, "%group%", groupName);
65 | 
66 |         sender.sendMessage(message);
67 |         return true;
68 |     }
69 | 
70 |     @Override
71 |     public List tabComplete(CommandSender sender, String[] args) {
72 |         return args.length < 2 ? GroupManager.getGroupNames() : null;
73 |     }
74 | }
75 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/process/impl/local/modify/ClearCommand.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.process.impl.local.modify;
 2 | 
 3 | import de.rayzs.pat.api.command.ProCommand;
 4 | import de.rayzs.pat.api.storage.Storage;
 5 | import java.util.concurrent.TimeUnit;
 6 | import de.rayzs.pat.utils.group.*;
 7 | import de.rayzs.pat.utils.*;
 8 | import de.rayzs.pat.utils.sender.CommandSender;
 9 | 
10 | import java.util.*;
11 | 
12 | public class ClearCommand extends ProCommand {
13 | 
14 |     private final ExpireCache CONFIRMATION = new ExpireCache<>(4, TimeUnit.SECONDS);
15 | 
16 |     public ClearCommand() {
17 |         super(
18 |                 "clear",
19 |                 "clr"
20 |         );
21 |     }
22 | 
23 |     @Override
24 |     public boolean execute(CommandSender sender, String[] args) {
25 | 
26 |         if (args.length == 0) {
27 |             final String confirmationString = "clear";
28 | 
29 |             if (!CONFIRMATION.getOrDefault(sender.getUniqueId(), "").equals(confirmationString)) {
30 |                 CONFIRMATION.put(sender.getUniqueId(), confirmationString);
31 |                 sender.sendMessage(Storage.ConfigSections.Messages.BLACKLIST.CLEAR_CONFIRM);
32 | 
33 |                 return true;
34 |             }
35 | 
36 |             Storage.Blacklist.getBlacklist().clear().save();
37 |             Storage.Blacklist.getBlacklist().load();
38 |             Storage.handleChange();
39 | 
40 |             CONFIRMATION.remove(sender.getUniqueId());
41 | 
42 |             sender.sendMessage(Storage.ConfigSections.Messages.BLACKLIST.CLEAR);
43 |             return true;
44 |         }
45 | 
46 |         String groupName = args[0];
47 |         Group group = GroupManager.getGroupByName(groupName);
48 | 
49 |         if (group == null) {
50 |             sender.sendMessage(Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST.replace("%group%", groupName));
51 |             return true;
52 |         }
53 | 
54 |         groupName = group.getGroupName();
55 | 
56 |         final String confirmationString = "clear " + groupName;
57 | 
58 |         if (!CONFIRMATION.getOrDefault(sender.getUniqueId(), "").equals(confirmationString)) {
59 |             CONFIRMATION.put(sender.getUniqueId(), confirmationString);
60 |             sender.sendMessage(Storage.ConfigSections.Messages.GROUP.CLEAR_CONFIRM);
61 |             return true;
62 |         }
63 | 
64 |         group.clear();
65 |         Storage.handleChange();
66 | 
67 |         CONFIRMATION.remove(sender.getUniqueId());
68 | 
69 |         sender.sendMessage(Storage.ConfigSections.Messages.GROUP.CLEAR.replace("%group%", groupName));
70 |         return true;
71 |     }
72 | 
73 |     @Override
74 |     public List tabComplete(CommandSender sender, String[] args) {
75 |         return args.length < 2 ? GroupManager.getGroupNames() : null;
76 |     }
77 | }
78 | 


--------------------------------------------------------------------------------
/src/main/resources/files/proxy-placeholders.yml:
--------------------------------------------------------------------------------
 1 | #      ____             ___          __  _ ______      __
 2 | #     / __ \_________  /   |  ____  / /_(_)_  __/___ _/ /_
 3 | #    / /_/ / ___/ __ \/ /| | / __ \/ __/ / / / / __ `/ __ \
 4 | #   / ____/ /  / /_/ / ___ |/ / / / /_/ / / / / /_/ / /_/ /
 5 | #  /_/   /_/   \____/_/  |_/_/ /_/\__/_/ /_/  \__,_/_.___/
 6 | #  placeholders.yml (PlaceholderAPI Hook)
 7 | #  (!) Warning: Those placeholders only work if PlaceholderAPI is installed!
 8 | 
 9 | # This here are all placeholders PAT can provide you with.
10 | # All these placeholders can be edited and accessed on the backend server's placeholder.yml file.
11 | # Here's a small overview of all placeholders:
12 | 
13 | # Some general Placeholders to work with:
14 | #   %pat_general_prefix%                    = Get the PAT prefix set in the config.yml.
15 | #   %pat_general_user%                      = Get the name of the user who receives this message.
16 | #   %pat_general_version_current%           = Get current version name of PAT.
17 | #   %pat_general_version_newest%            = Get newest version name of PAT.
18 | 
19 | # Placeholders of some of the messages in the config.yml:
20 | #   %pat_message_unknowncommand%            = Get the "unknown command"-message from the config.yml of PAT. [cancel-blocked-command]
21 | #   %pat_message_base_blocked%              = Get the "command blocked"-message from the config.yml of PAT. [custom-unknown-command]
22 | #   %pat_message_sub_blocked%               = Get the "sub-command blocked"-message from the config.yml of PAT. [custom-unknown-command]
23 | 
24 | # Placeholders to list all commands:
25 | #   %pat_list_size_commands%                = Get the amount of all listed commands.
26 | #   %pat_list_commands%                     = Get all listed commands.
27 | #   %pat_list_sorted_commands%              = Get all listed commands in alphabetic order. (A-Z)
28 | #   %pat_list_reversed_groups%              = Get all listed commands in reversed alphabetic order. (Z-A)
29 | 
30 | # Placeholders to list all commands of a group: (replace 'xxx' with the group-name)
31 | #   %pat_list_size_commands_group_xxx%      = Get the amount of all commands of a group.
32 | #   %pat_list_commands_group_xxx%           = Get all commands of a group.
33 | #   %pat_list_sorted_commands_group_xxx%    = Get all commands of a group in alphabetic order. (A-Z)
34 | #   %pat_list_reversed_commands_group_xxx%  = Get all commands of a group in reversed alphabetic order. (Z-A)
35 | 
36 | # Placeholders to list all groups:
37 | #   %pat_list_size_groups%                  = Get the amount of all available groups.
38 | #   %pat_list_groups%                       = Get all groups.
39 | #   %pat_list_sorted_groups%                = Get all groups in alphabetic order. (A-Z)
40 | #   %pat_list_reversed_groups%              = Get all groups in reversed alphabetic order. (Z-A)


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/plugin/process/impl/local/system/UpdateCommand.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.plugin.process.impl.local.system;
 2 | 
 3 | import de.rayzs.pat.plugin.listeners.bukkit.BukkitAntiTabListener;
 4 | import de.rayzs.pat.utils.Reflection;
 5 | import de.rayzs.pat.utils.permission.PermissionUtil;
 6 | import de.rayzs.pat.api.command.ProCommand;
 7 | import de.rayzs.pat.api.storage.Storage;
 8 | import de.rayzs.pat.utils.sender.CommandSender;
 9 | import de.rayzs.pat.utils.sender.CommandSenderHandler;
10 | 
11 | import java.util.*;
12 | 
13 | public class UpdateCommand extends ProCommand {
14 | 
15 |     public UpdateCommand() {
16 |         super(
17 |                 "update",
18 |                 ""
19 |         );
20 |     }
21 | 
22 |     @Override
23 |     public boolean execute(CommandSender sender, String[] args) {
24 |         if (args.length == 0) {
25 |             PermissionUtil.reloadPermissions();
26 | 
27 |             Storage.getLoader().getOnlinePlayerNames().forEach(name -> {
28 |                 Object playerObj = Storage.getLoader().getPlayerObjByName(name);
29 | 
30 |                 if (playerObj != null) {
31 |                     CommandSender s = CommandSenderHandler.from(playerObj);
32 | 
33 |                     assert s != null;
34 |                     PermissionUtil.reloadPermissions(s);
35 |                 }
36 |             });
37 | 
38 |             if (!Reflection.isProxyServer() && Reflection.getMinor() >= 13) {
39 |                 BukkitAntiTabListener.handleTabCompletion();
40 |             }
41 | 
42 |             sender.sendMessage(Storage.ConfigSections.Messages.UPDATE_PERMISSIONS.UPDATE_ALL);
43 |             return true;
44 |         }
45 | 
46 |         String name = args[0];
47 |         UUID uuid = Storage.getLoader().getUUIDByName(name);
48 |         Object playerObj = Storage.getLoader().getPlayerObjByUUID(uuid);
49 |         CommandSender targetSender = CommandSenderHandler.from(playerObj);
50 | 
51 |         boolean exist = targetSender != null;
52 | 
53 |         if (exist) {
54 |             name = targetSender.getName();
55 |         }
56 | 
57 |         String message = exist
58 |                 ? Storage.ConfigSections.Messages.UPDATE_PERMISSIONS.UPDATE_SPECIFIC
59 |                 : Storage.ConfigSections.Messages.UPDATE_PERMISSIONS.PLAYER_NOT_ONLINE;
60 | 
61 |         message = message.replace("%target%", name);
62 | 
63 |         if (exist) {
64 | 
65 |             PermissionUtil.reloadPermissions(targetSender);
66 | 
67 |             if (!Reflection.isProxyServer() && Reflection.getMinor() >= 13) {
68 |                 BukkitAntiTabListener.handleTabCompletion(uuid);
69 |             }
70 | 
71 |         }
72 | 
73 |         sender.sendMessage(message);
74 |         return true;
75 |     }
76 | 
77 |     @Override
78 |     public List tabComplete(CommandSender sender, String[] args) {
79 |         return args.length < 2 ? Storage.getLoader().getOnlinePlayerNames() : null;
80 |     }
81 | }
82 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/message/translators/BungeeMessageTranslator.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.message.translators;
 2 | 
 3 | import de.rayzs.pat.utils.StringUtils;
 4 | import net.kyori.adventure.key.Key;
 5 | import net.kyori.adventure.sound.Sound;
 6 | import net.kyori.adventure.text.Component;
 7 | import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
 8 | import net.kyori.adventure.title.Title;
 9 | import net.md_5.bungee.api.connection.ProxiedPlayer;
10 | import de.rayzs.pat.utils.message.MessageTranslator;
11 | import net.kyori.adventure.audience.Audience;
12 | import de.rayzs.pat.utils.message.Translator;
13 | import net.md_5.bungee.api.CommandSender;
14 | import de.rayzs.pat.plugin.BungeeLoader;
15 | 
16 | import java.time.Duration;
17 | 
18 | public class BungeeMessageTranslator implements Translator {
19 | 
20 |     private BungeeAudiences audiences;
21 | 
22 |     public BungeeMessageTranslator() {
23 |         audiences = BungeeAudiences.create(BungeeLoader.getPlugin());
24 |     }
25 | 
26 |     @Override
27 |     public String translate(String text) {
28 |         return miniMessage.serialize(miniMessage.deserialize(MessageTranslator.translateLegacy(text)));
29 |     }
30 | 
31 |     @Override
32 |     public void send(Object target, String text) {
33 |         Audience audience = target instanceof ProxiedPlayer ? audiences.player((ProxiedPlayer) target) : audiences.sender((CommandSender) target);
34 | 
35 |         audience.sendMessage(toComponent(text));
36 |     }
37 | 
38 |     @Override
39 |     public void sendActionbar(Object target, String text) {
40 |         Audience audience = target instanceof ProxiedPlayer ? audiences.player((ProxiedPlayer) target) : audiences.sender((CommandSender) target);
41 | 
42 |         audience.sendActionBar(toComponent(text));
43 |     }
44 | 
45 |     @Override
46 |     public void sendTitle(Object target, String titleStr, String subtitleStr, int fadeIn, int stay, int fadeOut) {
47 |         Audience audience = target instanceof ProxiedPlayer ? audiences.player((ProxiedPlayer) target) : audiences.sender((CommandSender) target);
48 | 
49 |         Title.Times times = Title.Times.times(Duration.ofMillis(fadeIn), Duration.ofMillis(stay), Duration.ofMillis(fadeOut));
50 |         Title title = Title.title(toComponent(titleStr), toComponent(subtitleStr), times);
51 | 
52 |         audience.showTitle(title);
53 |     }
54 | 
55 |     @Override
56 |     public void playSound(Object target, String soundKey, float volume, float pitch) throws Exception {
57 |         Audience audience = target instanceof ProxiedPlayer ? audiences.player((ProxiedPlayer) target) : audiences.sender((CommandSender) target);
58 |         Sound sound = Sound.sound(Key.key(soundKey), Sound.Source.MASTER, 1f, 1f);
59 | 
60 |         audience.playSound(sound, Sound.Emitter.self());
61 |     }
62 | 
63 |     @Override
64 |     public void close() {
65 |         audiences.close();
66 |         audiences = null;
67 |     }
68 | }
69 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/ConnectionBuilder.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils;
 2 | 
 3 | import de.rayzs.pat.plugin.logger.Logger;
 4 | 
 5 | import java.util.*;
 6 | import java.net.*;
 7 | 
 8 | public class ConnectionBuilder {
 9 | 
10 |     private String url = null, response = null;
11 |     private List responseList = new ArrayList<>();
12 |     private Object[] parameters = null;
13 |     private int timeout = -1;
14 | 
15 |     public ConnectionBuilder setUrl(String url) {
16 |         this.url = url;
17 |         return this;
18 |     }
19 | 
20 |     public ConnectionBuilder setTimeout(int timeout) {
21 |         this.timeout = timeout;
22 |         return this;
23 |     }
24 | 
25 |     public ConnectionBuilder setProperties(Object... parameters) {
26 |         this.parameters = parameters;
27 |         return this;
28 |     }
29 | 
30 |     public ConnectionBuilder connect() {
31 |         try {
32 |             String rawUrl = url;
33 |             URL url = new URL(rawUrl);
34 |             HttpURLConnection connection = (HttpURLConnection) url.openConnection();
35 | 
36 |             if(timeout != -1) connection.setConnectTimeout(timeout);
37 | 
38 |             connection.setRequestProperty("User-Agent", "Mozilla/5.0");
39 |             connection.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
40 | 
41 |             if(parameters != null && parameters.length > 0) {
42 | 
43 |                 Object firstParam = null, secondParam = null;
44 |                 for (Object parameter : parameters) {
45 | 
46 |                     if (firstParam == null) {
47 |                         firstParam = parameter;
48 |                         continue;
49 |                     }
50 | 
51 |                     secondParam = parameter;
52 | 
53 |                     connection.setRequestProperty((String) firstParam, (String) secondParam);
54 |                     firstParam = null;
55 |                 }
56 |             }
57 | 
58 |             Scanner scanner = new Scanner(connection.getInputStream());
59 |             StringBuilder builder = new StringBuilder("\\");
60 |             String next;
61 | 
62 |             while (scanner.hasNextLine()) {
63 |                 next = scanner.nextLine();
64 |                 responseList.add(next);
65 |                 builder.append(" ").append(next);
66 |             }
67 | 
68 |             response = builder.toString().replace("\\ ", "");
69 | 
70 |         } catch (Exception exception) {
71 |             Logger.warning("Could not reach plugin page! More information below. (" + exception + ")");
72 |         }
73 | 
74 |         return this;
75 |     }
76 | 
77 |     public boolean hasResponse() {
78 |         return response != null;
79 |     }
80 | 
81 |     public String getResponse() {
82 |         return response;
83 |     }
84 | 
85 |     public List getResponseList() {
86 |         return responseList;
87 |     }
88 | }


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/configuration/yaml/JsonConfiguration.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.configuration.yaml;
 2 | 
 3 | import com.google.common.base.Charsets;
 4 | import java.lang.reflect.Type;
 5 | import com.google.gson.*;
 6 | import java.util.*;
 7 | import java.io.*;
 8 | 
 9 | public class JsonConfiguration extends ConfigurationProvider {
10 | 
11 |     /*
12 |         Copyright (c) 2012, md_5. All rights reserved.
13 |         Original code from Bungeecord source:
14 |         https://github.com/SpigotMC/BungeeCord/blob/master/config/src/main/java/net/md_5/bungee/config/JsonConfiguration.java
15 |      */
16 | 
17 |     private final Gson json = (new GsonBuilder()).serializeNulls().setPrettyPrinting().registerTypeAdapter(Configuration.class, new JsonSerializer() {
18 |         public JsonElement serialize(Configuration src, Type typeOfSrc, JsonSerializationContext context) {
19 |             return context.serialize(src.self);
20 |         }
21 |     }).create();
22 | 
23 |     public void save(Configuration config, File file) throws IOException {
24 |         try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8)) {
25 |             save(config, writer);
26 |         }
27 |     }
28 | 
29 |     public void save(Configuration config, Writer writer) {
30 |         this.json.toJson(config.self, writer);
31 |     }
32 | 
33 |     public Configuration load(File file) throws IOException {
34 |         return load(file, (Configuration)null);
35 |     }
36 | 
37 |     public Configuration load(File file, Configuration defaults) throws IOException {
38 |         try (FileInputStream is = new FileInputStream(file)) {
39 |             return load(is, defaults);
40 |         }
41 |     }
42 | 
43 |     public Configuration load(Reader reader) {
44 |         return load(reader, (Configuration)null);
45 |     }
46 | 
47 |     public Configuration load(Reader reader, Configuration defaults) {
48 |         Map map = (Map)this.json.fromJson(reader, LinkedHashMap.class);
49 |         if (map == null)
50 |             map = new LinkedHashMap<>();
51 |         return new Configuration(map, defaults);
52 |     }
53 | 
54 |     public Configuration load(InputStream is) {
55 |         return load(is, (Configuration)null);
56 |     }
57 | 
58 |     public Configuration load(InputStream is, Configuration defaults) {
59 |         return load(new InputStreamReader(is, Charsets.UTF_8), defaults);
60 |     }
61 | 
62 |     public Configuration load(String string) {
63 |         return load(string, (Configuration)null);
64 |     }
65 | 
66 |     public Configuration load(String string, Configuration defaults) {
67 |         Map map = (Map)this.json.fromJson(string, LinkedHashMap.class);
68 |         if (map == null)
69 |             map = new LinkedHashMap<>();
70 |         return new Configuration(map, defaults);
71 |     }
72 | }
73 | 


--------------------------------------------------------------------------------
/src/main/java/de/rayzs/pat/utils/adapter/GroupManagerAdapter.java:
--------------------------------------------------------------------------------
 1 | package de.rayzs.pat.utils.adapter;
 2 | 
 3 | import de.rayzs.pat.api.storage.Storage;
 4 | import de.rayzs.pat.plugin.BukkitLoader;
 5 | import de.rayzs.pat.plugin.listeners.bukkit.BukkitAntiTabListener;
 6 | import de.rayzs.pat.plugin.logger.Logger;
 7 | import de.rayzs.pat.utils.Reflection;
 8 | import de.rayzs.pat.utils.permission.PermissionPlugin;
 9 | import de.rayzs.pat.utils.permission.PermissionUtil;
10 | import de.rayzs.pat.utils.scheduler.PATScheduler;
11 | import org.anjocaido.groupmanager.GroupManager;
12 | import org.anjocaido.groupmanager.events.GMGroupEvent;
13 | import org.anjocaido.groupmanager.events.GMSystemEvent;
14 | import org.anjocaido.groupmanager.events.GMUserEvent;
15 | import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
16 | import org.bukkit.Bukkit;
17 | import org.bukkit.entity.Player;
18 | import org.bukkit.event.EventHandler;
19 | import org.bukkit.event.Listener;
20 | import org.bukkit.plugin.Plugin;
21 | 
22 | import java.util.UUID;
23 | 
24 | public class GroupManagerAdapter implements Listener {
25 | 
26 |     private static GroupManager manager;
27 | 
28 |     public static void initialize(Plugin plugin) {
29 |         Logger.info("Successfully hooked into GroupManager for easier usage.");
30 | 
31 |         Storage.setPermissionPlugin(PermissionPlugin.GROUPMANAGER);
32 |         manager = (GroupManager) plugin;
33 | 
34 |         Bukkit.getServer().getPluginManager().registerEvents(new GroupManagerListener(), BukkitLoader.getPlugin());
35 |     }
36 | 
37 |     public static void setPermissions(UUID uuid) {
38 |         final Player player = Bukkit.getPlayer(uuid);
39 | 
40 |         if (player == null) {
41 |             return;
42 |         }
43 | 
44 |         final AnjoPermissionsHandler handler = manager.getWorldsHolder().getWorldPermissions(player);
45 |         handler.getAllPlayersPermissions(player.getName()).stream()
46 |                 .filter(permission -> permission.startsWith("proantitab."))
47 |                 .forEach(permission -> PermissionUtil.setPermission(uuid, permission, true));
48 | 
49 |         if (Reflection.getMinor() >= 13) {
50 |             BukkitAntiTabListener.handleTabCompletion(uuid);
51 |         }
52 |     }
53 | 
54 |     private static class GroupManagerListener implements Listener {
55 | 
56 |         @EventHandler
57 |         public void onGMUser(GMUserEvent event) {
58 |             PATScheduler.createScheduler(() -> {
59 |                 PermissionUtil.reloadPermissions(event.getUser().getBukkitPlayer().getUniqueId());
60 |             }, 10);
61 |         }
62 | 
63 |         @EventHandler
64 |         public void onGMGroup(GMGroupEvent event) {
65 |             PATScheduler.createScheduler(PermissionUtil::reloadPermissions, 10);
66 |         }
67 | 
68 |         @EventHandler
69 |         public void onGMSystem(GMSystemEvent event) {
70 |             PATScheduler.createScheduler(PermissionUtil::reloadPermissions, 10);
71 |         }
72 |     }
73 | }
74 | 


--------------------------------------------------------------------------------