Compare commits

...
472 Commits
Author SHA1 Message Date
rayzsyt 428ddfb78d Update MiniMessage API 2026-04-28 00:26:07 +02:00
rayzsyt 56bd8be247 Update Version 2026-04-27 23:54:32 +02:00
rayzsyt f7b2aa281e Small change 2026-04-27 23:18:48 +02:00
rayzsyt 0599d504af Fixed that messages were not set automatically in auto-config-updater 2026-04-27 23:18:29 +02:00
rayzsyt 471e0b100f Removed Version enum & simplified some code parts 2026-04-27 22:59:57 +02:00
rayzsyt 52d842b27a Small visual changes to make code more readable 2026-04-27 22:49:28 +02:00
Alihan dfc6ba91eb Merge pull request #26 from gaboss44/feat/mc-26.1-reflection
Reflection class changes
2026-04-27 21:22:51 +02:00
gaboss44 54d59d7b03 Reflection class changes 2026-04-27 13:01:04 -05:00
Alihan a4931199af Merge pull request #24 from MasivoSMP/main
Fix global-thread lag in Folia
2026-03-23 20:23:21 +01:00
Chesvin1 02469e977c Fix globa-thread lag in Folia
Replace backend plugin-message dispatch in BukkitClient from Server.sendPluginMessage(...) (broadcast/fan-out behavior) to single carrier-player dispatch via PATScheduler.execute(..., player).
This keeps plugin messaging on a player/entity scheduler for Folia, reducing redundant per-player sends and feedback amplification that were loading the global scheduler thread under high player counts.
2026-03-22 17:36:04 -03:00
rayzsyt f9386fd3f1 Merge remote-tracking branch 'origin/main' 2026-03-19 19:50:31 +01:00
rayzsyt 242590f3e8 Add 'suppress-exceptions' option 2026-03-19 19:50:12 +01:00
rayzsyt 65c383491e Changed order to filter number last 2026-03-06 19:26:16 +01:00
rayzsyt 0356c2f606 Implemented injection-failed settings 2026-02-27 22:32:49 +01:00
rayzsyt 60067f75d3 Added injection-failed option setting 2026-02-27 22:32:38 +01:00
rayzsyt e896ccb72d Added injection-failed option setting 2026-02-27 22:32:27 +01:00
rayzsyt 6c3dc58cd6 Updated Bungeecord API 2026-02-27 22:32:04 +01:00
rayzsyt 57ada83bfe Corrected wrong information 2026-02-17 03:23:46 +01:00
rayzsyt 8a86f05133 Fixed that proxies would create non-existing command tab-completions 2026-02-17 03:10:57 +01:00
rayzsyt f447cf69d3 Renamed "allow-p2b-packets" -> "allow-p2b-actions" 2026-02-15 00:44:11 +01:00
rayzsyt d06b723adc Reimplemented "Detected Software-API" 2026-02-14 23:46:26 +01:00
rayzsyt f8617cf1b9 Display software name 2026-02-14 23:46:00 +01:00
rayzsyt 8630a6f74c Removed debug message and shorten error message to something more informative 2026-02-14 23:25:30 +01:00
rayzsyt 424d892091 Changed to reveal first and last 2 characters of censored token 2026-02-14 23:18:37 +01:00
rayzsyt 9aaef6e297 Only display censored token instead 2026-02-14 23:10:33 +01:00
rayzsyt e749760136 Added CENSORED_TOKEN 2026-02-14 23:10:25 +01:00
rayzsyt 7f2f3c54ba Fixed color-code overlapping on Bukkit consoles 2026-02-14 22:54:03 +01:00
rayzsyt 24f2c867c6 Added method to reload Client to (un)register the plugin-channels accordingly 2026-02-14 22:28:10 +01:00
rayzsyt e7f3288fb7 Added method to reload Client to (un)register the plugin-channels accordingly 2026-02-14 22:28:05 +01:00
rayzsyt 2221062e98 Fix exception on Craftbukkit servers 2026-02-14 22:26:36 +01:00
rayzsyt 430f5ee9e6 Removed debug message 2026-02-14 22:26:20 +01:00
rayzsyt cd1a7cf312 Removed "Detected Software-API" since it's already in the title 2026-02-14 22:08:00 +01:00
rayzsyt 002cdc64ef Small code cleanup 2026-02-14 22:04:28 +01:00
rayzsyt 3d59686ba4 Small code cleanup 2026-02-14 22:02:01 +01:00
rayzsyt f6c72b9d0e Improved visual representation 2026-02-14 21:21:36 +01:00
rayzsyt d72d419044 Removed unrequired methods 2026-02-14 21:21:24 +01:00
rayzsyt c71a3a4002 Applied changes for new PAT sync-network 2026-02-14 21:21:05 +01:00
rayzsyt 02b70ed324 Applied changes for new PAT sync-network 2026-02-14 21:20:59 +01:00
rayzsyt 01d0a53049 Improved logic & implemented new PAT sync-network 2026-02-14 21:19:10 +01:00
rayzsyt c700ca6abb Removed unused method 2026-02-14 21:17:15 +01:00
rayzsyt d9cba6c010 Added option to toggle P2B packets 2026-02-14 21:16:49 +01:00
rayzsyt a6ed66cf1e Reimplemented PAT sync-network 2026-02-14 21:16:18 +01:00
rayzsyt 4f5b7ad3fb Recoded PAT sync-network 2026-02-14 21:12:03 +01:00
rayzsyt 962ea8b719 Small adjustment 2026-02-14 21:07:17 +01:00
rayzsyt 35e4d0b5aa Add AutoLowerCase for proxy 2026-02-14 20:05:48 +01:00
rayzsyt 497fe5ef98 Added last received alive packet 2026-02-14 20:02:48 +01:00
rayzsyt 0508387db1 Modified 'pat info' message 2026-02-14 19:49:20 +01:00
rayzsyt 1ff7c419ef Add last_alive_response 2026-02-14 19:24:03 +01:00
rayzsyt 612eda685c Modified bpat stats message 2026-02-14 19:17:50 +01:00
rayzsyt 7fc7b571a3 Add AutoLowerCase & Modified bpat stats message 2026-02-14 19:16:00 +01:00
rayzsyt 5cce86bf8d Check if token matches 2026-02-13 18:32:13 +01:00
Alihan Olgun 7621d815ac Code cleanup & Removed unnecessary data sync packets 2026-02-11 21:01:12 +01:00
rayzsyt 81495e3478 Removed unnecessary method implementation for Bukkit-Scheduler 2026-02-08 14:04:12 +01:00
rayzsyt 5c591d3a5b Fixed P2BExecute action in Folia 2026-02-08 13:54:23 +01:00
rayzsyt f1c225b718 Force command execution in main thread 2026-02-08 12:42:15 +01:00
rayzsyt ca7a098cfa Made warning a bit more visual present 2026-02-07 23:53:36 +01:00
rayzsyt b2fbba8455 Made warning a bit more visual present 2026-02-07 23:50:53 +01:00
rayzsyt ae6300c43c Changed parameters for Communicator#sendNotificationPacket method 2026-02-07 23:47:52 +01:00
rayzsyt cb62734da5 Implemented "alert" action and simplified the description 2026-02-07 23:47:18 +01:00
rayzsyt 04a2e4ea54 Add alert action for custom-responses 2026-02-07 23:46:32 +01:00
rayzsyt 2969469605 Replace %server% by server-name from Storage automatically 2026-02-07 23:08:28 +01:00
rayzsyt 25a0f7a742 Implemented P2B packets 2026-02-07 23:08:12 +01:00
rayzsyt d2f6c3336e Updated version 2026-02-07 21:44:01 +01:00
rayzsyt d2c7e00639 Fixed that only Bungeecord commands show up after "bpat reload" 2026-02-07 21:42:13 +01:00
rayzsyt e23fb19c98 Fixed custom-responses actions: execute & console 2026-02-07 21:40:25 +01:00
rayzsyt 1f8d5b78a7 Force command-update on Bungeecord 2026-01-25 01:24:50 +01:00
rayzsyt fee0362c69 Ensure packet not being sent if sync is disabled 2026-01-25 01:22:46 +01:00
rayzsyt 428d944933 Minor changes 2026-01-25 00:20:03 +01:00
rayzsyt 180d23fb1a Fixed wrong usage of sub-arguments in CommandWhitelist conversion 2026-01-23 12:35:04 +01:00
rayzsyt f54dc0f028 Implement Craftbukkit support 2026-01-21 22:05:38 +01:00
rayzsyt ef141a6e7f Disable MiniMessage for Craftbukkit 2026-01-21 21:45:25 +01:00
rayzsyt 55b0b5df75 Add Craftbukkit check 2026-01-21 21:37:10 +01:00
rayzsyt bc78304e97 Small adjustment 2026-01-21 20:18:48 +01:00
rayzsyt 42d8ea3526 Implement TEMP_PLAYER_SERVER_CACHE usage 2026-01-21 19:42:51 +01:00
rayzsyt dfc0066c17 Implement context check 2026-01-21 19:42:21 +01:00
rayzsyt 9e3e61e9a2 Reimplemented update-groups-per-server 2026-01-21 19:41:19 +01:00
rayzsyt 6551bffcdb Implement TEMP_PLAYER_SERVER_CACHE cache 2026-01-21 19:13:22 +01:00
rayzsyt 44f3b4d6d5 Return world name in getPlayerSerName(UUID) method 2026-01-21 18:12:27 +01:00
rayzsyt c672eaaf81 Cancelled event 2026-01-19 16:18:14 +01:00
rayzsyt 460013d22a Added default slash if not there 2026-01-19 16:17:06 +01:00
rayzsyt af89f082aa Always clear sub-arguments for custom-plugins & custom-version feature 2026-01-19 15:50:25 +01:00
rayzsyt e0c3c8a343 Made always executable if it's the console 2026-01-18 19:49:31 +01:00
rayzsyt 83480db4c6 Small adjustments 2026-01-18 19:44:46 +01:00
rayzsyt 04d441cfd6 Add missing interface 2026-01-18 19:44:29 +01:00
rayzsyt 842c2654c6 Add server placeholder to forwarded notification alert 2026-01-18 19:44:01 +01:00
rayzsyt 01d825da86 Implement NotificationPacket call 2026-01-18 18:50:21 +01:00
rayzsyt d61dd872eb Check if option is actually enabled 2026-01-18 17:49:01 +01:00
rayzsyt 3c417c6a8e Add displayCommand to NotificationPacket implementation 2026-01-18 17:40:01 +01:00
rayzsyt f0772a0969 Implement NotificationPacket 2026-01-18 17:39:47 +01:00
rayzsyt 2a83c1c548 Implement NotificationPacket and simplified logic 2026-01-18 17:35:23 +01:00
rayzsyt 12114c63bf Implement ForwardNotificationPacket 2026-01-18 17:30:37 +01:00
rayzsyt 8123ff2f27 Add Forward-Console-Notification-Alerts option 2026-01-18 17:29:29 +01:00
rayzsyt b56ebb3fcb Add NotificationPacket 2026-01-18 17:16:36 +01:00
rayzsyt 7adcce2361 Updated reference url 2026-01-18 17:10:08 +01:00
rayzsyt 6444ec153c Removed unused methods 2026-01-18 17:08:48 +01:00
rayzsyt 841253708d Changed version name 2026-01-18 16:31:46 +01:00
rayzsyt 467308be62 Implemented %offline_players% 2026-01-17 17:53:05 +01:00
rayzsyt d2f8305727 Added new commands to default config 2026-01-17 16:57:48 +01:00
rayzsyt 1a19435b96 Added checks to ensure the list hasn't been modified during the for-loop 2026-01-15 20:07:58 +01:00
rayzsyt eb4b2b1e17 Removed unnecessary computation 2026-01-15 19:53:32 +01:00
rayzsyt 8bca4bc091 Fixed sub-argument disappearing on Spigot servers 2026-01-15 19:48:02 +01:00
rayzsyt dfef20fb87 Fixed subargument blocking in BLACKLIST mode 2026-01-15 19:10:38 +01:00
rayzsyt f4e1dbf385 Fixed subargument blocking in BLACKLIST mode 2026-01-15 19:07:25 +01:00
rayzsyt 93a84f668a Fixed subargument blocking in BLACKLIST mode 2026-01-15 16:55:10 +01:00
rayzsyt f8463c9927 Fix command being blocked entirely if used in BLACKLIST mode 2026-01-15 16:22:46 +01:00
rayzsyt 34b5cd89e5 Ensures that the parent isn't null 2026-01-15 16:15:41 +01:00
rayzsyt 6aae96ab87 Removed old comment 2026-01-15 15:58:05 +01:00
rayzsyt 3f9978e3c1 Code clean up & small fixes 2026-01-06 20:06:35 +01:00
rayzsyt f43d32ca41 Changed usage message 2026-01-06 19:54:55 +01:00
rayzsyt f6c5777865 Changed use-colon to modes instead 2026-01-06 19:51:17 +01:00
rayzsyt cdd79b76a5 Add negated plugin= variable 2026-01-06 19:14:13 +01:00
rayzsyt 5fa152f118 Fix sub-argument filtering 2026-01-04 21:13:24 +01:00
Alihan 7a233e6e3d Removed unnecessary reload of all permissions 2026-01-04 15:09:06 +01:00
Alihan 0697a7e903 Changed licence 2026-01-04 14:52:23 +01:00
rayzsyt 5abf3603cf Add check if it's actually a higher-up version 2026-01-02 21:26:37 +01:00
rayzsyt 1576d4a5a6 Removed debug and private note 2026-01-01 05:12:35 +01:00
rayzsyt 78579f33dc Moved SubArguments module in another package 2026-01-01 05:12:01 +01:00
rayzsyt 3d94eac961 Fix wiresharks and improved algorithm 2026-01-01 04:53:13 +01:00
rayzsyt c31ac308f6 Experimental 2025-12-31 19:20:18 +01:00
rayzsyt e201591d14 Add recursive method 2025-12-31 19:07:16 +01:00
rayzsyt e86a8b29ae Improved replacement algorithm by checking each letter instead of parsing through words only. 2025-12-31 18:12:29 +01:00
rayzsyt 9992885f03 Fixed wrong filtering way 2025-12-30 05:01:49 +01:00
rayzsyt 44ae1e58bf Stop sync if handle-through-proxy is disabled 2025-12-30 04:51:37 +01:00
rayzsyt 5550853c7d Removed unused import 2025-12-29 20:43:45 +01:00
rayzsyt 1c70555d1c Removed unused import 2025-12-29 20:43:27 +01:00
rayzsyt 9dcc11c9f4 Removed unused import 2025-12-29 20:42:22 +01:00
rayzsyt 8d942d0f2e Remove ??? to server list 2025-12-29 20:41:30 +01:00
rayzsyt d556290a19 Call handleCommandNode from SubArgsModule 2025-12-29 20:35:59 +01:00
rayzsyt bf91c80e07 Implement idea 2025-12-29 20:35:46 +01:00
rayzsyt d5d8a43cb5 Add 2025-12-29 17:30:28 +01:00
rayzsyt 31cc490a55 Removed FilerProcess class 2025-12-29 17:30:23 +01:00
rayzsyt 3c0f870c22 Renamed CommandNodeHelper -> ProxyCommandNodeHelper 2025-12-29 17:29:00 +01:00
rayzsyt 4271d31d24 Renamed 2025-12-29 17:28:42 +01:00
rayzsyt 0f35426dbc Removed note 2025-12-29 17:13:33 +01:00
rayzsyt c19276134d Removed debug messages 2025-12-29 17:13:12 +01:00
rayzsyt a93ab63e33 Fixed wrong removal of child nodes 2025-12-29 17:12:41 +01:00
rayzsyt e41ab428b7 Attempt to make recursive removal 2025-12-29 15:16:23 +01:00
rayzsyt a3efda4b5c Completed removal of sub-arguments inside CommandNodes 2025-12-29 13:52:03 +01:00
rayzsyt e7357b1b9c Added note for myself 2025-12-29 02:34:25 +01:00
rayzsyt d9c8485358 Add reader and translator for RootCommands 2025-12-29 02:27:55 +01:00
rayzsyt 84b7899b29 Removed header entirely 2025-12-28 22:51:12 +01:00
rayzsyt 85e6de958c Small change 2025-12-28 22:48:22 +01:00
rayzsyt 9658e9dfe4 Fixed center 2025-12-28 22:47:54 +01:00
rayzsyt d0efa0cb26 Changed to static 2025-12-28 22:44:28 +01:00
rayzsyt 558d0cc7fc Inject all player onto plugin bootup 2025-12-28 22:44:16 +01:00
rayzsyt 96558955aa Implemented CommandSender instead 2025-12-28 22:37:18 +01:00
rayzsyt 383e7db013 Implemented CommandSender instead 2025-12-28 22:37:01 +01:00
rayzsyt bdd53e6003 Fixed wrong prefix 2025-12-28 22:36:52 +01:00
rayzsyt 04d48403bc Implemented CommandSender instead 2025-12-28 22:36:20 +01:00
rayzsyt bb0bd8fb84 Implemented CommandSender instead 2025-12-28 22:35:48 +01:00
rayzsyt 27d63ad1c5 Just made it more readable for me hehe 2025-12-28 22:35:30 +01:00
rayzsyt 26581fb288 Fixed negation of sub-arguments for proxy server 2025-12-28 22:34:56 +01:00
rayzsyt db6e106eb9 Implemented CommandSender instead and added isNegated method 2025-12-28 22:33:05 +01:00
rayzsyt fce4a52abe Implemented CommandSender instead 2025-12-28 22:32:41 +01:00
rayzsyt 81d6200c51 Implemented CommandSender instead 2025-12-28 22:32:26 +01:00
rayzsyt e9b6c45113 Remove targetObj from parameters and use a List of groups instead 2025-12-28 22:32:00 +01:00
rayzsyt ae1120f311 Split hasPermission method to two separate methods using CommandSender and UUID as parameter 2025-12-28 22:31:17 +01:00
rayzsyt 71bf486cc6 Removed cache 2025-12-28 22:30:23 +01:00
rayzsyt 7f8e0e90d5 Add removeSubArguments method 2025-12-28 22:29:44 +01:00
rayzsyt bc702d76ca Implemented CommandSender instead 2025-12-28 22:28:37 +01:00
rayzsyt ea0d6e4544 Implemented CommandSender instead and added improved sub-argument filtering process (Filtering commands using the Mojang Brigadier Library) 2025-12-28 22:28:07 +01:00
rayzsyt 2838486184 Implemented CommandSender instead and improved sub-argument filtering process (Filtering commands using the Mojang Brigadier Library) 2025-12-28 22:27:22 +01:00
rayzsyt 6d5c127571 Implemented CommandSender instead 2025-12-28 22:25:54 +01:00
rayzsyt 7bc32a196d Implemented CommandSender instead 2025-12-28 22:25:29 +01:00
rayzsyt c8ccd8f2b4 Implemented way to find a player-obj by UUID 2025-12-28 22:25:05 +01:00
rayzsyt a84d932050 Implemented CommandSender instead 2025-12-28 22:24:03 +01:00
rayzsyt 57774c4122 Disable unnecessary communication 2025-12-28 22:23:11 +01:00
rayzsyt b6bade9452 Implemented CommandSender instead 2025-12-28 22:22:21 +01:00
rayzsyt be8c5e6f76 Implemented CommandSender instead 2025-12-28 22:22:04 +01:00
rayzsyt d95af1e597 Implemented CommandSender instead 2025-12-28 22:21:41 +01:00
rayzsyt 589a8c320e Removed isNegated method and removed out-commented code 2025-12-28 22:21:05 +01:00
rayzsyt 6d23722b69 Remove doesBypass method 2025-12-28 22:20:35 +01:00
rayzsyt b9d0865c26 Small code refactoring 2025-12-28 22:20:11 +01:00
rayzsyt 87b440c8d7 Add actual description 2025-12-28 22:19:47 +01:00
rayzsyt 726f19de2a Update Java version and ViaVersion library 2025-12-28 22:19:27 +01:00
rayzsyt 406b3900cd Direct implementation of group-list in parameters to increase performance and speed 2025-12-25 23:51:10 +01:00
rayzsyt 3ce05f794a Removal of stored groups 2025-12-25 23:50:39 +01:00
rayzsyt 06752076ff Add extraction of all commands 2025-12-25 23:49:26 +01:00
rayzsyt 19d1ebb773 Remove warning for server-specific groups 2025-12-19 19:40:49 +01:00
rayzsyt e66f5f47f3 Changed http -> https 2025-12-19 19:31:37 +01:00
rayzsyt 2c56e80f57 Add additional check in-case no groups or servers for groups were written 2025-12-19 19:27:41 +01:00
rayzsyt 5cb6bed49d Added GroupManager to softdepend software to ensure its loaded before PAT 2025-12-18 15:14:34 +01:00
rayzsyt 7cc95e2060 Fix exception where backend tries to act as the Bungee 2025-12-16 22:31:37 +01:00
rayzsyt 1873997348 Experimental exception catch 2025-12-16 21:39:24 +01:00
rayzsyt 559e84765b Update version name 2025-12-16 20:57:10 +01:00
rayzsyt 6df476096d Small changes 2025-12-16 20:47:59 +01:00
rayzsyt 7c064e70fd Add sound effect 2025-12-16 20:47:44 +01:00
rayzsyt 55e6058b70 Add Sound effect & small code cleanup 2025-12-16 20:46:53 +01:00
rayzsyt 8a03a4faec Improve and Sound effect 2025-12-16 20:46:36 +01:00
rayzsyt 30eb102bbc Updated Kyori and Velocity libraries 2025-12-16 19:07:00 +01:00
rayzsyt 09ce792bd2 Attempting to allow both MiniMessage and Legacy colors for custom responses 2025-12-16 12:37:42 +01:00
rayzsyt 0fc23712e4 Fixed exception 2025-12-10 23:18:18 +01:00
rayzsyt 6b9c717ec4 Fixed missing server-name 2025-12-10 09:08:41 +01:00
rayzsyt 0c3e82c01e Fixed TOKEN not automatically updating after PAT reload 2025-12-09 23:59:35 +01:00
rayzsyt 8e6e544b60 Deactivated netty injection if Handle-Through-Proxy is enabled 2025-12-09 23:28:48 +01:00
rayzsyt a4196fc118 Added removal from hiddenCommands 2025-12-09 23:21:30 +01:00
rayzsyt d5a9b99a7a Deactivated backend-side sub-argument handling entirely 2025-12-09 22:50:57 +01:00
rayzsyt 6d850f9f07 Added missing server name 2025-12-09 22:35:34 +01:00
rayzsyt c4987b7c5e Fix error while modifying serv commands 2025-12-09 21:32:21 +01:00
rayzsyt 3880738ed9 Modified behavior in regard to block-namespaced-commands in regard to the new option (executions only) 2025-12-09 21:18:08 +01:00
rayzsyt 68c00b843b Add command to hiddenCommands as well 2025-12-09 21:12:29 +01:00
rayzsyt dc352275b6 Add new option 2025-12-09 21:01:38 +01:00
rayzsyt b3362987e5 Reload file on clearance 2025-12-09 21:01:26 +01:00
rayzsyt fb3ec45059 Removed one line 2025-12-09 18:08:27 +01:00
rayzsyt 5100b4a852 Update all commands on first schedule tick (after all plugin loads) 2025-12-09 12:33:46 +01:00
rayzsyt e9ec801dc5 Update if plugin=X or ! command has been added 2025-12-09 12:33:27 +01:00
rayzsyt 70c31b8597 Added plugin=X feature 2025-12-09 12:33:08 +01:00
rayzsyt a078de1fc3 Lowercase by default 2025-12-09 11:19:04 +01:00
rayzsyt a1d759451c Created plugin=X to add all plugin commands 2025-12-09 11:07:26 +01:00
rayzsyt 8a9373963c Ignore packet-handling if Velocity is being used 2025-12-09 11:07:09 +01:00
rayzsyt d964d5b859 Shorten to use new getPluginCommands(String, boolean) method 2025-12-09 11:06:40 +01:00
rayzsyt b468865041 Created getPluginCommands(String, boolean) method 2025-12-09 11:06:22 +01:00
rayzsyt d6fec721ad Deactivated netty tab-completion process for 1.8.8 player 2025-12-08 19:01:40 +01:00
rayzsyt 9256398fa2 Fixed wrong 1.8.8 tab-completion filtering 2025-12-08 19:00:53 +01:00
rayzsyt 4fed08a8f9 Remove changes.txt from final built 2025-12-07 16:58:08 +01:00
rayzsyt b650156e57 Update version name 2025-12-07 16:52:34 +01:00
rayzsyt 4737d15be5 Added option to negate commands via PAT groups 2025-12-07 16:05:22 +01:00
rayzsyt aca6dd7e1d Added experimental code 2025-12-07 01:18:48 +01:00
rayzsyt 5aa0d000dd Better understanding 2025-12-07 01:18:40 +01:00
rayzsyt e2b238fb81 Improved readability 2025-12-06 05:05:59 +01:00
rayzsyt ebdb3edbc1 Fixed wrong display of last-sync time 2025-12-05 21:19:26 +01:00
rayzsyt b9f4e46d65 Attempt to make negatable commands more effective 2025-12-04 16:56:06 +01:00
rayzsyt 287ebd4e9c Ignore if Handle-Through-Proxy is enabled 2025-12-04 16:54:48 +01:00
rayzsyt befdc3de6a Fixed missing tab-completion for Bungeecord commands 2025-12-04 13:55:27 +01:00
rayzsyt 55d00876a7 Recode planned 2025-11-30 14:11:45 +01:00
rayzsyt be0ee15448 Removed unmodifiable, since it's modified later on 2025-11-30 14:11:27 +01:00
rayzsyt 7f91b85d6e Fixed wrong tab-completion of available commands 2025-11-23 22:36:29 +01:00
rayzsyt 80beacaef9 Improved 2025-11-23 05:04:18 +01:00
rayzsyt 9f0521f9de Shorten 2025-11-23 04:53:10 +01:00
rayzsyt 3e1fffcfbb Added reload function 2025-11-23 04:44:29 +01:00
rayzsyt c0e77efad6 Set ignoreColons to false by default 2025-11-23 04:44:08 +01:00
rayzsyt 490f6f420b Set default ignoreColons value to false 2025-11-23 04:43:24 +01:00
rayzsyt 228185291d Added new converters 2025-11-23 04:42:59 +01:00
rayzsyt ab17861e7c Shorten 2025-11-23 04:42:38 +01:00
rayzsyt 567ca5192c Implemented Code 2025-11-23 04:42:25 +01:00
rayzsyt 442a0797a2 Added 2025-11-23 04:42:05 +01:00
rayzsyt c1be977abd Improved 2025-11-23 04:42:00 +01:00
rayzsyt a6f670dcfb Fixed wrong default value 2025-11-20 01:27:48 +01:00
rayzsyt 1d3e72aae2 Fixed error 2025-11-19 21:19:18 +01:00
rayzsyt 513fce2059 Prevent permissions reload if uuid is null 2025-11-19 21:16:22 +01:00
rayzsyt 6247aee871 Added secondary injection attempt. 2025-11-19 21:14:37 +01:00
rayzsyt fc0e230ca5 Stop attempt of working with invalid uuids 2025-11-19 21:14:23 +01:00
rayzsyt d2972f602f More refined information to work with 2025-11-19 21:13:57 +01:00
rayzsyt 0f3b858a75 Fixed missing "usage" message 2025-11-19 17:15:02 +01:00
rayzsyt 70b449e83d Changed message 2025-11-19 17:14:37 +01:00
rayzsyt 2a58b6644e Changed warning message 2025-11-19 16:57:26 +01:00
rayzsyt 96f4386f7a Shorten and improve logic 2025-11-19 16:57:14 +01:00
rayzsyt 3e9de4e859 Added messages 2025-11-19 16:56:57 +01:00
rayzsyt dad2db500c Fixed wrong display of group commands 2025-11-19 16:03:58 +01:00
rayzsyt 9bd33477b1 Apply parameter 2025-11-19 15:23:43 +01:00
rayzsyt 01c680b69a Added format parameter 2025-11-19 15:23:33 +01:00
rayzsyt d20c3c2820 Add 2025-11-19 14:58:51 +01:00
rayzsyt dcb73b1672 Implement more save way to iterate through list 2025-11-19 14:58:43 +01:00
rayzsyt 389f006d02 Added Convert and Extract Command 2025-11-19 14:58:19 +01:00
rayzsyt 0266a6c5f9 Initialized StorageConverter 2025-11-19 14:58:02 +01:00
rayzsyt 9b53123e92 Update version 2025-11-19 14:56:54 +01:00
rayzsyt 9e21110011 Updated version name 2025-11-09 01:58:43 +01:00
rayzsyt 5377c67614 Minor refactoring 2025-11-09 01:26:58 +01:00
rayzsyt 32f8c61d43 Added missing "disabled server" check 2025-11-09 01:26:51 +01:00
rayzsyt 2a16db32ba Added missing "disabled server" check 2025-11-09 01:23:59 +01:00
rayzsyt 735c3764db Edit 2025-11-02 01:55:04 +01:00
rayzsyt c160feb422 Readded notification for custom-plugins & custom-version feature 2025-11-02 01:24:33 +01:00
rayzsyt 21ed81d9ce Removed custom-plugin and custom-version check from there 2025-11-02 01:21:15 +01:00
rayzsyt 6c25c8570d Readded command blocking if command is part of custom-plugins or custom-versions feature 2025-11-02 01:20:23 +01:00
rayzsyt 560c9c3c8b Removed UpdateGroupsPerServer feature for now 2025-10-30 23:53:16 +01:00
rayzsyt 095f4d6179 Fixed issue 2025-10-30 22:16:24 +01:00
rayzsyt 4d389a3e3b Fixed wrong tab-completion filtering 2025-10-28 22:25:26 +01:00
rayzsyt 7f6a5aeba4 Minor logic change 2025-10-22 07:54:18 +02:00
rayzsyt 3006ffac30 Minor rename implementation 2025-10-18 10:07:38 +02:00
rayzsyt d0a256a281 Minor description adjustments 2025-10-18 10:07:18 +02:00
rayzsyt fceab89bc7 Added UpdateGroupPerServer 2025-10-18 10:07:08 +02:00
rayzsyt 6c11525879 Add 2025-10-18 03:47:31 +02:00
rayzsyt 3decc0453b Renamed 2025-10-18 03:47:00 +02:00
rayzsyt b4f9aec084 Mini refactor 2025-10-18 03:41:18 +02:00
rayzsyt 4cd1901e48 Mini refactor 2025-10-18 03:39:38 +02:00
rayzsyt 2aca1d42b0 Fixed missing permissions update after (de)op 2025-10-18 02:46:44 +02:00
rayzsyt 23050b6788 Improved performance by *literally* using a list I already had ;-; 2025-10-18 01:49:02 +02:00
rayzsyt 07bd37bc51 Changed UUID to senderObj 2025-10-17 21:59:44 +02:00
rayzsyt de2ffe910f Update player groups 2025-10-16 02:10:23 +02:00
rayzsyt e3f33e0df4 Wrong display of count 2025-10-16 02:04:41 +02:00
rayzsyt d919bee580 Shorten 2025-10-16 01:40:59 +02:00
rayzsyt ab10f02e3e Replaced with Logger 2025-10-16 01:08:59 +02:00
rayzsyt 647a4ed2b4 Removed debug messages 2025-10-16 01:07:41 +02:00
rayzsyt 5b11e09ece Made task sync 2025-10-16 01:07:16 +02:00
rayzsyt 5c006b3ba7 Implemented method 2025-10-16 01:06:55 +02:00
rayzsyt ba970a2ae4 Moved body to Storage.quickSubArgumentUpdate 2025-10-16 01:06:41 +02:00
rayzsyt 2a51caba40 Improved logic 2025-10-16 01:05:53 +02:00
rayzsyt 5b9035b766 Moved bypass permission check 2025-10-15 23:39:34 +02:00
rayzsyt 41365e07f6 Minor logic adjustments and removal of message 2025-10-15 23:38:51 +02:00
rayzsyt 9fbaf9c628 Minor method adjustment 2025-10-15 23:38:26 +02:00
rayzsyt 730fe64eeb Minor refactor changes 2025-10-15 23:38:05 +02:00
rayzsyt 266fc497d8 Skip if bypass permission exists 2025-10-15 23:37:18 +02:00
rayzsyt 871443b643 Adjustment for non-LuckPerms servers 2025-10-15 23:37:00 +02:00
rayzsyt 4094ee0211 Add broadcastPermissionsPluginNotice method 2025-10-15 23:36:31 +02:00
rayzsyt 0bcd099dcd Improved for non-LuckPerms servers 2025-10-15 23:36:00 +02:00
rayzsyt 04b603569d Improved auto update process 2025-10-15 23:35:40 +02:00
rayzsyt 5a4951aec2 Improved and shorten code 2025-10-15 23:34:59 +02:00
rayzsyt a16aa53561 Minor refactor changes 2025-10-15 23:34:08 +02:00
rayzsyt a4bbcd5f99 Remove unnecessary tab-completion 2025-10-15 23:33:34 +02:00
rayzsyt 75263af008 Implement new packet UpdateCommandsPacket 2025-10-15 23:32:59 +02:00
rayzsyt 6c74c6f1d1 Add new packet 2025-10-15 23:32:47 +02:00
rayzsyt 1ba064db1b Implement updateSenderObject method 2025-10-15 23:32:37 +02:00
rayzsyt e10c55a35b Skip filtering if bypass permission exists 2025-10-15 23:32:26 +02:00
rayzsyt 29a234d94d Implement updateSenderObject method 2025-10-15 23:31:40 +02:00
rayzsyt ccf97cca20 Implement updateSenderObject method 2025-10-15 23:31:33 +02:00
rayzsyt 4ee5908c96 Improve PermissionCheck for non-LuckPerms users 2025-10-15 23:31:20 +02:00
rayzsyt 53128a49bb Added check for bypass permission 2025-10-15 23:30:50 +02:00
rayzsyt 6092960af5 Minor refactor changes 2025-10-15 23:30:22 +02:00
rayzsyt c9e4c9f077 Implement updateSenderObject method 2025-10-15 23:30:00 +02:00
rayzsyt d00a44de53 Improve PermissionCheck for non-LuckPerms users 2025-10-15 23:29:30 +02:00
rayzsyt adfff4c520 Minor refactor changes 2025-10-15 23:29:01 +02:00
rayzsyt fb0dac4e3b Minor refactor changes 2025-10-15 23:28:52 +02:00
rayzsyt 71a43bd431 Updated version name 2025-10-15 23:28:29 +02:00
rayzsyt 339f0490cf Added broadcastPermissionsPluginNotice call and handleUpdateCommandsPacket method 2025-10-15 23:28:15 +02:00
rayzsyt 3e9e71812a Added broadcastPermissionsPluginNotice call 2025-10-15 23:27:44 +02:00
rayzsyt fd0e7c6f7f New 2025-10-15 23:27:15 +02:00
rayzsyt 07a61712ea Added new method 2025-10-15 23:25:49 +02:00
rayzsyt 33080da0b1 Added better PermissionSystem detection 2025-10-15 14:53:41 +02:00
rayzsyt 02f48525e2 Removed display of sub-arguments if using Handle-Through-Proxy 2025-10-12 16:42:35 +02:00
rayzsyt c2aacd1b0c Small improvement 2025-10-12 16:42:14 +02:00
rayzsyt b524ff0701 Moved Methods 2025-10-12 16:09:23 +02:00
rayzsyt b5bffb6731 Update version name 2025-10-12 14:43:00 +02:00
rayzsyt cf84c608a6 Reload Allowed/Disallowed-Commands after change 2025-10-12 14:41:22 +02:00
rayzsyt e61ea7c8b3 Improved 2025-10-12 14:41:00 +02:00
rayzsyt a63df948d7 Removed unused libraries 2025-10-12 14:26:55 +02:00
rayzsyt 509bad85c2 Auto-Command-Sync for Bungeecord 2025-10-12 14:26:46 +02:00
rayzsyt ef48117ab4 Added Bungeecord-intern SubArgument Filter 2025-10-12 14:06:18 +02:00
rayzsyt 08724d4fa8 Small adjustments 2025-10-12 14:04:53 +02:00
rayzsyt 59e5c15c0f Fix minor issue 2025-10-12 03:01:43 +02:00
rayzsyt e96572b62b Fix minor issue 2025-10-12 02:31:23 +02:00
rayzsyt 441eb3f439 Accidental wrong method 2025-10-12 02:07:56 +02:00
rayzsyt 479beb17de Fix minor issues 2025-10-12 02:02:36 +02:00
rayzsyt 92939ba2fd Fix minor issues 2025-10-12 02:02:32 +02:00
rayzsyt 4b4ba32191 Update version name 2025-10-12 01:13:08 +02:00
rayzsyt 2ba002d508 Listed GroupManager-Support to debug post to Bukkit servers only 2025-10-12 01:11:20 +02:00
rayzsyt 594f8a25da Listed GroupManager-Support to debug post 2025-10-12 01:10:41 +02:00
rayzsyt 3ad852e1c8 Fix minor misrepresentation 2025-10-12 00:53:06 +02:00
rayzsyt b3a66eebee Update version name 2025-10-12 00:41:51 +02:00
rayzsyt 5baad90145 Added extra variable for %args[...]% 2025-10-12 00:41:23 +02:00
rayzsyt 2ceb0b6219 Improved Responses Argument Replacer 2025-10-12 00:37:34 +02:00
rayzsyt f870625551 Add GroupManager support 2025-10-10 02:57:35 +02:00
rayzsyt 993aa1e439 Update version 2025-10-09 03:31:51 +02:00
rayzsyt 44822601ee Fixed 1.8.8 issues 2025-10-09 03:25:59 +02:00
rayzsyt 19e698cce4 Update SubArgument commands for 1.8.8 2025-10-09 03:25:37 +02:00
rayzsyt f393156471 More generalised with BukkitLoader methods 2025-10-09 03:25:08 +02:00
rayzsyt 08e996d8df Improved 2025-10-09 03:24:48 +02:00
rayzsyt afffeed10f Fix 1.8.8 issues 2025-10-09 03:24:06 +02:00
rayzsyt ac7efd60de Added methods and implement body of getPlayerIds method 2025-10-09 03:23:24 +02:00
rayzsyt f0db105e7f Moved to BukkitLoader 2025-10-09 03:23:00 +02:00
rayzsyt e07a8bdebb Small adjustment 2025-10-08 19:14:17 +02:00
rayzsyt 84cff08785 Update version 2025-10-08 19:05:19 +02:00
rayzsyt 0f8740c54b Reverted some api updates 2025-10-08 19:04:48 +02:00
rayzsyt 35e1c9aca2 Add new config section 2025-10-08 18:36:06 +02:00
rayzsyt 98848cffd1 Small default-settings adjustments 2025-10-08 18:25:17 +02:00
rayzsyt df6b6f447d Add UpdateCommandsPerWorld feature 2025-10-08 18:23:59 +02:00
rayzsyt ae59f6c84b Updated moved class import 2025-10-08 18:20:28 +02:00
rayzsyt 74ee1fa94c Moved class 2025-10-08 18:19:57 +02:00
rayzsyt 9e11143b88 Code cleanup 2025-10-08 18:19:16 +02:00
rayzsyt 9786e3e472 Add 2025-10-08 18:16:36 +02:00
rayzsyt 468c7d9bd7 Rename Listener class 2025-10-08 18:16:30 +02:00
rayzsyt 640d428d70 Update api 2025-10-08 18:16:09 +02:00
rayzsyt 9a8b78ce9c Updated version name 2025-09-30 23:07:35 +02:00
rayzsyt 87e13ea777 New method 2025-09-30 23:06:51 +02:00
rayzsyt 8e70558363 Wrong display of commands 2025-09-30 23:06:43 +02:00
rayzsyt 5764842f52 Reload existing proxy commands after specific iterations 2025-09-27 01:46:01 +02:00
rayzsyt c2634da6af Relocated proxy-commands load into separate function instead 2025-09-20 00:00:07 +02:00
rayzsyt bf04109e91 Added delayed reload of proxy-commands 2025-09-19 23:59:03 +02:00
rayzsyt ebc46247ad Fixed wrong display of missing parts after plugin-reload 2025-09-14 19:35:54 +02:00
rayzsyt bac1361f98 Removed unnecessary part 2025-09-14 19:26:41 +02:00
rayzsyt b26b1eacba Minor change to missing-parts format 2025-09-14 19:21:57 +02:00
rayzsyt 367357821e Minor change 2025-09-14 19:21:29 +02:00
rayzsyt 030154a135 Improved tutorial 2025-09-14 19:05:18 +02:00
rayzsyt b0bb78acdd Add BaseCommandCaseSensitive option 2025-09-14 18:50:58 +02:00
rayzsyt f98aafa8d1 Add BaseCommandCaseSensitive option 2025-09-14 18:50:54 +02:00
rayzsyt 805a041474 Remove lowercasing the commands 2025-09-14 18:50:16 +02:00
rayzsyt 3f5a0ae4a0 Update version name 2025-09-14 18:26:01 +02:00
rayzsyt 27caf727de Added Software-API info 2025-09-14 18:15:07 +02:00
rayzsyt 31a7d9bc9f Shorten Folia-Check 2025-09-14 18:09:02 +02:00
rayzsyt 3eaf2549e8 Integrated toggleInjection method 2025-09-14 18:07:15 +02:00
rayzsyt 6f0d290d0d Add toggleInjection method 2025-09-14 18:07:08 +02:00
rayzsyt a03da1bbd3 Experimental removal for unnecessary copy-operation 2025-09-14 17:42:39 +02:00
rayzsyt 35d6bd9ead Avoided modifying an iterating list 2025-09-14 17:42:23 +02:00
rayzsyt 97e7b712c7 Added try-catch to identify errors more precise 2025-09-14 17:41:48 +02:00
rayzsyt fcdcb8fa1c Small adjustment 2025-09-13 19:10:27 +02:00
rayzsyt 71b64d74e6 Improve check 2025-09-13 19:09:12 +02:00
rayzsyt bd411e3239 Test to avoid ArrayOutOfBounds issue 2025-09-13 18:24:05 +02:00
rayzsyt 91ce9326b2 Test to avoid ArrayOutOfBounds issue 2025-09-13 18:17:20 +02:00
rayzsyt 9711af2ff4 Removed unnecessary backend-only information 2025-09-05 02:44:25 +02:00
rayzsyt dabf1ca089 Add plugins information 2025-09-05 02:44:04 +02:00
rayzsyt f43c4f7680 Changed log priority 2025-08-29 15:22:01 +02:00
rayzsyt 28ecc7c92d Simplified function due to removal of debug logger 2025-08-29 15:21:35 +02:00
rayzsyt b36428b4ab Added info-method & fixed group-commands issue 2025-08-29 15:21:14 +02:00
rayzsyt 21d219ca53 Changed post-debug function 2025-08-29 15:20:47 +02:00
rayzsyt 497ea897d3 Removed debug logger 2025-08-29 15:20:12 +02:00
rayzsyt 35c4908936 Fix Blacklist/Whitelist issue 2025-08-29 15:19:58 +02:00
rayzsyt 091eb9ae8a Remove debug logger 2025-08-29 15:19:39 +02:00
rayzsyt 445a5d37c3 Remove debug logs 2025-08-29 15:19:13 +02:00
rayzsyt e6b8a9383e Update version name 2025-08-29 15:15:32 +02:00
rayzsyt 66b350eb5e Fix minor bug 2025-08-24 15:12:08 +02:00
rayzsyt da84e1164a Fix minor bug 2025-08-24 15:08:45 +02:00
rayzsyt cde86d46c3 Remove unnecessary Message-Formatting 2025-08-24 15:07:55 +02:00
rayzsyt 607ee2a6c8 Additional group-update check 2025-08-23 16:58:40 +02:00
rayzsyt 6219c7ce9a Add getSenderFromUUID method 2025-08-23 16:57:14 +02:00
rayzsyt 098035d280 Fix new groups not getting set 2025-08-23 16:56:56 +02:00
rayzsyt 111b1275c4 Fix logic (I gave every player perms to all groups ;-;) 2025-08-23 16:42:32 +02:00
rayzsyt d6119a41fb Remove unnecessary function calls 2025-08-23 14:34:36 +02:00
rayzsyt 095dfde3bb Change approach of scanning the list 2025-08-23 14:33:25 +02:00
rayzsyt 3bc56bc934 Change version 2025-08-22 18:15:12 +02:00
rayzsyt 14ecc52cda Improve player-groups storaging 2025-08-22 18:09:02 +02:00
rayzsyt 464355c91c Delayed when filteredCommands list is being set to when it's completed 2025-08-22 06:24:37 +02:00
rayzsyt 82e704eaf7 Readded native command handling 2025-08-21 23:33:08 +02:00
rayzsyt 54284a0543 Removed debug logger 2025-08-21 23:32:55 +02:00
rayzsyt 2cf07382df Update version name 2025-08-21 23:32:40 +02:00
rayzsyt 1de01ac745 Fixed Permission-Recognition issue (Without LuckPerms) 2025-08-19 22:45:01 +02:00
rayzsyt 66fce9fb50 Add 2025-08-19 20:49:08 +02:00
rayzsyt 017500fb5a Integrated LimitedList List 2025-08-19 20:49:03 +02:00
rayzsyt ddd8025fe5 Integrated Negation 2025-08-18 18:52:34 +02:00
rayzsyt f27bc065ba Ignore Negation 2025-08-18 18:52:18 +02:00
rayzsyt 9db3819866 Small method replacement 2025-08-18 18:51:55 +02:00
rayzsyt 8a5470dc68 Added Negation Operator (!) 2025-08-18 18:51:41 +02:00
rayzsyt 159f1b5938 Allows uppercase exceptions 2025-08-18 18:49:56 +02:00
rayzsyt 89fc1ef8ee Add (-_) operator 2025-08-17 18:38:12 +02:00
rayzsyt f249f77cfa Updated version 2025-08-17 18:37:59 +02:00
rayzsyt fad7525101 Removed unused import 2025-08-13 20:55:19 +02:00
rayzsyt 8dc3583ec7 Added delayed permission check if there's no LuckPerms installed 2025-08-13 20:54:40 +02:00
rayzsyt 2936faab56 Improved Logic 2025-08-13 20:52:45 +02:00
rayzsyt 637b7a263a Improved Update Command 2025-08-13 20:51:52 +02:00
rayzsyt be26033dfe Updated version name 2025-08-13 20:51:03 +02:00
rayzsyt 4bc7a7f292 Updated version name 2025-08-13 20:50:56 +02:00
rayzsyt 9b6a9061bc Fixed StackOverFlow Exploit 2025-08-13 20:50:46 +02:00
rayzsyt 6358358078 Added m, k and b to number criteria 2025-08-09 01:35:38 +02:00
rayzsyt 4c4224eb09 Update version name 2025-08-09 01:35:16 +02:00
rayzsyt 9100db600e Fixed removal of commands if "spaced" command was included 2025-08-08 17:49:12 +02:00
rayzsyt 263e3e6896 Removed unnecessary boolean 2025-08-08 04:34:42 +02:00
rayzsyt 26f326668f Fixed commands-update issue when reloading 2025-08-08 04:33:17 +02:00
rayzsyt 74e26a05f3 Update version name 2025-08-08 04:32:58 +02:00
rayzsyt 36145b1ee7 Update version name 2025-08-07 18:26:43 +02:00
rayzsyt 5f457c6e4a Fixed wrong display of blocked command in chat 2025-08-07 18:26:00 +02:00
rayzsyt 65dc540577 Improved performance of getAllCommands method 2025-08-07 01:59:32 +02:00
rayzsyt c338e29ec4 Changed method call 2025-08-07 01:59:08 +02:00
rayzsyt c253f6684b Small refactoring 2025-08-07 01:58:56 +02:00
rayzsyt aa740ffabf Fixed potential Folia incompatibility 2025-08-07 01:58:38 +02:00
rayzsyt e9ffe83a93 Integrated new methods from Loader 2025-08-07 01:58:19 +02:00
rayzsyt c83e83bb06 Integrated new method from Loader 2025-08-07 01:58:04 +02:00
rayzsyt b3c2e014c1 Add new methods 2025-08-07 01:57:54 +02:00
rayzsyt 6631da42e1 Fixed BLACKLIST mode issues 2025-08-07 01:57:44 +02:00
rayzsyt ac5233582f Change version name & integrated new default methods 2025-08-07 01:57:18 +02:00
rayzsyt 32a1f4351a Change version name 2025-08-07 01:57:01 +02:00
rayzsyt 2ff88eeb03 Fixed 1.8.8 incompatibility 2025-08-04 21:44:52 +02:00
rayzsyt 62b505450a Update version name 2025-08-04 21:44:11 +02:00
rayzsyt f7fd9dd42a Update version name 2025-08-04 18:31:55 +02:00
rayzsyt acd8e9291a Fix unnecessary offline-player cache spam 2025-08-02 16:20:17 +02:00
rayzsyt 50c80fc708 Change version name 2025-08-02 16:19:47 +02:00
rayzsyt bb02672085 Apply %args[.-.]% for in-game messages as well 2025-07-31 03:17:43 +02:00
rayzsyt f2e7efeaa6 Fix 0 commands 2025-07-31 03:04:39 +02:00
rayzsyt aa0863e726 Fix missing notification on /pl or /ver 2025-07-30 22:16:32 +02:00
rayzsyt 71cec6933f Add setDoesNotify function 2025-07-30 22:16:03 +02:00
rayzsyt c2d407cd62 Improved Update-Notifier 2025-07-30 22:15:54 +02:00
rayzsyt 61adaa19db Improved notification dedicator 2025-07-30 20:53:55 +02:00
rayzsyt 4c1cc0683d Add exceptional version names 2025-07-30 20:53:35 +02:00
rayzsyt ce3b42af38 Improved VersionComparer 2025-07-30 19:46:21 +02:00
rayzsyt 61c204ade0 Improved replaceArgsVariables Function 2025-07-30 17:18:34 +02:00
rayzsyt e13fae6e67 Removed Skript 2025-07-30 05:23:36 +02:00
rayzsyt 31e4c3caa4 Added variable examples for %args[.-.]% 2025-07-30 05:21:52 +02:00
rayzsyt bccb77667d Added variable %args[from-to]% 2025-07-30 05:18:25 +02:00
rayzsyt 4ab0791740 Updated version name 2025-07-30 05:18:04 +02:00
rayzsyt a9afbad0a2 Updated version name 2025-07-28 20:29:33 +02:00
rayzsyt d625212ac1 Code more readable 2025-07-28 20:26:49 +02:00
rayzsyt ee23b2d47e Fixed sub-argument issue with digits 2025-07-28 20:26:09 +02:00
rayzsyt 30714d5b7d Fixed sub-argument issue with digits 2025-07-28 20:26:03 +02:00
rayzsyt 07734f70bb Moved replacePlaceholders method in here 2025-07-28 20:25:39 +02:00
rayzsyt 367d0cec7e Updated version name 2025-07-28 20:25:18 +02:00
159 changed files with 7931 additions and 2993 deletions

No files matched your search

+335 -17
View File
@@ -1,21 +1,339 @@
MIT License
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (c) 2024 Alihan
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Preamble
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
+562 -6
View File
@@ -1,8 +1,564 @@
# ProAntiTab
# **A**BOUT
ProAntiTab is an advanced **plugin hider** with **many features** and a very simple to understand system. It prevents your server from **plugin spoofers** used by hack clients, manipulates the **tab-completion**, blocks unwanted **suggestions** and much more!
#####
### About
ProAntiTab is a Spigot/Bungeecord Minecraft plugin that helps you to hide unwanted commands from your players.
# **I**N ACTION
![https://www.rayzs.de/proantitab/assets/beforeafter5.png](https://www.rayzs.de/proantitab/assets/beforeafter5.png)
### Support versions
Spigot (+ Forks): 1.8x - 1.20x (latest)
Bungeecord (+ Forks) | Waterfall recommended
######
# **C**USTOM SERVER BRAND (F3)
Create your own animated custom server brand on your Spigot, Bungeecord and Velocity server!
*![https://www.rayzs.de/proantitab/assets/csbr.gif](https://www.rayzs.de/proantitab/assets/csbr.gif)![https://www.rayzs.de/proantitab/assets/edc.gif](https://www.rayzs.de/proantitab/assets/edc.gif)*
<details>
<summary>open config.yml section</summary>
```yaml
# This feature allows you to customize your server-brand you see when you press F3.
# Normally there stands something like 'Purpur', or 'Spigot'.
# With this feature you are able to change and even animate it! ^^
custom-server-brand:
enabled: false
# Determines the speed in that the animation goes
repeat-delay: 3
# This here is the list of the animation
# Possible placeholders:
# %player% - name of the player
# %displayname% - displayname of the player
# %world% - name of world where the player is
# and the other placeholders from PlaceholderAPI
brands:
- '&f&lP&froAntiTab |'
- '&fP&lr&foAntiTab /'
- '&fPr&lo&fAntiTab -'
- '&fPro&lA&fntiTab |'
- '&fProA&ln&ftiTab \'
- '&fProAn&lt&fiTab |'
- '&fProAnt&li&fTab /'
- '&fProAnti&lT&fab -'
- '&fProAnti&lT&fab \'
- '&fProAntiT&la&fb |'
- '&fProAntiTa&lb&f /'
- '&fProAntiTab -'
- '&fProAntiTab \'
```
</details>
######
# **U**SE BLACKLIST AS WHITELIST
You have way too many commands to block? Don't worry.
There's a section in the config.yml located pretty much high that allows you to turn the blacklist into a whitelist instead. This will block every command on your server except for those that are listed.
<details>
<summary>section in config.yml</summary>
```yaml
# This is a very necessary feature if you have way too many commands to block and instead decide
# to whitelist specific commands.
# Enabling this will disable ALL commands except for those that are in the (group-)list.
turn-blacklist-to-whitelist: false
```
</details>
######
# **A**NTI PLUGIN SPOOFING
##### ProAntiTab is able to detect and block plugin spoofing attempts used by hack clients.
*![https://www.rayzs.de/proantitab/assets/noplspoof.png](https://www.rayzs.de/proantitab/assets/noplspoof.png)*
######
# **B**LOCK SUB ARGUMENTS
We all know the problem when players should be able to use some of the commands but should not see literally EVERY sub-argument in a command. Well, then just blend them out? ProAntiTab can do this for you and it's very easy to setup as well! (See some examples below)
![https://www.rayzs.de/proantitab/assets/subargs.png](https://www.rayzs.de/proantitab/assets/subargs.png)
<details>
<summary>example</summary>
```yaml
# Let's say you just want to allow "/help Minecraft" only and not "/help apple".
# It will also automatically allow everything after "/help Minecraft ..."
- help Minecraft
# [CMD] = Allow the execution of the command
# [TAB] = Allow the tab-completion of the command
- "[CMD]cmi tpa" # Only executable. Not tab-completable
- tpa # Executable & Tab-Completable
# %hidden_online_players% = Online players (Removed from tab-completion)
# %online_players% = Online players
# %hidden_players% = Registered players (Removed from tab-completion)
# %players% = Registered players
# %numbers% = Numbers, such as 1000 or 1.000
# _- = Block everything after
- "tpa %online_players%"
- "sell %numbers%"
# Using the operator _- at the end cancels every argument afterwards and blocks it.
# This will allow the player to use "/help Minecraft" but not "/help Minecraft xyz"
- help Minecraft _-
```
</details>
######
# **B**LOCK COLLON COMMANDS
It's annyoing after some time to block all commands including collons like essentials:spawn. With this option you can disable them entirely for good! Only people with the proantitab.namespace permission can see these commands again.
![https://www.rayzs.de/proantitab/assets/namespace.png](https://www.rayzs.de/proantitab/assets/namespace.png)
<details>
<summary>open config.yml section</summary>
```yaml
#>> HTP (Overwritten)
# Here you can disable all namespace commands.
# Namespace commands are commands like plugin:command (e.g: essentials:warp)
# You can bypass this restriction with the proantitab.namespace permission.
block-namespace-commands:
enabled: false
```
</details>
######
# **C**USTOM PLUGINS LIST
Just blocking the /plugins command is pretty boring. This feature here allows you to make it more interesting by displaying for example fake plugins.
![https://www.rayzs.de/proantitab/assets/fakeplugins2.PNG](https://www.rayzs.de/proantitab/assets/fakeplugins2.PNG)
<details>
<summary>open config.yml section</summary>
```yaml
#>> HTP (Overwritten)
# Here you can customize your own fake '/plugins' command.
custom-plugins:
enabled: true
commands:
- pl
- plugins
- bukkit:pl
- bukkit:plugins
message:
- '&fPlugins (0):'
```
</details>
######
# **C**USTOM VERSION COMMAND
Who wouldn't like to pretend to own a custom server-jar? Have fun customizing your very own /version command to your personal liking.
![https://www.rayzs.de/proantitab/assets/custom-version.png](https://www.rayzs.de/proantitab/assets/custom-version.png)
<details>
<summary>open config.yml section</summary>
```yaml
#>> HTP (Overwritten)
# Here you can customize your own fake '/version' command.
custom-version:
enabled: true
commands:
- version
- ver
- icanhasbukkit
- bukkit:ver
- bukkit:version
message:
- '&fThis server is running CraftBukkit version git-NasaSpigot-294 (MC: X)'
```
</details>
######
# **C**USTOM UNKNOWN COMMAND MESSAGE
The Bukkit/Spigot version of ProAntiTab gives your the possibility to create your own unknown-command message to align it with the blocked-command message for example.
![https://www.rayzs.de/proantitab/assets/customunknowncommand.PNG](https://www.rayzs.de/proantitab/assets/customunknowncommand.PNG)
<details>
<summary>open config.yml section</summary>
```yaml
# Now there we come to the good stuff! ^^
# If ProAntiTab is loaded on a Spigot server, you will see this option right here.
# With that you can also customize your own "Unknown Command"-message.
custom-unknown-command:
enabled: true
message:
- '&cThis command does not exist!'
```
</details>
######
# **C**USTOM PROTOCOL PING
Do you know the red text message at the players count when you ping a server with the wrong version? Exactly this holds the information of what kind of server your proxy server is running at. This feature hides the version of the proxy with a custom made one. It's enabled by default but doesn't show the text. The text can be seen when someone pings the server with the wrong version or uses a resolver. This picture shows you what someone with the wrong version would see, unless the "always-show" is enabled. If this option is enabled, this text will always appear.
![https://www.rayzs.de/proantitab/assets/custom-protol-ping.png](https://www.rayzs.de/proantitab/assets/custom-protol-ping.png) <details>
<summary>open config.yml section</summary>
```yaml
# Change the protocol for the version name when the server is being pinged
# (!) Warning: It's required to use Paper or Purpur to use this feature!
# (!) Supported server versions: 1.12.2 - latest
custom-protocol-ping:
enabled: false
# Normally it would only display when someone pings the server with the wrong version.
# Enabling this will always display the protocol and replace it with the normal player count.
always-show: false
# This number here determines the outcome for the %online_extended% placeholder.
# It's the current amount of players increased by this number.
# For example: 5/20 becomes 6/20
extend-online-count: 1
# true: Use new calculated online-count (%online_extended%) as max-players count.
# false: Use the default max-players count.
use-as-maxplayers: false
# Enabling this option hides the list of players on your server,
# when you hover over the player count.
hide-players: true
# The displayed protocol message
# Available placeholders:
# %online% - current online player count
# %online_extended% - manipulated online player count
# %max% - max player count
protocol: '&f&lProAntiTab &7(&a%online%&7/&c%max%&7)'
```
</details>
######
# **C**USTOM RESPONSE ACTIONS
For some, it's important to determine how the response message should be or what should happen. You can customize that factor to your personal liking and use different actions to have full control over your blocked commands.
![https://www.rayzs.de/proantitab/assets/custom-response-title-smaller-2.png](https://www.rayzs.de/proantitab/assets/custom-response-title-smaller-2.png)
![https://www.rayzs.de/proantitab/assets/custom-response-down-smaller-3.png](https://www.rayzs.de/proantitab/assets/custom-response-down-smaller-3.png)
<details>
<summary>Bukkit/Spigot examples</summary>
```yaml
# ____ ___ __ _ ______ __
# / __ \_________ / | ____ / /_(_)_ __/___ _/ /_
# / /_/ / ___/ __ \/ /| | / __ \/ __/ / / / / __ `/ __ \
# / ____/ / / /_/ / ___ |/ / / / /_/ / / / / /_/ / /_/ /
# /_/ /_/ \____/_/ |_/_/ /_/\__/_/ /_/ \__,_/_.___/
# custom-responses.yml
#
# Here you can configure a few of the blocked commands a bit further.
# But what exactly is this here? Every command that would normally respond with the typical "command is blocked" message, can be configured in here!
# And how does it work? It's simple. You just provide the a trigger of the command that would be normally blocked.
# Commands that would normally work won't send the messages you have set here.
# This way PAT can offer you full control over certain commands and their normal responses.
# What are these action section at each block?
# This is an additional feature to make your responses much more alive.
# Example actions that can be used are the following:
# Execute console command:
# Syntax: console::command
# Example: console::say %player% is an evil player
# Execute player command:
# Syntax: execute::command
# Example: execute::help
# Send actionbar:
# Syntax: actionbar::text
# Example: actionbar::&cThis is not cool %player%!
# Send title:
# Syntax: title::title::subtitle::5::20::5
# Example: title::&aTest title::&cHello %player%!
# Play sound:
# Syntax: sound::soundName::volume::pitch
# Example: sound::ENTITY_ENDER_DRAGON_GROWL::1.0::1.0
# Give potion effect:
# Syntax: effect::potionEffect::duration::amplifier
# Example: effect::BLINDNESS::45::1
# Here are a few examples:
# Example with kits.
# In here we only trigger the given message, if the player would type "/kit ...".
# If this command would work through sub-arguments, then the player would only able to execute the command with the
# listed sub-arguments assigned to it. Everything else will result with the set message in there.
# --
#example-with-kits:
# triggers:
# - "kit *"
# message:
# - "&cThis kit does not exist!"
# actions:
# - "actionbar::&cSorry %player%, but this kit does not exist!"
# Here another example with an auctionhouse plugin.
# In here we only trigger the given message, if the player would type "/ah plugin".
# Normally it would print out the "command is blocked" message, because PAT would have blocked it in our case.
# Therefore, we can also assign a custom response message to it.
# ---
#example-with-auctionhouse:
# triggers:
# - "ah plugin"
# message:
# - "&cThis sub-command does not exist. Please type: &e/ah help"
# actions:
# - "console::say That's not nice %player%!"
# - "effect::BLINDNESS::45::1"
# - "sound::ENTITY_ENDER_DRAGON_GROWL::1.0::1.0"
# - "title::&cHey!::&cYou can't do that %player%!::5::20::5"
# - "actionbar::&cNop, sorry %player%"
```
</details>
<details>
<summary>Proxy examples</summary>
```yaml
# ____ ___ __ _ ______ __
# / __ \_________ / | ____ / /_(_)_ __/___ _/ /_
# / /_/ / ___/ __ \/ /| | / __ \/ __/ / / / / __ `/ __ \
# / ____/ / / /_/ / ___ |/ / / / /_/ / / / / /_/ / /_/ /
# /_/ /_/ \____/_/ |_/_/ /_/\__/_/ /_/ \__,_/_.___/
# custom-responses.yml
#
# Here you can configure a few of the blocked commands a bit further.
# But what exactly is this here? Every command that would normally respond with the typical "command is blocked" message, can be configured in here!
# And how does it work? It's simple. You just provide the a trigger of the command that would be normally blocked.
# Commands that would normally work won't send the messages you have set here.
# This way PAT can offer you full control over certain commands and their normal responses.
# What are these action section at each block?
# This is an additional feature to make your responses much more alive.
# Example actions that can be used are the following:
# Execute console command:
# Syntax: console::command
# Example: console::send %player% fallback
# Execute player command:
# Syntax: execute::command
# Example: execute::help
# Send actionbar:
# Syntax: actionbar::text
# Example: actionbar::&cThis is not cool %player%!
# Send title:
# Syntax: title::title::subtitle::5::20::5
# Example: title::&aTest title::&cHello %player%!
# Here are a few examples:
# Example with kits.
# In here we only trigger the given message, if the player would type "/kit ...".
# If this command would work through sub-arguments, then the player would only able to execute the command with the
# listed sub-arguments assigned to it. Everything else will result with the set message in there.
# --
#example-with-kits:
# triggers:
# - "kit *"
# message:
# - "&cThis kit does not exist!"
# actions:
# - "actionbar::&cSorry %player%, but this kit does not exist!"
# Here another example with an auctionhouse plugin.
# In here we only trigger the given message, if the player would type "/ah plugin".
# Normally it would print out the "command is blocked" message, because PAT would have blocked it in our case.
# Therefore, we can also assign a custom response message to it.
# ---
#example-with-auctionhouse:
# triggers:
# - "ah plugin"
# message:
# - "&cThis sub-command does not exist. Please type: &e/ah help"
# actions:
# - "console::say That's not nice %player%!"
# - "title::Hey!::You can't do that %player%!::30::3000::30"
# - "actionbar::Nop, sorry %player%"
```
</details>
#####
# **N**EGATE COMMANDS
It's not a must to write each and every possible sub-argument by hand. The same goes for commands in general.
You can negate them with the help of the negation operator (``!``).
*![https://www.rayzs.de/proantitab/assets/neg.png](https://www.rayzs.de/proantitab/assets/neg.png)*
<details>
<summary>example</summary>
```yaml
# Allows /gamemode and all of its sub-arguments
# except "/gamemode creative"
- "gamemode"
- "!gamemode creative"
- '!gamemode toggle'
```
```yaml
# Allows all commands, except /anvil
- "*"
- "!anvil"
```
</details>
#####
# **A**UTO-ADD ALL PLUGIN COMMANDS
Sometimes it's so annoying to add all commands from a certain plugin by hand. That's why ProAntiTab offers the possebility to simply add all commands from a certain plugin with a simple shortcut.
You can simply add ``plugin=<plugin-name>`` to add all commands from a plugin automatically.
**Only works for standalone Spigot (+Forks) servers**
<details>
<summary>example</summary>
```yaml
# Allows all Essentials commands except /anvil.
# /gamemode is limited to only two sub-arguments
- "plugin=essentials"
- "!anvil"
- "gamemode creative"
- "gamemode survival"
```
</details>
######
# **B**LOCK ON SPECIFIC SERVERS
If you use ProAntiTab on a network, you can pretty easily manage on what servers what commands should exist. Everything can be handled via the proxy and does not require additional maintenance on the backend servers.
For this, just follow the official [setup](https://github.com/RayzsYT/ProAntiTab/wiki/How-to-setup#proxy--spigot-eg-bungeecord--spigot) and [how-to](https://github.com/RayzsYT/ProAntiTab/wiki/How-to#introduction) guide, which can be both found on the [Github wiki](https://github.com/RayzsYT/ProAntiTab/wiki).
######
# **G**ROUP SYSYTEM
The PAT group system allows you to allow certain commands only for a certain group of people. PAT group commands are mainly for **whitelisting** commands, can merge with other groups, and so on.
They can also be used to blacklist commands by negating the commands inside there. But for this to work, the option `allow-group-overruling` inside the `config.yml` needs to be enabled.
How to use the PAT group system in general can be seen on the [Github wiki](https://github.com/RayzsYT/ProAntiTab/wiki/How-to#use-the-group-system).
######
# **P**LACEHOLDERAPI & PAPIPROXYBRIDGE SUPPORT
Customization and uniqueness is an important factor for many server owners. That's why PAT offers you the possebility to edit and use many of its placeholders with the widely spreaded plugin [PlaceholderAPI](https://www.spigotmc.org/resources/6245/). Accessing those placeholders on the proxy isn't a problem either. With the support of the addtional plugin [PAPIProxyBridge](https://www.spigotmc.org/resources/108415/), PAT's placeholders are even accessable on your proxy server.
<details>
<summary>Available placeholders</summary>
```yaml
# Some general Placeholders to work with:
# %pat_general_user% = Get the name of the user who receives this message.
# %pat_general_version_current% = Get current version name of PAT.
# %pat_general_version_newest% = Get newest version name of PAT.
# Placeholders of some of the messages in the config.yml:
# %pat_message_unknowncommand% = Get the "unknown command"-message from the config.yml of PAT. [cancel-blocked-command]
# %pat_message_blocked% = Get the "command blocked"-message from the config.yml of PAT. [custom-unknown-command]
# Placeholders to list all commands:
# %pat_list_size_commands% = Get the amount of all listed commands.
# %pat_list_commands% = Get all listed commands.
# %pat_list_sorted_commands% = Get all listed commands in alphabetic order. (A-Z)
# %pat_list_reversed_groups% = Get all listed commands in reversed alphabetic order. (Z-A)
# Placeholders to list all commands of a group: (replace 'xxx' with the group-name)
# %pat_list_size_commands_group_xxx% = Get the amount of all commands of a group.
# %pat_list_commands_group_xxx% = Get all commands of a group.
# %pat_list_sorted_commands_group_xxx% = Get all commands of a group in alphabetic order. (A-Z)
# %pat_list_reversed_commands_group_xxx% = Get all commands of a group in reversed alphabetic order. (Z-A)
# Placeholders to list all groups:
# %pat_list_size_groups% = Get the amount of all available groups.
# %pat_list_groups% = Get all groups.
# %pat_list_sorted_groups% = Get all groups in alphabetic order. (A-Z)
# %pat_list_reversed_groups% = Get all groups in reversed alphabetic order. (Z-A)
```
</details>
###
# **M**INIMESSAGE SUPPORT
## ![https://www.rayzs.de/proantitab/assets/possibilites.png](https://www.rayzs.de/proantitab/assets/possibilites.png)
##### You want to design your messages more unique? We got you covered! *(works on 1.17 server and above)*
*([Click here to see the documentation for the format](https://docs.advntr.dev/minimessage/format.html#)*)
Look at those few examples to see what kind of possibilities awaits you:
<details>
<summary>example 1</summary>
```yaml
cancel-blocked-commands:
enabled: true
message: '<hover:show_text:"&cBlocked command: &4&o%command%">&cThis command is &4&lBLOCKED&c!'
```
![https://www.rayzs.de/proantitab/assets/example1.png](https://www.rayzs.de/proantitab/assets/example1.png)
</details>
<details>
<summary>example 2</summary>
```yaml
cancel-blocked-commands:
enabled: true
message: '&cThis command is blocked! <click:suggest_command:/help>&7Click here to get a view of all available commands instead.'
```
![https://www.rayzs.de/proantitab/assets/example2.png](https://www.rayzs.de/proantitab/assets/example2.png)
</details>
######
# **H**OW TO SETUP?
Despite of the fact that ProAntiTab is pretty easy to use, the setup is slidely different for each server engine.
It normally is already enough to simply load ProAntiTab on the certain server you wanna use it, but in order to use ProAntiTab with all its features, its recommended to follow the [official setup guide on the Github wiki](https://github.com/RayzsYT/ProAntiTab/wiki/How-to-setup).
**Please feel free to join the [Discord](https://www.rayzs.de/discord) server to request for help if the instruction is unclear or too complicated. ^^**
#
# **H**OW TO ALLOW COMMANDS?
[Please check out the wiki to get an idea on how PAT works and can be used.](https://github.com/RayzsYT/ProAntiTab/wiki/How-to)
If you want to bypass all blocked commands, simply give yourself the following permission: **proantitab.bypass**
Following permission is required to execute all listed commands within a certain group: **proantitab.group.<command>**
######
# **C**OMMANDS & PERMISSIONS
All commands and their permissions are listed on the [documentation](https://www.spigotmc.org/resources/113172/field?field=documentation) page at the very buttom.
######
# **C**ONFIGURATION FILE
<details>
<summary>Bukkit/Spigot</summary>
[config.yml](https://github.com/RayzsYT/ProAntiTab/blob/v2.0.1/src/main/resources/files/bukkit-config.yml)
<br>
[storage.yml](https://github.com/RayzsYT/ProAntiTab/blob/v2.0.1/src/main/resources/files/bukkit-storage.yml)
</details>
<details>
<summary>Proxy (Bungeecord/Velocity)</summary>
[config.yml](https://github.com/RayzsYT/ProAntiTab/blob/v2.0.1/src/main/resources/files/proxy-config.yml)
<br>
[storage.yml](https://github.com/RayzsYT/ProAntiTab/blob/v2.0.1/src/main/resources/files/proxy-storage.yml)
</details>
######
## **bStats**
[![https://bstats.org/signatures/bukkit/ProAntiTab%20-%20Spigot.svg](https://bstats.org/signatures/bukkit/ProAntiTab%20-%20Spigot.svg)](https://bstats.org/plugin/bukkit/proantitab%20-%20spigot/20089)
[![https://bstats.org/signatures/bungeecord/ProAntiTab%20-%20Bungeecord.svg](https://bstats.org/signatures/bungeecord/ProAntiTab%20-%20Bungeecord.svg)](https://bstats.org/plugin/bungeecord/proantitab%20-%20bungeecord/20090)
[![https://bstats.org/signatures/velocity/ProAntiTab%20-%20Velocity.svg](https://bstats.org/signatures/velocity/ProAntiTab%20-%20Velocity.svg)](https://bstats.org/plugin/velocity/proantitab%20-%20velocity/21638)
<center>
[![https://www.rayzs.de/rayzsshield/assets/support.png](https://www.rayzs.de/rayzsshield/assets/support.png)](https://www.rayzs.de/discord)
+30 -28
View File
@@ -6,11 +6,11 @@
<groupId>de.rayzs.pat</groupId>
<artifactId>ProAntiTab</artifactId>
<version>2.0.2</version>
<version>2.3.2</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<repositories>
@@ -72,25 +72,10 @@
<url>https://repo.william278.net/papiproxybridge</url>
</repository>
<repository>
<id>skript-releases</id>
<name>Skript Repository</name>
<url>https://repo.skriptlang.org/releases</url>
</repository>
</repositories>
<dependencies>
<!--
<dependency>
<groupId>org.skriptlang</groupId>
<artifactId>Skript</artifactId>
<version>2.10.1</version>
<scope>provided</scope>
</dependency>
!-->
<dependency>
<groupId>dev.folia</groupId>
<artifactId>folia-api</artifactId>
@@ -115,7 +100,7 @@
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.20-R0.3-SNAPSHOT</version>
<version>1.21-R0.5-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
@@ -134,6 +119,13 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.ElgarL</groupId>
<artifactId>groupmanager</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>brigadier</artifactId>
@@ -200,7 +192,7 @@
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
@@ -235,35 +227,35 @@
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.20.0</version>
<version>4.26.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.20.0</version>
<version>4.26.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-api</artifactId>
<version>4.3.3</version>
<version>4.4.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bungeecord</artifactId>
<version>4.3.4</version>
<version>4.4.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.3.4</version>
<version>4.4.1</version>
<scope>compile</scope>
</dependency>
@@ -284,7 +276,7 @@
<dependency>
<groupId>com.viaversion</groupId>
<artifactId>viaversion-api</artifactId>
<version>LATEST</version>
<version>5.7.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
@@ -299,6 +291,16 @@
<build>
<finalName>IgnoreThisJar</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.txt</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -325,8 +327,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>16</source>
<target>16</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
</plugins>
@@ -7,7 +7,7 @@ import de.rayzs.pat.utils.Reflection;
public class CustomServerBrand {
public static final String CHANNEL_NAME = Reflection.getMinor() < 13 ? "MC|Brand" : "minecraft:brand";
public static final String CHANNEL_NAME = Reflection.isBefore(1, 13) ? "MC|Brand" : "minecraft:brand";
private static final ServerBrand SERVER_BRAND = Reflection.isVelocityServer() ? new VelocityServerBrand() : Reflection.isProxyServer() ? new BungeeServerBrand() : new BukkitServerBrand();
public static void initialize() { refreshTask(); }
@@ -30,7 +30,7 @@ public class BukkitServerBrand implements ServerBrand {
if (Reflection.isWeird()) {
NO_PREP_CHANNELS = Reflection.getMinor() >= 22 || (Reflection.getMinor() == 21 && Reflection.getRelease() >= 7);
NO_PREP_CHANNELS = Reflection.isAtLeast(1, 21, 7);
if (brandPayloadClass == null)
brandPayloadClass = Reflection.getClass("net.minecraft.network.protocol.common.custom.BrandPayload");
@@ -1,41 +1,101 @@
package de.rayzs.pat.api.communication;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.utils.scheduler.*;
import org.bukkit.Bukkit;
public class BackendUpdater {
private BackendUpdater() {}
private static PATSchedulerTask TASK;
private static boolean CONNECTED = false,
WAITING = false;
private static final long SCHEDULER_PERIOD_TIME = 20 * 10;
public static void handle() {
if(isRunning() || !shouldRun() || !Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) return;
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
return;
}
if (isRunning() || !canRun()) {
return;
}
start();
}
public static boolean isRunning() {
return TASK != null && TASK.isActive();
public static void restart() {
stop();
handle();
}
public static void start() {
if(isRunning()) return;
public static void receivedKeepAlivePacket() {
WAITING = false;
CONNECTED = true;
}
public static boolean isConnected() {
return CONNECTED;
}
private static void start() {
if (isRunning()) return;
TASK = PATScheduler.createScheduler(() -> {
if (shouldRun())
Communicator.sendRequest();
else
if (!canRun()) {
stop();
}, 5, 20);
return;
}
if (CONNECTED) {
if (WAITING) {
disconnect();
Communicator.Backend2Proxy.sendIdentityRequest();
return;
}
WAITING = true;
Communicator.Backend2Proxy.sendKeepAliveRequest();
return;
}
Communicator.Backend2Proxy.sendIdentityRequest();
}, 20, SCHEDULER_PERIOD_TIME);
}
public static void stop() {
if(TASK == null || !TASK.isActive()) return;
TASK.cancelTask();
TASK = null;
disconnect();
if (isRunning()) {
TASK.cancelTask();
TASK = null;
}
}
private static boolean shouldRun() {
int onlinePlayerSize = Bukkit.getOnlinePlayers().size();
private static void disconnect() {
CONNECTED = false;
WAITING = false;
}
private static boolean isRunning() {
return TASK != null && TASK.isActive();
}
private static boolean canRun() {
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
return false;
}
final int onlinePlayerSize = Bukkit.getOnlinePlayers().size();
return onlinePlayerSize >= 1;
}
}
@@ -1,6 +1,9 @@
package de.rayzs.pat.api.communication;
import de.rayzs.pat.utils.CommunicationPackets;
public interface Client {
String CHANNEL_NAME = "pat:channel";
void send(Object packet);
void reload();
void send(CommunicationPackets.PATPacket packet);
}
@@ -1,237 +1,356 @@
package de.rayzs.pat.api.communication;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.*;
import java.util.concurrent.TimeUnit;
import de.rayzs.pat.api.communication.client.ClientInfo;
import de.rayzs.pat.api.communication.client.impl.BungeeClientInfo;
import de.rayzs.pat.api.communication.client.impl.VelocityClientInfo;
import de.rayzs.pat.api.communication.impl.BukkitClient;
import de.rayzs.pat.api.communication.impl.BungeeClient;
import de.rayzs.pat.api.communication.impl.VelocityClient;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
import de.rayzs.pat.api.storage.blacklist.impl.GroupBlacklist;
import de.rayzs.pat.plugin.BukkitLoader;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.utils.CommunicationPackets;
import de.rayzs.pat.utils.ExpireCache;
import de.rayzs.pat.utils.Reflection;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.group.TinyGroup;
import de.rayzs.pat.utils.permission.PermissionUtil;
public class Communicator {
private static final Client CLIENT =
Reflection.isVelocityServer() ? new VelocityClient()
: Reflection.isProxyServer() ? new BungeeClient()
: new BukkitClient();
private static final UUID SERVER_ID = UUID.randomUUID();
private static Communicator instance = null;
public static final List<ClientInfo> CLIENTS = new ArrayList<>();
public static void initialize(final Client client) {
if (instance != null) {
Logger.warning("Communicator instance is already initialized!");
return;
}
public static int SERVER_DATA_SYNC_COUNT = 0;
public static long LAST_DATA_UPDATE = System.currentTimeMillis(),
LAST_SENT_REQUEST = 0,
LAST_BUKKIT_SYNC = System.currentTimeMillis();
public static void sendPacket(Object packet) {
CLIENT.send(packet);
instance = new Communicator(client);
}
public static void sendPacket(ClientInfo clientInfo, Object packet) {
clientInfo.sendBytes(CommunicationPackets.convertToBytes(packet));
public static Communicator get() {
return instance;
}
public static void receiveInformation(String serverName, Object packet) {
ClientInfo client = getClientByName(serverName);
if (packet instanceof CommunicationPackets.RequestPacket) {
public static class Backend2Proxy {
CommunicationPackets.RequestPacket requestPacket = (CommunicationPackets.RequestPacket) packet;
private Backend2Proxy() {}
if (!requestPacket.isToken(Storage.TOKEN))
return;
if (client == null) {
client = Reflection.isVelocityServer()
? new VelocityClientInfo(requestPacket.getServerId(), serverName)
: new BungeeClientInfo(requestPacket.getServerId(), serverName);
CLIENTS.add(client);
}
if (!client.compareId(requestPacket.getServerId()))
client.setId(requestPacket.getServerId());
syncData(client.getId());
return;
}
if (packet instanceof CommunicationPackets.ForcePermissionResetPacket) {
if (Reflection.isProxyServer())
return;
CommunicationPackets.ForcePermissionResetPacket permissionResetPacket = (CommunicationPackets.ForcePermissionResetPacket) packet;
if (!permissionResetPacket.isToken(Storage.TOKEN))
return;
if (permissionResetPacket.hasTarget())
PermissionUtil.setPlayerPermissions(permissionResetPacket.getTargetUUID());
else
PermissionUtil.reloadPermissions();
return;
}
if (packet instanceof CommunicationPackets.BackendDataPacket) {
CommunicationPackets.BackendDataPacket backendDataPacket = (CommunicationPackets.BackendDataPacket) packet;
if (!backendDataPacket.isToken(Storage.TOKEN))
return;
Storage.SERVER_NAME = backendDataPacket.getServerName();
return;
}
if (packet instanceof CommunicationPackets.FeedbackPacket) {
CommunicationPackets.FeedbackPacket feedbackPacket = (CommunicationPackets.FeedbackPacket) packet;
if (!feedbackPacket.isToken(Storage.TOKEN))
return;
String serverId = feedbackPacket.getServerId();
if (client == null) {
client = Reflection.isVelocityServer()
? new VelocityClientInfo(feedbackPacket.getServerId(), serverName)
: new BungeeClientInfo(feedbackPacket.getServerId(), serverName);
CLIENTS.add(client);
}
if (!client.compareId(feedbackPacket.getServerId()))
client.setId(feedbackPacket.getServerId());
if (client.hasSentFeedback())
return;
client.setFeedback(true);
client.syncTime();
SERVER_DATA_SYNC_COUNT++;
CommunicationPackets.BackendDataPacket backendDataPacket = new CommunicationPackets.BackendDataPacket(Storage.TOKEN, serverId, serverName);
sendPacket(client, backendDataPacket);
return;
}
if (packet instanceof CommunicationPackets.PacketBundle) {
CommunicationPackets.PacketBundle packetBundle = (CommunicationPackets.PacketBundle) packet;
if (!packetBundle.isToken(Storage.TOKEN) || !packetBundle.isId(SERVER_ID.toString()))
return;
Storage.USE_VELOCITY = packetBundle.isVelocity();
LAST_BUKKIT_SYNC = System.currentTimeMillis();
BukkitLoader.synchronize(packetBundle);
}
}
public static void syncData() {
syncData(null);
}
public static void syncData(String serverId) {
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED)
return;
LAST_DATA_UPDATE = System.currentTimeMillis();
ClientInfo clientInfo;
if(serverId == null) {
SERVER_DATA_SYNC_COUNT = 0;
CLIENTS.forEach(currentClient -> syncData(currentClient.getId()));
return;
} else {
clientInfo = getClientById(serverId);
if (clientInfo != null)
clientInfo.setFeedback(false);
SERVER_DATA_SYNC_COUNT = Math.max(0, SERVER_DATA_SYNC_COUNT -1);
}
CommunicationPackets.CommandsPacket commandsPacket = new CommunicationPackets.CommandsPacket();
CommunicationPackets.GroupsPacket groupsPacket;
CommunicationPackets.PacketBundle bundle;
List<String> commands = new ArrayList<>();
String tempServerName = "";
if (clientInfo != null && clientInfo.getName() != null) {
tempServerName = clientInfo.getName();
if (!Storage.Blacklist.isIgnoredServer(tempServerName))
commands.addAll(Storage.Blacklist.getBlacklist().getCommands());
List<GeneralBlacklist> serverBlacklists = Storage.Blacklist.getServerBlacklists(clientInfo.getName());
serverBlacklists.stream().filter(serverBlacklist ->
serverBlacklist != null && serverBlacklist.getCommands() != null
).forEach(serverBlacklist ->
commands.addAll(serverBlacklist.getCommands())
public static void sendIdentityRequest() {
get().send2Proxy(
new CommunicationPackets.Backend2Proxy.IdentityRequestPacket(get().getId())
);
}
final String serverName = tempServerName;
List<TinyGroup> groups = new ArrayList<>();
TinyGroup tinyGroup;
for (Group group : GroupManager.getGroups()) {
if (groups.stream().anyMatch(cTG -> cTG.getGroupName().equals(group.getGroupName())))
continue;
tinyGroup = new TinyGroup(group.getGroupName(), group.getPriority(), group.getAllCommands(serverName));
for (GroupBlacklist groupBlacklist : group.getAllServerGroupBlacklist(serverName))
tinyGroup.addAll(groupBlacklist.getCommands());
groups.add(tinyGroup);
public static void sendKeepAliveRequest() {
get().send2Proxy(
new CommunicationPackets.Backend2Proxy.KeepAlivePacket()
);
}
groupsPacket = new CommunicationPackets.GroupsPacket(groups);
commandsPacket.setTurnBlacklistToWhitelist(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
commandsPacket.setCommands(commands);
bundle = new CommunicationPackets.PacketBundle(Storage.TOKEN, serverId, commandsPacket, groupsPacket);
clientInfo.sendBytes(CommunicationPackets.convertToBytes(bundle));
PATEventHandler.callSentSyncEvents(bundle, serverName);
}
public static void sendRequest() {
if(System.currentTimeMillis() - LAST_SENT_REQUEST >= 5000) {
LAST_SENT_REQUEST = System.currentTimeMillis();
sendPacket(new CommunicationPackets.RequestPacket(Storage.TOKEN, SERVER_ID.toString()));
public static class Proxy2Backend {
private Proxy2Backend() {}
// Update commands for all players
public static void sendUpdateCommand() {
get().send2AllClients(
new CommunicationPackets.Proxy2Backend.UpdatePacket(null)
);
}
// Update commands for a certain player.
public static void sendUpdateCommand(UUID playerId, String serverName) {
final ClientInfo clientInfo = get().clients.get(serverName);
if (clientInfo == null) return;
clientInfo.send(
new CommunicationPackets.Proxy2Backend.UpdatePacket(playerId)
);
}
public static void sendDataSync() {
Communicator.get().lastSync = System.currentTimeMillis();
Communicator.get().send2AllClients(
Communicator.get().constructDataSyncPacket()
);
}
// Sync data for one server
public static void sendDataSync(String serverName) {
final ClientInfo clientInfo = get().clients.get(serverName);
if (clientInfo == null) return;
clientInfo.send(
Communicator.get().constructDataSyncPacket()
);
}
// Sync data for all registered clients.
public static void sendConsoleMessage(String serverName, String message) {
final ClientInfo clientInfo = get().clients.get(serverName);
if (clientInfo == null) return;
clientInfo.send(
new CommunicationPackets.Proxy2Backend.ConsoleMessagePacket(message)
);
}
public static void sendExecutePlayerCommand(String serverName, UUID playerId, String command) {
final ClientInfo clientInfo = get().clients.get(serverName);
if (clientInfo == null) return;
clientInfo.send(
new CommunicationPackets.Proxy2Backend.ExecutePlayerCommandPacket(playerId, command)
);
}
public static void sendExecuteConsoleCommand(String serverName, String command) {
final ClientInfo clientInfo = get().clients.get(serverName);
if (clientInfo == null) return;
clientInfo.send(
new CommunicationPackets.Proxy2Backend.ExecuteConsoleCommandPacket(command)
);
}
public static void sendNotification(UUID playerId, String serverName, String command) {
if (!Storage.ConfigSections.Settings.FORWARD_CONSOLE_NOTIFICATIONS.ENABLED) {
return;
}
final ClientInfo clientInfo = get().clients.get(serverName);
if (clientInfo == null) return;
clientInfo.send(
new CommunicationPackets.Proxy2Backend.NotificationPacket(playerId, command)
);
}
}
public static void sendPermissionReset() {
if(Reflection.isProxyServer())
sendPacket(new CommunicationPackets.ForcePermissionResetPacket(Storage.TOKEN));
private final Client client;
private final UUID id = UUID.randomUUID();
// Server name, ClientInfo
private final Map<String, ClientInfo> clients = new HashMap<>();
private final ExpireCache<String, ClientInfo> pendingClients = new ExpireCache<>(2, TimeUnit.SECONDS);
private long lastReceivedKeepAliveResponse = System.currentTimeMillis();
private long lastSync = System.currentTimeMillis();
private Communicator(final Client client) {
this.client = client;
}
public static void sendFeedback() {
sendPacket(new CommunicationPackets.FeedbackPacket(Storage.TOKEN, SERVER_ID.toString()));
// BACKEND -> PROXY
public void handleB2PPacket(String serverName, CommunicationPackets.PATPacket incomingPacket) {
if (!incomingPacket.tokenMatches(Storage.TOKEN)) {
return;
}
if (incomingPacket instanceof CommunicationPackets.Backend2Proxy.KeepAlivePacket packet) {
final ClientInfo clientInfo = clients.get(serverName);
if (clientInfo == null) return;
clientInfo.updateKeepAliveTime();
clientInfo.send(new CommunicationPackets.Proxy2Backend.KeepAliveResponsePacket());
return;
}
if (incomingPacket instanceof CommunicationPackets.Backend2Proxy.IdentityRequestPacket packet) {
final ClientInfo registeredClientInfo = clients.get(serverName);
final boolean exist = registeredClientInfo != null;
final boolean same = exist && registeredClientInfo.getId().equals(packet.serverId());
if (!same) {
final ClientInfo clientInfo = Reflection.isVelocityServer()
? new VelocityClientInfo(packet.serverId(), serverName)
: new BungeeClientInfo(packet.serverId(), serverName);
pendingClients.put(serverName, clientInfo);
clientInfo.send(new CommunicationPackets.Proxy2Backend.IdentityPacket(packet.serverId(), serverName));
} else {
registeredClientInfo.send(new CommunicationPackets.Proxy2Backend.KeepAliveResponsePacket());
registeredClientInfo.send(new CommunicationPackets.Proxy2Backend.IdentityPacket(packet.serverId(), serverName));
}
return;
}
if (incomingPacket instanceof CommunicationPackets.Backend2Proxy.IdentityResponsePacket packet) {
final ClientInfo clientInfo = pendingClients.get(serverName);
if (clientInfo != null && clientInfo.getId().equals(packet.serverId())) {
clientInfo.setId(packet.serverId());
pendingClients.remove(serverName);
clients.put(serverName, clientInfo);
clientInfo.send(new CommunicationPackets.Proxy2Backend.KeepAliveResponsePacket());
clientInfo.send( constructDataSyncPacket() );
clientInfo.updateSyncTime();
}
return;
}
if (incomingPacket instanceof CommunicationPackets.Backend2Proxy.DataSyncReceivedPacket packet) {
final ClientInfo clientInfo = clients.get(serverName);
if (clientInfo == null) return;
clientInfo.updateSyncTime();
}
}
public static Client getClient() {
return CLIENT;
// PROXY -> BACKEND
public void handleP2BPacket(CommunicationPackets.PATPacket incomingPacket) {
if (!incomingPacket.tokenMatches(Storage.TOKEN)) {
return;
}
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.KeepAliveResponsePacket packet) {
lastReceivedKeepAliveResponse = System.currentTimeMillis();
BackendUpdater.receivedKeepAlivePacket();
return;
}
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.IdentityPacket packet) {
Storage.SERVER_NAME = packet.serverName();
send2Proxy(new CommunicationPackets.Backend2Proxy.IdentityResponsePacket(id));
return;
}
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.DataSyncPacket packet) {
lastSync = System.currentTimeMillis();
send2Proxy(new CommunicationPackets.Backend2Proxy.DataSyncReceivedPacket());
BukkitLoader.handleDataSyncPacket(packet);
return;
}
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.UpdatePacket packet) {
BukkitLoader.handleUpdateCommandsPacket(packet);
return;
}
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.NotificationPacket packet) {
BukkitLoader.handleNotificationPacket(packet);
return;
}
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.ConsoleMessagePacket packet) {
BukkitLoader.handleConsoleMessagePacket(packet);
return;
}
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.ExecutePlayerCommandPacket packet) {
BukkitLoader.handlePlayerExecuteCommandPacket(packet);
return;
}
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.ExecuteConsoleCommandPacket packet) {
BukkitLoader.handleConsoleExecuteCommandPacket(packet);
return;
}
}
public static ClientInfo getClientById(String id) {
return CLIENTS.isEmpty() ? null : CLIENTS.stream().filter(client -> client != null && client.compareId(id)).findFirst().orElse(null);
private void send2Proxy(CommunicationPackets.PATPacket packet) {
if (Reflection.isProxyServer()) {
Logger.warning("Cannot send B2P packet as proxy!");
return;
}
client.send(packet);
}
public static ClientInfo getClientByName(String name) {
return CLIENTS.isEmpty() ? null : CLIENTS.stream().filter(client -> client != null && client.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
private void send2Client(ClientInfo clientInfo, CommunicationPackets.PATPacket packet) {
if (!Reflection.isProxyServer()) {
Logger.warning("Cannot send P2B packet as backend!");
return;
}
if (clientInfo == null || Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) {
return;
}
clientInfo.send(packet);
}
private void send2AllClients(CommunicationPackets.PATPacket packet) {
if (!Reflection.isProxyServer()) {
Logger.warning("Cannot send P2B packet as backend!");
return;
}
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) {
return;
}
getClients().forEach(clientInfo -> {
clientInfo.send(packet);
});
}
private CommunicationPackets.Proxy2Backend.DataSyncPacket constructDataSyncPacket() {
return new CommunicationPackets.Proxy2Backend.DataSyncPacket(
new CommunicationPackets.Proxy2Backend.DataSyncPacket.Messages(
Storage.ConfigSections.Messages.PREFIX.PREFIX
),
new CommunicationPackets.Proxy2Backend.DataSyncPacket.AutoLowerCase(
Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.ENABLED
),
new CommunicationPackets.Proxy2Backend.DataSyncPacket.UnknownCommand(
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.ENABLED,
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.MESSAGE
)
);
}
public void reload() {
this.client.reload();
}
public UUID getClientId(String serverName) {
final ClientInfo clientInfo = clients.get(serverName);
if (clientInfo == null) return null;
return clientInfo.getId();
}
public boolean hasConnectedClients() {
return !clients.isEmpty();
}
public Set<ClientInfo> getClients() {
return new HashSet<>(clients.values());
}
public UUID getId() {
return id;
}
public long getLastReceivedKeepAliveResponse() {
return lastReceivedKeepAliveResponse;
}
public long getLastSync() {
return lastSync;
}
}
@@ -1,58 +1,62 @@
package de.rayzs.pat.api.communication.client;
import de.rayzs.pat.utils.CommunicationPackets;
import de.rayzs.pat.utils.TimeConverter;
import java.util.UUID;
public abstract class ClientInfo {
private String id, name;
private UUID id;
private String serverName;
private boolean sentFeedback = false;
private long syncTime = System.currentTimeMillis();
private long syncTime = System.currentTimeMillis(),
keepAliveTime = System.currentTimeMillis();
public ClientInfo(String serverId) {
this.id = serverId;
public ClientInfo(UUID id) {
this.id = id;
}
public ClientInfo(String serverId, String name) {
this.id = serverId;
this.name = name;
public ClientInfo(UUID id, String name) {
this.id = id;
this.serverName = name;
}
public abstract void sendBytes(byte[] bytes);
public abstract void send(CommunicationPackets.PATPacket packet);
public void setName(String name) {
this.name = name;
public void setServerName(String name) {
this.serverName = name;
}
public void setId(String serverId) {
this.id = serverId;
public void setId(UUID id) {
this.id = id;
}
public String getName() {
return name;
public String getServerName() {
return serverName;
}
public boolean compareId(String id) {
return this.id.equals(id);
}
public void syncTime() {
public void updateSyncTime() {
syncTime = System.currentTimeMillis();
}
public String getSyncTime() {
public void updateKeepAliveTime() {
keepAliveTime = System.currentTimeMillis();
}
public boolean isAlive() {
return System.currentTimeMillis() - keepAliveTime > 5000;
}
public String getFormattedSyncTime() {
return TimeConverter.calcAndGetTime(syncTime);
}
public void setFeedback(boolean state) {
this.sentFeedback = state;
public String getFormattedLastReceivedKeepAlivePacketTime() {
return TimeConverter.calcAndGetTime(keepAliveTime);
}
public boolean hasSentFeedback() {
return sentFeedback;
}
public String getId() {
public UUID getId() {
return id;
}
}
@@ -2,25 +2,35 @@ package de.rayzs.pat.api.communication.client.impl;
import de.rayzs.pat.api.communication.client.ClientInfo;
import de.rayzs.pat.api.communication.Client;
import de.rayzs.pat.utils.CommunicationPackets;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import java.util.UUID;
public class BungeeClientInfo extends ClientInfo {
public BungeeClientInfo(String serverId) {
super(serverId);
public BungeeClientInfo(UUID id) {
super(id);
}
public BungeeClientInfo(String serverId, String name) {
super(serverId, name);
public BungeeClientInfo(UUID id, String name) {
super(id, name);
}
@Override
public void sendBytes(byte[] bytes) {
ProxyServer.getInstance().getServers().entrySet().stream().filter(entry ->
entry.getKey().equalsIgnoreCase(getName())
).forEach(entry ->
entry.getValue().sendData(Client.CHANNEL_NAME, bytes)
);
public void send(CommunicationPackets.PATPacket packet) {
final byte[] preparedPacket = CommunicationPackets.preparePacket(packet, getId());
if (preparedPacket == null) {
return;
}
final ServerInfo serverInfo = ProxyServer.getInstance().getServerInfo(getServerName());
if (serverInfo != null) {
serverInfo.sendData(Client.CHANNEL_NAME, preparedPacket);
}
}
}
@@ -1,25 +1,36 @@
package de.rayzs.pat.api.communication.client.impl;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import de.rayzs.pat.api.communication.impl.VelocityClient;
import de.rayzs.pat.api.communication.client.ClientInfo;
import de.rayzs.pat.plugin.VelocityLoader;
import de.rayzs.pat.utils.CommunicationPackets;
import java.util.Optional;
import java.util.UUID;
public class VelocityClientInfo extends ClientInfo {
public VelocityClientInfo(String serverId) {
super(serverId);
public VelocityClientInfo(UUID id) {
super(id);
}
public VelocityClientInfo(String serverId, String name) {
super(serverId, name);
public VelocityClientInfo(UUID id, String name) {
super(id, name);
}
@Override
public void sendBytes(byte[] bytes) {
VelocityLoader.getServer().getAllServers().stream().filter(server ->
server.getServerInfo().getName().equalsIgnoreCase(getName())
).forEach(server ->
server.sendPluginMessage(VelocityClient.getIdentifier(), bytes)
);
public void send(CommunicationPackets.PATPacket packet) {
final byte[] preparedPacket = CommunicationPackets.preparePacket(packet, getId());
if (preparedPacket == null) {
return;
}
final Optional<RegisteredServer> optServer = VelocityLoader.getServer().getServer(getServerName());
optServer.ifPresent(registeredServer -> {
registeredServer.sendPluginMessage(VelocityClient.getIdentifier(), preparedPacket);
});
}
}
@@ -1,5 +1,6 @@
package de.rayzs.pat.api.communication.impl;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.scheduler.PATScheduler;
import org.bukkit.plugin.messaging.PluginMessageListener;
import de.rayzs.pat.utils.CommunicationPackets;
@@ -7,43 +8,96 @@ import de.rayzs.pat.plugin.BukkitLoader;
import de.rayzs.pat.api.communication.*;
import org.bukkit.entity.Player;
import org.bukkit.*;
import java.util.Iterator;
public class BukkitClient implements Client, PluginMessageListener {
private static final Server SERVER = Bukkit.getServer();
private boolean registered = false;
public BukkitClient() {
reload();
}
@Override
public void reload() {
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
if (registered) {
unregister();
}
return;
}
if (!registered) {
register();
}
}
private void register() {
registered = true;
SERVER.getMessenger().registerIncomingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME, this);
SERVER.getMessenger().registerOutgoingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME);
}
private void unregister() {
registered = false;
SERVER.getMessenger().unregisterIncomingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME, this);
SERVER.getMessenger().unregisterOutgoingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME);
}
@Override
public void send(Object packet) {
try {
public void send(CommunicationPackets.PATPacket packet) {
final byte[] preparedPacket = CommunicationPackets.preparePacket(packet);
SERVER.sendPluginMessage(BukkitLoader.getPlugin(), CHANNEL_NAME, CommunicationPackets.convertToBytes(packet));
} catch (Throwable throwable) {
throwable.printStackTrace();
if (preparedPacket == null) {
return;
}
final Player carrier = selectCarrier();
if (carrier == null) {
return;
}
PATScheduler.execute(() -> {
if (!carrier.isOnline()) {
return;
}
try {
carrier.sendPluginMessage(BukkitLoader.getPlugin(), CHANNEL_NAME, preparedPacket);
} catch (Exception exception) {
exception.printStackTrace();
}
}, carrier);
}
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] bytes) {
if (!channel.equals(CHANNEL_NAME))
if (!channel.equals(CHANNEL_NAME)) {
return;
}
try {
Object packetObj = CommunicationPackets.buildFromBytes(bytes);
final Object packetObj = CommunicationPackets.readPacket(bytes);
if (!CommunicationPackets.isPacket(packetObj))
if (!CommunicationPackets.isP2BPacket(packetObj)) {
return;
}
PATScheduler.createScheduler(() -> Communicator.receiveInformation("proxy", packetObj));
PATScheduler.createScheduler(() -> Communicator.get().handleP2BPacket((CommunicationPackets.PATPacket) packetObj));
} catch (Throwable throwable) {
throwable.printStackTrace();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private Player selectCarrier() {
final Iterator<? extends Player> iterator = SERVER.getOnlinePlayers().iterator();
return iterator.hasNext() ? iterator.next() : null;
}
}
@@ -1,5 +1,6 @@
package de.rayzs.pat.api.communication.impl;
import de.rayzs.pat.api.storage.Storage;
import net.md_5.bungee.api.event.PluginMessageEvent;
import de.rayzs.pat.utils.CommunicationPackets;
import net.md_5.bungee.api.connection.Server;
@@ -10,25 +11,39 @@ import de.rayzs.pat.plugin.BungeeLoader;
import de.rayzs.pat.api.communication.*;
import net.md_5.bungee.api.ProxyServer;
import java.util.UUID;
public class BungeeClient implements Client, Listener {
private static final ProxyServer SERVER = ProxyServer.getInstance();
public BungeeClient() {
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) {
return;
}
SERVER.registerChannel(CHANNEL_NAME);
SERVER.getPluginManager().registerListener(BungeeLoader.getPlugin(), this);
}
@Override
public void send(Object packet) {
public void reload() {}
@Override
public void send(CommunicationPackets.PATPacket packet) {
final byte[] preparedPacket = CommunicationPackets.preparePacket(packet);
if (preparedPacket == null) {
return;
}
for (ServerInfo serverInfo : ProxyServer.getInstance().getServers().values()) {
try {
serverInfo.sendData(CHANNEL_NAME, CommunicationPackets.convertToBytes(packet));
} catch (Throwable throwable) {
throwable.printStackTrace();
serverInfo.sendData(CHANNEL_NAME, preparedPacket);
} catch (Exception exception) {
exception.printStackTrace();
}
}
@@ -36,18 +51,26 @@ public class BungeeClient implements Client, Listener {
@EventHandler
public void onQueryReceive(PluginMessageEvent event) {
if (!event.getTag().equalsIgnoreCase(CHANNEL_NAME))
if (!event.getTag().equalsIgnoreCase(CHANNEL_NAME)) {
return;
}
final Server server = (Server) event.getSender();
final String serverName = server.getInfo().getName();
final UUID clientId = Communicator.get().getClientId(serverName);
if (!CommunicationPackets.isInitialPacket(event.getData()) && clientId == null) {
return;
}
try {
Object packetObj = CommunicationPackets.buildFromBytes(event.getData());
if (!CommunicationPackets.isPacket(packetObj))
Object packetObj = CommunicationPackets.readPacket(event.getData(), clientId);
if (!CommunicationPackets.isB2PPacket(packetObj)) {
return;
}
Server server = (Server) event.getSender();
Communicator.receiveInformation(server.getInfo().getName(), packetObj);
Communicator.get().handleB2PPacket(serverName, (CommunicationPackets.PATPacket) packetObj);
} catch (Throwable throwable) {
throwable.printStackTrace();
@@ -3,11 +3,13 @@ package de.rayzs.pat.api.communication.impl;
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.CommunicationPackets;
import com.velocitypowered.api.event.Subscribe;
import de.rayzs.pat.plugin.VelocityLoader;
import de.rayzs.pat.api.communication.*;
import com.velocitypowered.api.proxy.*;
import java.util.UUID;
public class VelocityClient implements Client {
@@ -15,20 +17,33 @@ public class VelocityClient implements Client {
private static final MinecraftChannelIdentifier IDENTIFIER = MinecraftChannelIdentifier.from(CHANNEL_NAME);
public VelocityClient() {
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) {
return;
}
SERVER.getChannelRegistrar().register(IDENTIFIER);
SERVER.getEventManager().register(VelocityLoader.getInstance(), this);
}
@Override
public void send(Object packet) {
public void reload() {}
@Override
public void send(CommunicationPackets.PATPacket packet) {
final byte[] preparedPacket = CommunicationPackets.preparePacket(packet);
if (preparedPacket == null) {
return;
}
for (RegisteredServer registeredServer : SERVER.getAllServers()) {
try {
registeredServer.sendPluginMessage(IDENTIFIER, CommunicationPackets.convertToBytes(packet));
} catch (Throwable throwable) {
throwable.printStackTrace();
registeredServer.sendPluginMessage(IDENTIFIER, preparedPacket);
} catch (Exception exception) {
exception.printStackTrace();
}
}
@@ -36,16 +51,26 @@ public class VelocityClient implements Client {
@Subscribe
public void onQueryReceive(PluginMessageEvent event) {
if (event.getIdentifier() != IDENTIFIER)
if (event.getIdentifier() != IDENTIFIER) {
return;
}
Object packetObj = CommunicationPackets.buildFromBytes(event.getData());
final ServerConnection server = (ServerConnection) event.getSource();
final String serverName = server.getServerInfo().getName();
final UUID clientId = Communicator.get().getClientId(serverName);
if (!CommunicationPackets.isPacket(packetObj))
if (!CommunicationPackets.isInitialPacket(event.getData()) && clientId == null) {
return;
}
Object packetObj = CommunicationPackets.readPacket(event.getData(), clientId);
if (!CommunicationPackets.isB2PPacket(packetObj)) {
return;
}
Communicator.get().handleB2PPacket(serverName, (CommunicationPackets.PATPacket) packetObj);
ServerConnection server = (ServerConnection) event.getSource();
Communicator.receiveInformation(server.getServerInfo().getName(), packetObj);
}
public static MinecraftChannelIdentifier getIdentifier() {
@@ -10,8 +10,8 @@ public class PATEventHandler {
private static List<PATEvent> EVENTS = new ArrayList<>();
public static ExecuteCommandEvent callExecuteCommandEvents(Object senderObj, String command, boolean blocked) {
ExecuteCommandEvent event = EmptyEvent.createEmptyExecuteCommandEvent(senderObj, command, blocked);
public static ExecuteCommandEvent callExecuteCommandEvents(Object senderObj, String command, boolean blocked, boolean notify) {
ExecuteCommandEvent event = EmptyEvent.createEmptyExecuteCommandEvent(senderObj, command, blocked, notify);
for (PATEvent patEvent : EVENTS) {
if(patEvent instanceof ExecuteCommandEvent) {
@@ -88,8 +88,8 @@ public class PATEventHandler {
return event;
}
public static SentSyncEvent callSentSyncEvents(CommunicationPackets.PacketBundle packetBundle, String serverName) {
SentSyncEvent event = EmptyEvent.createEmptySentSyncEvent(packetBundle, serverName);
public static SentSyncEvent callSentSyncEvents(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket, String serverName) {
SentSyncEvent event = EmptyEvent.createEmptySentSyncEvent(dataSyncPacket, serverName);
for (PATEvent patEvent : EVENTS) {
if(patEvent instanceof SentSyncEvent) {
@@ -101,8 +101,8 @@ public class PATEventHandler {
return event;
}
public static ReceiveSyncEvent callReceiveSyncEvents(CommunicationPackets.PacketBundle packetBundle) {
ReceiveSyncEvent event = EmptyEvent.createEmptyReceiveSyncEvent(packetBundle);
public static ReceiveSyncEvent callReceiveSyncEvents(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket) {
ReceiveSyncEvent event = EmptyEvent.createEmptyReceiveSyncEvent(dataSyncPacket);
for (PATEvent patEvent : EVENTS) {
if(patEvent instanceof ReceiveSyncEvent) {
@@ -133,8 +133,8 @@ public class PATEventHandler {
};
}
public static SentSyncEvent createEmptySentSyncEvent(CommunicationPackets.PacketBundle packetBundle, String serverName) {
return new SentSyncEvent(null, packetBundle, serverName) {
public static SentSyncEvent createEmptySentSyncEvent(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket, String serverName) {
return new SentSyncEvent(null, dataSyncPacket, serverName) {
@Override
public void handle(SentSyncEvent event) {
@@ -142,8 +142,8 @@ public class PATEventHandler {
};
}
public static ReceiveSyncEvent createEmptyReceiveSyncEvent(CommunicationPackets.PacketBundle packetBundle) {
return new ReceiveSyncEvent(null, packetBundle) {
public static ReceiveSyncEvent createEmptyReceiveSyncEvent(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket) {
return new ReceiveSyncEvent(null, dataSyncPacket) {
@Override
public void handle(ReceiveSyncEvent event) {
@@ -169,8 +169,8 @@ public class PATEventHandler {
};
}
public static ExecuteCommandEvent createEmptyExecuteCommandEvent(Object senderObj, String command, boolean blocked) {
return new ExecuteCommandEvent(senderObj, command, blocked) {
public static ExecuteCommandEvent createEmptyExecuteCommandEvent(Object senderObj, String command, boolean blocked, boolean notify) {
return new ExecuteCommandEvent(senderObj, command, blocked, notify) {
@Override
public void handle(ExecuteCommandEvent event) {
@@ -5,18 +5,24 @@ import de.rayzs.pat.api.event.PATEvent;
public abstract class ExecuteCommandEvent extends PATEvent<ExecuteCommandEvent> {
private final String command;
private boolean blocked;
private boolean blocked, notify;
public ExecuteCommandEvent() {
super(null);
this.blocked = false;
this.notify = false;
this.command = null;
}
public ExecuteCommandEvent(Object senderObj, String command, boolean blocked) {
public ExecuteCommandEvent(Object senderObj, String command, boolean blocked, boolean notify) {
super(senderObj);
this.blocked = blocked;
this.command = command;
this.notify = notify;
}
public void setDoesNotify(boolean notify) {
this.notify = notify;
}
public String getCommand() {
@@ -27,6 +33,10 @@ public abstract class ExecuteCommandEvent extends PATEvent<ExecuteCommandEvent>
return blocked;
}
public boolean doesNotify() {
return notify;
}
public void setBlocked(boolean blocked) {
this.blocked = blocked;
}
@@ -5,19 +5,19 @@ import de.rayzs.pat.api.event.PATEvent;
public abstract class ReceiveSyncEvent extends PATEvent<ReceiveSyncEvent> {
private final CommunicationPackets.PacketBundle packetBundle;
private final CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket;
public ReceiveSyncEvent() {
super(null);
this.packetBundle = null;
this.dataSyncPacket = null;
}
public ReceiveSyncEvent(Object senderObj, CommunicationPackets.PacketBundle packetBundle) {
public ReceiveSyncEvent(Object senderObj, CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket) {
super(senderObj);
this.packetBundle = packetBundle;
this.dataSyncPacket = dataSyncPacket;
}
public CommunicationPackets.PacketBundle getPacketBundle() {
return packetBundle;
public CommunicationPackets.Proxy2Backend.DataSyncPacket getDataSyncPacket() {
return dataSyncPacket;
}
}
@@ -5,18 +5,18 @@ import de.rayzs.pat.api.event.PATEvent;
public abstract class SentSyncEvent extends PATEvent<SentSyncEvent> {
private final CommunicationPackets.PacketBundle packetBundle;
private final CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket;
private final String serverName;
public SentSyncEvent() {
super(null);
this.packetBundle = null;
this.dataSyncPacket = null;
this.serverName = null;
}
public SentSyncEvent(Object senderObj, CommunicationPackets.PacketBundle packetBundle, String serverName) {
public SentSyncEvent(Object senderObj, CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket, String serverName) {
super(senderObj);
this.packetBundle = packetBundle;
this.dataSyncPacket = dataSyncPacket;
this.serverName = serverName;
}
@@ -24,7 +24,7 @@ public abstract class SentSyncEvent extends PATEvent<SentSyncEvent> {
return serverName;
}
public CommunicationPackets.PacketBundle getPacketBundle() {
return packetBundle;
public CommunicationPackets.Proxy2Backend.DataSyncPacket getDataSyncPacket() {
return dataSyncPacket;
}
}
@@ -8,6 +8,9 @@ import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.ExpireCache;
import de.rayzs.pat.utils.Reflection;
import java.util.concurrent.TimeUnit;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import org.bukkit.entity.Player;
import io.netty.channel.*;
import org.bukkit.Bukkit;
@@ -19,7 +22,10 @@ public class BukkitPacketAnalyzer {
private static final ExpireCache<UUID, Object> SENT_PACKET = new ExpireCache<>(2, TimeUnit.SECONDS);
private static final String HANDLER_NAME = "pat-bukkit-handler", PIPELINE_NAME = "packet_handler";
private static final BukkitPacketHandler PACKET_HANDLER = Reflection.getMinor() >= 16 ? new ModernPacketHandler() : new LegacyPacketHandler();
private static final BukkitPacketHandler PACKET_HANDLER = Reflection.isAtLeast(1, 16) ? new ModernPacketHandler() : new LegacyPacketHandler();
private static final BukkitPacketHandler COMMANDS_NODE_HANDLER = new ModernCommandsNodeHandler();
private static final HashMap<Player, String> PLAYER_INPUT_CACHE = new HashMap<>();
public static void injectAll() {
@@ -42,13 +48,13 @@ public class BukkitPacketAnalyzer {
}
public static boolean inject(Player player) {
if (Storage.USE_VELOCITY)
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
return true;
try {
Channel channel = Reflection.getPlayerChannel(player);
if (channel == null) {
Logger.warning("Failed to inject " + player.getName() + "! Channel is null.");
return false;
}
@@ -57,8 +63,21 @@ public class BukkitPacketAnalyzer {
channel.pipeline().addBefore(BukkitPacketAnalyzer.PIPELINE_NAME, BukkitPacketAnalyzer.HANDLER_NAME, new PacketDecoder(player));
BukkitPacketAnalyzer.INJECTED_PLAYERS.put(player.getUniqueId(), channel);
} catch (Throwable throwable) {
throwable.printStackTrace();
} catch (IndexOutOfBoundsException indexOutOfBoundsException) {
Reflection.toggleInjectionMethod();
boolean success = inject(player);
if (!success) {
Logger.warning("Both injection methods failed! Please report this back to me on my Discord! (https://www.rayzs.de/discord)");
}
return success;
} catch (Exception exception) {
if (!Storage.ConfigSections.Settings.INJECTION_FAILED.SUPPRESS_EXCEPTIONS) {
exception.printStackTrace();
}
return false;
}
@@ -67,7 +86,7 @@ public class BukkitPacketAnalyzer {
}
public static void uninject(UUID uuid) {
if (Storage.USE_VELOCITY)
if (Storage.SEND_CONSOLE_NOTIFICATION)
return;
if (BukkitPacketAnalyzer.INJECTED_PLAYERS.containsKey(uuid)) {
@@ -77,7 +96,7 @@ public class BukkitPacketAnalyzer {
}
public static void uninject(Channel channel) {
if (Storage.USE_VELOCITY)
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
return;
if (channel != null) {
@@ -103,29 +122,35 @@ public class BukkitPacketAnalyzer {
private static class PacketDecoder extends ChannelDuplexHandler {
private final Player player;
private final CommandSender sender;
private PacketDecoder(Player player) {
this.player = player;
this.sender = CommandSenderHandler.from(player);
}
@Override
public void channelRead(ChannelHandlerContext channel, Object packetObj) {
try {
if (packetObj.getClass() != null) {
String packetName = packetObj.getClass().getSimpleName();
if (!packetName.equals("PacketPlayInTabComplete") && !packetName.equals("ServerboundCommandSuggestionPacket")) {
super.channelRead(channel, packetObj);
return;
}
if (!PermissionUtil.hasBypassPermission(player)) {
if (!PACKET_HANDLER.handleIncomingPacket(player, packetObj))
return;
}
if (packetObj.getClass() == null || Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
super.channelRead(channel, packetObj);
return;
}
String packetName = packetObj.getClass().getSimpleName();
if (!packetName.equals("PacketPlayInTabComplete") && !packetName.equals("ServerboundCommandSuggestionPacket")) {
super.channelRead(channel, packetObj);
return;
}
if (!PermissionUtil.hasBypassPermission(sender)) {
if (!PACKET_HANDLER.handleIncomingPacket(player, sender, packetObj))
return;
}
super.channelRead(channel, packetObj);
} catch (Throwable exception) { exception.printStackTrace(); }
}
@@ -134,32 +159,41 @@ public class BukkitPacketAnalyzer {
public void write(ChannelHandlerContext channel, Object packetObj, ChannelPromise promise) {
try {
if(packetObj.getClass() != null) {
String packetName = packetObj.getClass().getSimpleName();
if(packetObj.getClass() == null || Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
super.write(channel, packetObj, promise);
return;
}
if (!packetName.equals("PacketPlayOutTabComplete") && !packetName.equals("ClientboundCommandSuggestionsPacket")) {
super.write(channel, packetObj, promise);
final String packetName = packetObj.getClass().getSimpleName();
final boolean isCommandsPacket = packetName.equals("ClientboundCommandsPacket");
final boolean isTabCompletePacket = packetName.equals("PacketPlayOutTabComplete") || packetName.equals("ClientboundCommandSuggestionsPacket");
if (!isCommandsPacket && !isTabCompletePacket || PermissionUtil.hasBypassPermission(sender)) {
super.write(channel, packetObj, promise);
return;
}
if (isCommandsPacket) {
COMMANDS_NODE_HANDLER.handleOutgoingPacket(player, sender, packetObj);
super.write(channel, packetObj, promise);
return;
}
UUID uuid = player.getUniqueId();
Object sentPacketObj = SENT_PACKET.get(uuid);
if (sentPacketObj != null) {
if (sentPacketObj == packetObj) {
SENT_PACKET.remove(uuid);
super.write(channel, sentPacketObj, promise);
return;
}
if (!PermissionUtil.hasBypassPermission(player)) {
UUID uuid = player.getUniqueId();
Object sentPacketObj = SENT_PACKET.get(uuid);
if (sentPacketObj != null) {
if (sentPacketObj == packetObj) {
SENT_PACKET.remove(uuid);
super.write(channel, sentPacketObj, promise);
return;
}
}
if (!PACKET_HANDLER.handleOutgoingPacket(player, packetObj))
return;
}
}
if (!PACKET_HANDLER.handleOutgoingPacket(player, sender, packetObj))
return;
super.write(channel, packetObj, promise);
} catch (Throwable exception) {
@@ -1,8 +1,9 @@
package de.rayzs.pat.api.netty.bukkit;
import de.rayzs.pat.utils.sender.CommandSender;
import org.bukkit.entity.Player;
public interface BukkitPacketHandler {
boolean handleIncomingPacket(Player player, Object packetObj) throws Exception;
boolean handleOutgoingPacket(Player player, Object packetObj) throws Exception;
boolean handleIncomingPacket(Player player, CommandSender sender, Object packetObj) throws Exception;
boolean handleOutgoingPacket(Player player, CommandSender sender, Object packetObj) throws Exception;
}
@@ -4,8 +4,11 @@ import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.sender.CommandSender;
import org.bukkit.entity.Player;
import de.rayzs.pat.api.event.PATEventHandler;
@@ -13,14 +16,13 @@ import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
import de.rayzs.pat.api.netty.bukkit.BukkitPacketHandler;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.plugin.BukkitLoader;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.utils.Reflection;
public class LegacyPacketHandler implements BukkitPacketHandler {
@Override
public boolean handleIncomingPacket(Player player, Object packetObj) throws Exception {
public boolean handleIncomingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
Field stringField = Reflection.getFirstFieldByType(packetObj.getClass(), "String", Reflection.SearchOption.ENDS);
if(stringField == null) {
Logger.warning("Failed PacketAnalyze process! (#1)");
@@ -33,76 +35,82 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
}
@Override
public boolean handleOutgoingPacket(Player player, Object packetObj) throws Exception {
String input = BukkitPacketAnalyzer.getPlayerInput(player);
public boolean handleOutgoingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
final String rawInput = BukkitPacketAnalyzer.getPlayerInput(player);
if(input == null)
if(rawInput == null) {
return false;
}
boolean cancelsBeforeHand;
int spaces = 0;
final List<Group> groups = GroupManager.getPlayerGroups(sender);
if (input.startsWith("/")) {
input = input.replace("/", "");
String input = rawInput;
boolean cancelsBeforeHand = false;
if (input.contains(" ")) {
String[] split = input.split(" ");
spaces = split.length;
if (spaces > 0)
input = split[0];
}
if (!input.startsWith("/")) {
return true;
}
cancelsBeforeHand = Storage.Blacklist.canPlayerAccessTab(player, input);
if (!cancelsBeforeHand)
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(input);
} else return true;
input = input.substring(1);
final boolean doesBypassNamespace = Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender);
final boolean spaces = input.contains(" ");
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(input) && !doesBypassNamespace) {
cancelsBeforeHand = true;
}
if (!cancelsBeforeHand && !input.isEmpty()) {
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(sender, groups, StringUtils.getFirstArg(input));
}
if (!cancelsBeforeHand) {
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(input) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input);
}
for (Field field : Reflection.getFields(packetObj)) {
field.setAccessible(true);
Object result = field.get(packetObj);
if (!(result instanceof String[]))
if (!(result instanceof String[])) {
continue;
List<String> newResultList = new ArrayList<>();
String[] tR = (String[]) result;
String tempName;
boolean doesBypassNamespace = Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player);
if (spaces == 0) {
for (String s : tR) {
if (!BukkitLoader.isLoaded())
continue;
if (!s.startsWith("/")) {
newResultList.add(s);
continue;
}
tempName = s.replaceFirst("/", "");
if (!doesBypassNamespace && Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(tempName))
continue;
if (!Storage.Blacklist.canPlayerAccessTab(player, tempName))
newResultList.add(s);
}
} else {
if (!cancelsBeforeHand) {
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), input, Arrays.asList(tR));
if (!filteredTabCompletionEvent.isCancelled()) {
List<String> suggestions = Arrays.stream(tR).filter(s -> filteredTabCompletionEvent.getCompletion().contains(s)).collect(Collectors.toList());
newResultList.addAll(suggestions);
}
}
}
field.set(packetObj, newResultList.toArray(new String[0]));
String[] tR = (String[]) result;
List<String> suggestions = new ArrayList<>(Arrays.asList(tR));
if (spaces) {
if (cancelsBeforeHand) {
suggestions.clear();
field.set(packetObj, suggestions.toArray(new String[0]));
return true;
}
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, new ArrayList<>(suggestions));
if (filteredTabCompletionEvent.isCancelled()) {
suggestions.clear();
} else {
suggestions.removeIf(s -> !filteredTabCompletionEvent.getCompletion().contains(s));
}
} else {
suggestions.removeIf(s -> {
String cpy = s;
if (cpy.startsWith("/")) {
cpy = cpy.substring(1);
}
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(cpy) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(cpy)) {
return false;
}
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, cpy);
});
}
field.set(packetObj, suggestions.toArray(new String[0]));
}
return true;
@@ -0,0 +1,22 @@
package de.rayzs.pat.api.netty.bukkit.handlers;
import de.rayzs.pat.api.netty.bukkit.BukkitPacketHandler;
import de.rayzs.pat.plugin.subarguments.SubArguments;
import de.rayzs.pat.utils.node.BukkitCommandNodeHelper;
import de.rayzs.pat.utils.sender.CommandSender;
import org.bukkit.entity.Player;
public class ModernCommandsNodeHandler implements BukkitPacketHandler {
public boolean handleIncomingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
// Ignored
return true;
}
@Override
public boolean handleOutgoingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
final BukkitCommandNodeHelper helper = new BukkitCommandNodeHelper(packetObj);
SubArguments.handleCommandNode(player.getUniqueId(), helper);
return true;
}
}
@@ -5,6 +5,9 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.sender.CommandSender;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -28,7 +31,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
private static boolean modifiable = true;
@Override
public boolean handleIncomingPacket(Player player, Object packetObj) throws Exception {
public boolean handleIncomingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
Field stringField = Reflection.getFirstFieldByType(packetObj.getClass(), "String", Reflection.SearchOption.ENDS);
if(stringField == null) {
@@ -37,6 +40,8 @@ public class ModernPacketHandler implements BukkitPacketHandler {
}
String text = (String) stringField.get(packetObj);
if (!text.isBlank() && text.charAt(0) != '/') text = '/' + text;
if (Storage.ConfigSections.Settings.PATCH_EXPLOITS.isMalicious(text)) {
MessageTranslator.send(
Bukkit.getConsoleSender(),
@@ -57,13 +62,15 @@ public class ModernPacketHandler implements BukkitPacketHandler {
}
@Override
public boolean handleOutgoingPacket(Player player, Object packetObj) throws Exception {
public boolean handleOutgoingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
Object suggestionObj;
String rawInput = BukkitPacketAnalyzer.getPlayerInput(player), input = rawInput;
if(input == null)
if(input == null) {
return false;
}
final List<Group> groups = GroupManager.getPlayerGroups(sender);
boolean is121Packet = packetObj.getClass().getSimpleName().equals("ClientboundCommandSuggestionsPacket"),
cancelsBeforeHand = false;
@@ -77,7 +84,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
if(spaces > 0) input = split[0];
}
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(player, input);
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(sender, groups, input);
if (!cancelsBeforeHand)
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(input);
@@ -98,7 +105,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
if ((input.isEmpty() || cancelsBeforeHand) && Reflection.isWeird())
return false;
if (spaces >= 1 && cancelsBeforeHand || !BukkitLoader.isLoaded()) {
if (spaces >= 1 && cancelsBeforeHand) {
suggestions.clear();
return true;
}
@@ -106,7 +113,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
if (spaces == 0) {
suggestions.removeIf(suggestion -> {
String command = getSuggestionFromEntry(suggestion);
return !Storage.Blacklist.canPlayerAccessTab(player, command);
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command);
});
return true;
@@ -149,7 +156,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
}
if (Reflection.getMinor() < 17) {
if (Reflection.isBefore(1, 17)) {
Field suggestionsField = Reflection.getFieldsByType(packetObj.getClass(), "Suggestions", Reflection.SearchOption.ENDS).get(0);
if (suggestionsField == null) return false;
suggestionObj = suggestionsField.get(packetObj);
@@ -171,7 +178,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
return false;
}
if(spaces >= 1 && cancelsBeforeHand || !BukkitLoader.isLoaded()) {
if(spaces >= 1 && cancelsBeforeHand) {
suggestions.getList().clear();
return true;
}
@@ -180,7 +187,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
suggestions.getList().removeIf(suggestion -> {
String command = suggestion.getText();
return !Storage.Blacklist.canPlayerAccessTab(player, command);
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command);
});
return true;
@@ -3,35 +3,35 @@ package de.rayzs.pat.api.netty.proxy;
import java.lang.reflect.Field;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.RootCommandNode;
import de.rayzs.pat.api.brand.CustomServerBrand;
import de.rayzs.pat.api.communication.Communicator;
import de.rayzs.pat.api.communication.client.ClientInfo;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.plugin.subarguments.SubArguments;
import de.rayzs.pat.utils.CommandsCache;
import de.rayzs.pat.utils.node.CommandNodeHelper;
import de.rayzs.pat.utils.ExpireCache;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.node.ProxyCommandNodeHelper;
import de.rayzs.pat.utils.Reflection;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.MessageToMessageDecoder;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.protocol.PacketWrapper;
import net.md_5.bungee.protocol.packet.Commands;
import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
public class BungeePacketAnalyzer {
@@ -39,17 +39,20 @@ public class BungeePacketAnalyzer {
private static final String HANDLER_NAME = "pat-bungee-handler", PIPELINE_NAME = "packet-decoder";
private static final HashMap<ProxiedPlayer, Boolean> PLAYER_MODIFIED = new HashMap<>();
private static final HashMap<ProxiedPlayer, String> PLAYER_INPUT_CACHE = new HashMap<>();
private static final com.mojang.brigadier.Command DUMMY_COMMAND = (context) -> 0;
private static final ExpireCache<UUID, String> PLAYER_INPUT_CACHE = new ExpireCache<>(5, TimeUnit.SECONDS);
private static final List<String> PLUGIN_COMMANDS = new ArrayList<>();
private static Class<?> channelWrapperClass, serverConnectionClass;
private static final List<String> PROXY_COMMANDS;
private static List<String> PROXY_COMMANDS;
static {
ProxyCommandNodeHelper.setDefaultSuggestionProvider(Commands.SuggestionRegistry.ASK_SERVER);
loadProxyCommands();
}
public static void loadProxyCommands() {
PROXY_COMMANDS = ProxyServer.getInstance().getPluginManager().getCommands().stream().map(entry -> {
String key = entry.getKey();
return key.startsWith("/") ? key.substring(1) : key;
@@ -100,8 +103,11 @@ public class BungeePacketAnalyzer {
channel.pipeline().addAfter(BungeePacketAnalyzer.PIPELINE_NAME, BungeePacketAnalyzer.HANDLER_NAME, new PacketDecoder(player));
BungeePacketAnalyzer.INJECTED_PLAYERS.put(player, channel);
} catch (Throwable throwable) {
throwable.printStackTrace();
} catch (Exception exception) {
if (!Storage.ConfigSections.Settings.INJECTION_FAILED.SUPPRESS_EXCEPTIONS) {
exception.printStackTrace();
}
return false;
}
@@ -110,7 +116,7 @@ public class BungeePacketAnalyzer {
}
public static void uninject(ProxiedPlayer player) {
BungeePacketAnalyzer.PLAYER_INPUT_CACHE.remove(player);
BungeePacketAnalyzer.PLAYER_INPUT_CACHE.remove(player.getUniqueId());
BungeePacketAnalyzer.PLAYER_MODIFIED.remove(player);
if(BungeePacketAnalyzer.INJECTED_PLAYERS.containsKey(player)) {
@@ -127,33 +133,55 @@ public class BungeePacketAnalyzer {
}
}
public static void setPlayerInput(ProxiedPlayer player, String input) {
PLAYER_INPUT_CACHE.putIgnoreIfContains(player.getUniqueId(), input);
}
public static String getPlayerInput(ProxiedPlayer player) {
String input = PLAYER_INPUT_CACHE.get(player);
PLAYER_INPUT_CACHE.remove(player);
String input = PLAYER_INPUT_CACHE.get(player.getUniqueId());
PLAYER_INPUT_CACHE.remove(player.getUniqueId());
return input;
}
private static void modifyCommands(ProxiedPlayer player, Commands commands) {
ServerInfo serverInfo = player.getServer().getInfo();
String serverName = serverInfo.getName();
private static void modifyCommands(ProxiedPlayer player, CommandSender sender, Commands commands) {
String serverName = sender.getServerName();
CommandNodeHelper helper = new CommandNodeHelper<CommandNode>(commands.getRoot());
final boolean ignore = PermissionUtil.hasBypassPermission(sender) || Storage.Blacklist.isDisabledServer(serverName);
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
ProxyCommandNodeHelper helper = new ProxyCommandNodeHelper<CommandNode>(commands.getRoot());
if (!cache.containsKey(serverName))
cache.put(serverName, new CommandsCache());
CommandsCache commandsCache = cache.get(serverName);
List<String> commandsAsString = new ArrayList<String>(PROXY_COMMANDS);
List<String> commandsAsString = new ArrayList<>(PROXY_COMMANDS);
commandsAsString.addAll(helper.getChildrenNames());
commandsCache.handleCommands(commandsAsString, serverName);
List<String> playerCommands = new ArrayList<>();
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
if (!ignore) {
final List<Group> groups = GroupManager.getPlayerGroups(sender);
helper.removeIf(str -> !playerCommands.contains(str));
final Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
if (!cache.containsKey(serverName)) {
cache.put(serverName, new CommandsCache());
}
final CommandsCache commandsCache = cache.get(serverName);
commandsCache.handleCommands(commandsAsString, serverName);
final List<String> tmpPlayerCommands = commandsCache.getPlayerCommands(commandsAsString, sender, groups, serverName);
if (commands.getRoot().getChildren().size() != 0) {
helper.removeIf(str -> !tmpPlayerCommands.contains(str));
}
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.ALWAYS_TAB_COMPLETABLE) {
Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines().forEach(input -> helper.add(input, false));
}
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.ALWAYS_TAB_COMPLETABLE) {
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines().forEach(input -> helper.add(input, false));
}
playerCommands = tmpPlayerCommands;
}
for (Map.Entry<String, Command> command : ProxyServer.getInstance().getPluginManager().getCommands()) {
@@ -163,41 +191,65 @@ public class BungeePacketAnalyzer {
if (commands.getRoot().getChild(command.getKey()) != null)
continue;
if (!command.getValue().hasPermission(player))
if (!command.getValue().hasPermission(player)) {
continue;
}
String commandName = command.getKey();
commandName = commandName.startsWith("/") ? commandName.substring(1) : commandName;
if (!playerCommands.contains(commandName))
continue;
if (!ignore) {
boolean tabablePluginCommand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(commandName);
boolean tabableVersionCommand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(commandName);
CommandNode dummy = createDummyCommandNode(command.getKey());
if (!tabablePluginCommand && !tabableVersionCommand && !playerCommands.contains(commandName)) {
continue;
}
}
CommandNode dummy = ProxyCommandNodeHelper.createDummyCommandNode(command.getKey());
commands.getRoot().addChild(dummy);
}
// Disabled temporarily
// PROXY_COMMANDS.stream().filter(playerCommands::contains).forEach(helper::add);
// SubArgsModule.handleCommandNode(player.getUniqueId(), helper);
for (String command : PROXY_COMMANDS) {
if (ignore || playerCommands.contains(command)) {
helper.add(command, true);
}
}
if (!ignore) {
SubArguments.handleCommandNode(player.getUniqueId(), helper);
}
}
private static CommandNode createDummyCommandNode(String command) {
return LiteralArgumentBuilder
.literal(command)
.executes(DUMMY_COMMAND)
.then(RequiredArgumentBuilder
.argument("args", (ArgumentType) StringArgumentType.greedyString())
.suggests(Commands.SuggestionRegistry.ASK_SERVER)
.executes(DUMMY_COMMAND))
.build();
public static void sendCommandsPacket() {
if (!Communicator.get().hasConnectedClients()) {
return;
}
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
if (player.getPendingConnection().getVersion() < 754)
continue;
final CommandSender sender = CommandSenderHandler.from(player);
RootCommandNode root = new RootCommandNode();
Commands packet = new Commands(root);
modifyCommands(player, sender, packet);
player.unsafe().sendPacket(packet);
}
}
private static class PacketDecoder extends MessageToMessageDecoder<PacketWrapper> {
private final ProxiedPlayer player;
private final CommandSender sender;
private PacketDecoder(ProxiedPlayer player) {
this.player = player;
this.sender = CommandSenderHandler.from(player);
}
@Override
@@ -207,41 +259,49 @@ public class BungeePacketAnalyzer {
return;
}
if(wrapper.packet instanceof PluginMessage) {
if (wrapper.packet instanceof PluginMessage) {
PluginMessage pluginMessage = (PluginMessage) wrapper.packet;
if(CustomServerBrand.isEnabled() && CustomServerBrand.isBrandTag(pluginMessage.getTag()))
return;
} else if (wrapper.packet instanceof Commands) {
Commands response = (Commands) wrapper.packet;
modifyCommands(player, response);
modifyCommands(player, sender, response);
player.unsafe().sendPacket(response);
return;
/*
} else if (wrapper.packet instanceof TabCompleteResponse) {
TabCompleteResponse response = (TabCompleteResponse) wrapper.packet;
String serverName = player.getServer().getInfo().getName();
if(player.getPendingConnection().getVersion() < 754) {
if(!PermissionUtil.hasBypassPermission(player)) {
System.out.println("damn");
ClientInfo clientInfo = Communicator.getClientByName(player.getServer().getInfo().getName());
if (clientInfo == null || !PLAYER_INPUT_CACHE.containsKey(player))
if (!Storage.Blacklist.isDisabledServer(serverName) && player.getPendingConnection().getVersion() < 754) {
if (!PermissionUtil.hasBypassPermission(player)) {
System.out.println("Further!");
System.out.println("Got: " + PLAYER_INPUT_CACHE.get(player.getUniqueId()));
if (!PLAYER_INPUT_CACHE.contains(player.getUniqueId()))
return;
boolean cancelsBeforeHand = false;
String rawPlayerInput = getPlayerInput(player);
String rawPlayerInput = PLAYER_INPUT_CACHE.get(player.getUniqueId());
int spaces = rawPlayerInput.contains(" ") ? rawPlayerInput.split(" ").length : 0;
String playerInput = StringUtils.getFirstArg(rawPlayerInput),
server = player.getServer().getInfo().getName();
System.out.println("NETTY -> " + playerInput);
if (!playerInput.equals("/")) {
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(player, StringUtils.replaceFirst(playerInput, "/", ""), server);
if (!cancelsBeforeHand)
cancelsBeforeHand = !Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
cancelsBeforeHand = !Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
}
final String cursor = playerInput;
@@ -294,7 +354,7 @@ public class BungeePacketAnalyzer {
player.unsafe().sendPacket(new TabCompleteResponse(response.getCommands()));
}
}
}
}*/
}
list.add(wrapper);
@@ -1,12 +1,11 @@
package de.rayzs.pat.api.netty.proxy;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import com.mojang.brigadier.suggestion.SuggestionProvider;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.packet.AvailableCommandsPacket;
@@ -22,12 +21,18 @@ import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.plugin.VelocityLoader;
import de.rayzs.pat.plugin.listeners.velocity.VelocityBlockCommandListener;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.plugin.subarguments.SubArguments;
import de.rayzs.pat.utils.CommandsCache;
import de.rayzs.pat.utils.PacketUtils;
import de.rayzs.pat.utils.Reflection;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.utils.node.ProxyCommandNodeHelper;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import io.netty.channel.Channel;
import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
@@ -37,6 +42,31 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
public class VelocityPacketAnalyzer {
private static boolean FAILED = false;
static {
try {
final String name = "minecraft:ask_server";
final Object availableCommandsPacket = AvailableCommandsPacket.class.newInstance();
final Class<?> packetInstanceObjClass = availableCommandsPacket.getClass();
for (Class<?> clazz : packetInstanceObjClass.getClasses()) {
if (clazz.getSimpleName().equals("ProtocolSuggestionProvider")) {
final Object suggestionProviderObj = clazz.getConstructor(String.class).newInstance(name);
final SuggestionProvider<?> suggestionProvider = (SuggestionProvider<?>) suggestionProviderObj;
ProxyCommandNodeHelper.setDefaultSuggestionProvider(suggestionProvider);
break;
}
}
} catch (Exception exception) {
exception.printStackTrace();
FAILED = true;
}
}
public static final ConcurrentHashMap<Player, Channel> INJECTED_PLAYERS = new ConcurrentHashMap<>();
private static final String PIPELINE_NAME = "pat-velocity-handler", HANDLER_NAME = "handler";
@@ -73,20 +103,30 @@ public class VelocityPacketAnalyzer {
channel = (Channel) Reflection.getMethodsByName(minecraftConnectionClass, "getChannel").get(0).invoke(minecraftConnectionObj);
if(channel == null) {
if (channel == null) {
Logger.warning("Failed to inject " + player.getUsername() + "! Channel is null.");
return false;
}
if(channel.pipeline().names().contains(VelocityPacketAnalyzer.PIPELINE_NAME))
if (channel.pipeline().names().contains(VelocityPacketAnalyzer.PIPELINE_NAME))
uninject(player);
channel.pipeline().addBefore(VelocityPacketAnalyzer.HANDLER_NAME, VelocityPacketAnalyzer.PIPELINE_NAME, new PacketDecoder(player));
VelocityPacketAnalyzer.INJECTED_PLAYERS.put(player, channel);
} catch (Throwable throwable) {
throwable.printStackTrace();
} catch (NoSuchElementException e) {
Logger.warning("Failed to find 'handler' inside player pipeline! (name=" + player.getUsername() + ", uuid=" + player.getUniqueId() + ", version=" + player.getProtocolVersion() + ", brand=" + player.getClientBrand() + " )");
return false;
} return true;
} catch (Exception exception) {
if (!Storage.ConfigSections.Settings.INJECTION_FAILED.SUPPRESS_EXCEPTIONS) {
exception.printStackTrace();
}
return false;
}
return true;
}
public static void uninject(Player player) {
@@ -114,12 +154,67 @@ public class VelocityPacketAnalyzer {
PLAYER_INPUT_CACHE.put(player, text.toLowerCase());
}
private static void modifyCommands(Player player, CommandSender sender, AvailableCommandsPacket commands) {
if (commands.getRootNode().getChildren().size() == 1
&& player.getProtocolVersion().getProtocol() > 340
&& commands.getRootNode().getChild("args") != null
&& commands.getRootNode().getChild("args").getChildren().isEmpty()) {
return;
}
String serverName = sender.getServerName();
final boolean ignore = PermissionUtil.hasBypassPermission(sender) || Storage.Blacklist.isDisabledServer(serverName);
final ProxyCommandNodeHelper<CommandSource> helper = new ProxyCommandNodeHelper<>(commands.getRootNode());
final List<String> commandsAsString = new ArrayList<>();
commandsAsString.addAll(helper.getChildrenNames());
if (ignore) {
return;
}
final List<Group> groups = GroupManager.getPlayerGroups(sender);
final Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
if (!cache.containsKey(serverName)) {
cache.put(serverName, new CommandsCache());
}
final CommandsCache commandsCache = cache.get(serverName);
commandsCache.handleCommands(commandsAsString, serverName);
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, sender, groups, serverName);
helper.removeIf(str -> {
if (str.equals("args")) {
return false;
}
return !playerCommands.contains(str);
});
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.ALWAYS_TAB_COMPLETABLE) {
Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines().forEach(input -> helper.add(input, false));
}
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.ALWAYS_TAB_COMPLETABLE) {
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines().forEach(input -> helper.add(input, false));
}
SubArguments.handleCommandNode(player.getUniqueId(), helper);
}
private static class PacketDecoder extends ChannelDuplexHandler {
private final Player player;
private final CommandSender sender;
private PacketDecoder(Player player) {
this.player = player;
this.sender = CommandSenderHandler.from(player);
}
@Override
@@ -149,15 +244,12 @@ public class VelocityPacketAnalyzer {
}
}
if (packet instanceof UnsignedPlayerCommandPacket) {
UnsignedPlayerCommandPacket unsignedPlayerCommandPacket = (UnsignedPlayerCommandPacket) packet;
if (packet instanceof UnsignedPlayerCommandPacket unsignedPlayerCommandPacket) {
if (!VelocityBlockCommandListener.handleCommand(player, unsignedPlayerCommandPacket.getCommand()).getResult().isAllowed())
return;
}
if (packet instanceof TabCompleteRequestPacket) {
TabCompleteRequestPacket request = (TabCompleteRequestPacket) msg;
if (packet instanceof TabCompleteRequestPacket request) {
if (request.getCommand() != null) {
if (Storage.ConfigSections.Settings.PATCH_EXPLOITS.isMalicious(request.getCommand())) {
@@ -180,40 +272,45 @@ public class VelocityPacketAnalyzer {
MinecraftPacket packet = (MinecraftPacket) msg;
if (packet instanceof PluginMessagePacket) {
PluginMessagePacket pluginMessagePacket = (PluginMessagePacket) packet;
if (packet instanceof PluginMessagePacket pluginMessagePacket) {
if(CustomServerBrand.isEnabled() && CustomServerBrand.isBrandTag(pluginMessagePacket.getChannel()) && !player.getCurrentServer().isPresent()) {
PacketUtils.BrandManipulate brandManipulatePacket = CustomServerBrand.createBrandPacket(player);
super.write(ctx, new PluginMessagePacket(pluginMessagePacket.getChannel(), brandManipulatePacket.getByteBuf()), promise);
return;
}
} else if (packet instanceof TabCompleteResponsePacket) {
} else if (packet instanceof TabCompleteResponsePacket response) {
if (!PermissionUtil.hasBypassPermission(player) && player.getCurrentServer().isPresent()) {
TabCompleteResponsePacket response = (TabCompleteResponsePacket) packet;
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
if (Storage.Blacklist.isDisabledServer(serverName)) {
super.write(ctx, msg, promise);
return;
}
if (!PermissionUtil.hasBypassPermission(sender) && player.getCurrentServer().isPresent()) {
final List<Group> groups = GroupManager.getPlayerGroups(sender);
boolean cancelsBeforeHand = false;
String playerInput = getPlayerInput(player), rawPlayerInput = playerInput, server = player.getCurrentServer().get().getServerInfo().getName();
int spaces = 0;
if(playerInput.contains(" ")) {
if (playerInput.contains(" ")) {
String[] split = playerInput.split(" ");
spaces = split.length;
if(spaces > 0) playerInput = split[0];
if (spaces > 0) playerInput = split[0];
}
if(!playerInput.equals("/")) {
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(player, StringUtils.replaceFirst(playerInput, "/", ""), server);
if (!playerInput.equals("/")) {
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(sender, groups, StringUtils.replaceFirst(playerInput, "/", ""), server);
if(!cancelsBeforeHand)
if (!cancelsBeforeHand)
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
}
final String cursor = playerInput;
if (!cursor.startsWith("/") && spaces < 2 && player.getProtocolVersion().getProtocol() >= 754) {
Logger.debug("Player won't receive TabCompleteResponsePacket because the client protocol id is " + player.getProtocolVersion().getProtocol() + "! This doesn't makes sense, that's why.");
return;
}
@@ -223,7 +320,11 @@ public class VelocityPacketAnalyzer {
String command = offer.getText();
if (command.startsWith("/")) command = StringUtils.replaceFirst(command, "/", "");
return !Storage.Blacklist.canPlayerAccessTab(player, command, player.getCurrentServer().get().getServerInfo().getName());
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command)) {
return false;
}
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command, player.getCurrentServer().get().getServerInfo().getName());
});
} else {
if (cancelsBeforeHand) return;
@@ -238,18 +339,39 @@ public class VelocityPacketAnalyzer {
}
response.getOffers().removeIf(offer -> !filteredTabCompletionEvent.getCompletion().contains(offer.getText()));
if (response.getOffers().isEmpty()) return;
}
}
}
} else if (packet instanceof AvailableCommandsPacket) {
} else if (packet instanceof AvailableCommandsPacket commands) {
if (!PermissionUtil.hasBypassPermission(player) && player.getCurrentServer().isPresent()) {
AvailableCommandsPacket commands = (AvailableCommandsPacket) packet;
if (player.getCurrentServer().isPresent()) {
if (!FAILED) {
modifyCommands(player, sender, commands);
super.write(ctx, msg, promise);
return;
}
if (!PermissionUtil.hasBypassPermission(player)) {
super.write(ctx, msg, promise);
return;
}
final String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
if (Storage.Blacklist.isDisabledServer(serverName)) {
super.write(ctx, msg, promise);
return;
}
final List<Group> groups = GroupManager.getPlayerGroups(sender);
if(!commands.getRootNode().getChildren().isEmpty()) {
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
if (!cache.containsKey(serverName))
@@ -264,7 +386,7 @@ public class VelocityPacketAnalyzer {
if (PermissionUtil.hasBypassPermission(player)) return;
final boolean newer = player.getProtocolVersion().getProtocol() > 340;
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, sender, groups, serverName);
if (commands.getRootNode().getChildren().size() == 1 && newer
&& commands.getRootNode().getChild("args") != null
@@ -274,13 +396,17 @@ public class VelocityPacketAnalyzer {
return;
}
commands.getRootNode().getChildren().removeIf(command -> {
commands.getRootNode().getChildren().removeIf(command -> {
if (command == null || command.getName() == null)
return true;
if (command.getName().equals("args"))
return false;
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command.getName()) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command.getName())) {
return false;
}
return !playerCommands.contains(command.getName());
});
}
@@ -3,44 +3,25 @@ package de.rayzs.pat.api.storage;
import java.util.*;
import java.util.concurrent.TimeUnit;
import de.rayzs.pat.api.brand.CustomServerBrand;
import de.rayzs.pat.api.communication.BackendUpdater;
import de.rayzs.pat.api.communication.Communicator;
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
import de.rayzs.pat.api.storage.config.messages.*;
import de.rayzs.pat.api.storage.config.settings.*;
import de.rayzs.pat.plugin.listeners.bukkit.BukkitAntiTabListener;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.plugin.modules.SubArgsModule;
import de.rayzs.pat.plugin.subarguments.SubArguments;
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.permission.PermissionPlugin;
import de.rayzs.pat.utils.sender.CommandSender;
import org.bukkit.entity.Player;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.api.storage.blacklist.BlacklistCreator;
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
import de.rayzs.pat.api.storage.blacklist.impl.GeneralIgnoredServers;
import de.rayzs.pat.api.storage.config.messages.BlacklistSection;
import de.rayzs.pat.api.storage.config.messages.CommandFailedSection;
import de.rayzs.pat.api.storage.config.messages.GroupSection;
import de.rayzs.pat.api.storage.config.messages.HelpSection;
import de.rayzs.pat.api.storage.config.messages.InfoSection;
import de.rayzs.pat.api.storage.config.messages.NoPermissionSection;
import de.rayzs.pat.api.storage.config.messages.NotificationSection;
import de.rayzs.pat.api.storage.config.messages.OnlyForProxySection;
import de.rayzs.pat.api.storage.config.messages.PermsCheckSection;
import de.rayzs.pat.api.storage.config.messages.PostDebugSection;
import de.rayzs.pat.api.storage.config.messages.PrefixSection;
import de.rayzs.pat.api.storage.config.messages.ReloadSection;
import de.rayzs.pat.api.storage.config.messages.ServerListSection;
import de.rayzs.pat.api.storage.config.messages.StatsSection;
import de.rayzs.pat.api.storage.config.messages.UpdatePermissionsSection;
import de.rayzs.pat.api.storage.config.settings.AutoLowercaseCommandsSection;
import de.rayzs.pat.api.storage.config.settings.BlockNamespaceCommandsSection;
import de.rayzs.pat.api.storage.config.settings.CancelCommandSection;
import de.rayzs.pat.api.storage.config.settings.CustomBrandSection;
import de.rayzs.pat.api.storage.config.settings.CustomPluginsSection;
import de.rayzs.pat.api.storage.config.settings.CustomProtocolPingSection;
import de.rayzs.pat.api.storage.config.settings.CustomUnknownCommandSection;
import de.rayzs.pat.api.storage.config.settings.CustomVersionSection;
import de.rayzs.pat.api.storage.config.settings.DisableSyncSection;
import de.rayzs.pat.api.storage.config.settings.HandleThroughProxySection;
import de.rayzs.pat.api.storage.config.settings.PatchExploitSection;
import de.rayzs.pat.api.storage.config.settings.TurnBlacklistToWhitelistSection;
import de.rayzs.pat.api.storage.config.settings.UpdateSection;
import de.rayzs.pat.api.storage.placeholders.commands.general.ListCommandsPlaceholder;
import de.rayzs.pat.api.storage.placeholders.commands.general.ListReversedCommandsPlaceholder;
import de.rayzs.pat.api.storage.placeholders.commands.general.ListSizeCommandsPlaceholder;
@@ -79,25 +60,49 @@ public class Storage {
public static final List<UUID> NOTIFY_PLAYERS = new ArrayList<>();
public static String TOKEN = "", SERVER_NAME = null, CURRENT_VERSION = "", NEWER_VERSION = "";
public static String TOKEN = "", CENSORED_TOKEN = "", SERVER_NAME = null, CURRENT_VERSION = "", NEWER_VERSION = "";
public static boolean OUTDATED = false, SEND_CONSOLE_NOTIFICATION = true;
public static Object PLUGIN_OBJECT;
public static boolean USE_LUCKPERMS = false, USE_PLACEHOLDERAPI = false, USE_PAPIPROXYBRIDGE = false, USE_VIAVERSION = false, USE_VELOCITY = false, USE_SIMPLECLOUD;
public static long LAST_SYNC = System.currentTimeMillis();
public static boolean USE_PLACEHOLDERAPI = false, USE_PAPIPROXYBRIDGE = false, USE_VIAVERSION = false;
private final static ExpireCache<UUID, String> TEMP_PLAYER_SERVER_CACHE = new ExpireCache<>(1, TimeUnit.SECONDS);
private static PermissionPlugin PERMISSION_PLUGIN = PermissionPlugin.NONE;
public static void initialize(PluginLoader loader, String currentVersion) {
LOADER = loader;
CURRENT_VERSION = currentVersion;
}
public static void setPermissionPlugin(PermissionPlugin permissionPlugin) {
if (PERMISSION_PLUGIN == PermissionPlugin.LUCKPERMS) {
return;
}
PERMISSION_PLUGIN = permissionPlugin;
}
public static void broadcastPermissionsPluginNotice() {
if (Storage.getPermissionPlugin() != PermissionPlugin.NONE) {
return;
}
Logger.warning("No known permissions plugin found, so some features may be disabled.");
Logger.warning("Read more about it here: https://rayzs.de/products/proantitab/nkppf");
}
public static PermissionPlugin getPermissionPlugin() {
return PERMISSION_PLUGIN;
}
public static void loadAll(boolean loadBlacklist) {
loadConfig();
loadToken();
if (TOKEN != null && !TOKEN.isEmpty()) {
int tokenLength = TOKEN.length(), cutIndex = Math.max(1, tokenLength - 3);
String censoredTokenDisplay = "*".repeat(cutIndex) + TOKEN.substring(cutIndex);
Logger.info("Token found! (" + censoredTokenDisplay + ")");
int tokenLength = TOKEN.length(), cutIndex = Math.max(1, tokenLength - 2);
CENSORED_TOKEN = TOKEN.charAt(0) + "*".repeat(cutIndex) + TOKEN.substring(cutIndex);
Logger.info("Token found! (" + CENSORED_TOKEN + ")");
}
if (loadBlacklist) Blacklist.loadAll();
@@ -106,6 +111,7 @@ public class Storage {
}
public static void loadToken() {
Files.TOKEN.reload();
boolean invalidEnv = false;
@@ -161,6 +167,34 @@ public class Storage {
ConfigSections.PLACEHOLDERS.forEach(PlaceholderStorage::load);
}
public static void reload() {
boolean proxy = Reflection.isProxyServer();
boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !proxy;
ConfigUpdater.initialize();
Storage.loadAll(Reflection.isProxyServer() || !backend);
CustomServerBrand.initialize();
GroupManager.clearAllGroups();
GroupManager.initialize();
if (!proxy) {
Communicator.get().reload();
BackendUpdater.restart();
}
if (!backend) {
Storage.handleChange();
}
if (proxy) {
Communicator.Proxy2Backend.sendDataSync();
}
ConfigUpdater.broadcastMissingParts();
Storage.getLoader().handleReload();
}
public static void handleChange() {
handleChange(null);
}
@@ -190,11 +224,11 @@ public class Storage {
associatedServers.forEach(s -> {
List<UUID> playerIds = Storage.getLoader().getPlayerIdsByServer(s);
List<String> commands = new ArrayList<>(SubArgsModule.getServerCommands(s));
List<String> commands = new ArrayList<>(SubArguments.getServerCommands(s));
playerIds.forEach(playerId -> {
List<String> playerCommands = new ArrayList<>(commands);
playerCommands.addAll(SubArgsModule.getGroupCommands(playerId, s));
playerCommands.addAll(SubArguments.getGroupCommands(playerId, s));
PATEventHandler.callUpdatePlayerCommandsEvents(playerId, playerCommands, true);
});
@@ -204,12 +238,14 @@ public class Storage {
} else {
Storage.Blacklist.Experimental.forceCacheReset();
if (isVelocity) {
List<UUID> playerIds = Storage.getLoader().getPlayerIds();
playerIds.forEach(playerId -> {
List<String> playerCommands = new ArrayList<>(SubArgsModule.getServerCommands(playerId));
playerCommands.addAll(SubArgsModule.getGroupCommands(playerId));
List<String> playerCommands = new ArrayList<>(SubArguments.getServerCommands(playerId));
playerCommands.addAll(SubArguments.getGroupCommands(playerId));
PATEventHandler.callUpdatePlayerCommandsEvents(playerId, playerCommands, false);
});
@@ -218,20 +254,55 @@ public class Storage {
}
GroupManager.clearServerGroupBlacklists();
Communicator.syncData();
Storage.getLoader().updateCommandCache();
Communicator.sendPermissionReset();
if (!Reflection.isVelocityServer()) {
BungeePacketAnalyzer.sendCommandsPacket();
}
Communicator.Proxy2Backend.sendUpdateCommand();
return;
}
getLoader().handleReload();
PermissionUtil.reloadPermissions();
if (Reflection.getMinor() >= 13) {
if (Reflection.isBefore(1, 13)) {
final List<UUID> playerIds = Storage.getLoader().getPlayerIds();
final List<String> commands = new ArrayList<>(Blacklist.BLACKLIST.getCommands());
playerIds.forEach(playerId -> {
List<String> playerCommands = new ArrayList<>(commands);
playerCommands.addAll(SubArguments.getGroupCommands(playerId));
PATEventHandler.callUpdatePlayerCommandsEvents(playerId, playerCommands, true);
});
} else {
BukkitAntiTabListener.handleTabCompletion();
}
}
public static void tempCachePlayerToServer(UUID playerId, String server) {
TEMP_PLAYER_SERVER_CACHE.put(playerId, server);
}
public static void getTempCachedPlayerToServer(UUID playerId, String server) {
TEMP_PLAYER_SERVER_CACHE.put(playerId, server);
}
public static String getCachedPlayerServername(UUID playerId) {
return TEMP_PLAYER_SERVER_CACHE.get(playerId);
}
// Quickly updates all player subarguments.
public static void quickSubArgumentUpdate(UUID uuid) {
List<String> playerCommands = new ArrayList<>(SubArguments.getServerCommands(uuid));
playerCommands.addAll(SubArguments.getGroupCommands(uuid));
PATEventHandler.callUpdatePlayerCommandsEvents(uuid, playerCommands, false);
}
public static PluginLoader getLoader() {
return LOADER;
}
@@ -288,18 +359,25 @@ public class Storage {
public static class Settings {
public static AllowGroupOverrulingSection ALLOW_GROUP_OVERRULING = new AllowGroupOverrulingSection();
public static AutoLowercaseCommandsSection AUTO_LOWERCASE_COMMANDS = new AutoLowercaseCommandsSection();
public static BlockNamespaceCommandsSection BLOCK_NAMESPACE_COMMANDS = new BlockNamespaceCommandsSection();
public static HandleThroughProxySection HANDLE_THROUGH_PROXY = new HandleThroughProxySection();
public static InjectionFailedSection INJECTION_FAILED = new InjectionFailedSection();
public static PatchExploitSection PATCH_EXPLOITS = new PatchExploitSection();
public static CustomBrandSection CUSTOM_BRAND = new CustomBrandSection();
public static CancelCommandSection CANCEL_COMMAND = new CancelCommandSection();
public static CustomPluginsSection CUSTOM_PLUGIN = new CustomPluginsSection();
public static CustomVersionSection CUSTOM_VERSION = new CustomVersionSection();
public static DisableSyncSection DISABLE_SYNC = new DisableSyncSection();
public static ForwardConsoleNotificationAlertsSection FORWARD_CONSOLE_NOTIFICATIONS = new ForwardConsoleNotificationAlertsSection();
public static CustomProtocolPingSection CUSTOM_PROTOCOL_PING = new CustomProtocolPingSection();
public static CustomUnknownCommandSection CUSTOM_UNKNOWN_COMMAND = new CustomUnknownCommandSection();
public static TurnBlacklistToWhitelistSection TURN_BLACKLIST_TO_WHITELIST = new TurnBlacklistToWhitelistSection();
public static BaseCommandCaseSensitiveSection BASE_COMMAND_CASE_SENSITIVE = new BaseCommandCaseSensitiveSection();
public static UpdateGroupsPerWorldSection UPDATE_GROUPS_PER_WORLD = new UpdateGroupsPerWorldSection();
public static UpdateGroupsPerServerSection UPDATE_GROUPS_PER_SERVER = new UpdateGroupsPerServerSection();
public static UpdateSection UPDATE = new UpdateSection();
public static void initialize() {}
@@ -310,6 +388,8 @@ public class Storage {
public static PrefixSection PREFIX = new PrefixSection();
public static BlacklistSection BLACKLIST = new BlacklistSection();
public static CommandFailedSection COMMAND_FAILED = new CommandFailedSection();
public static ConvertSection CONVERT = new ConvertSection();
public static ExtractSection EXTRACT = new ExtractSection();
public static GroupSection GROUP = new GroupSection();
public static HelpSection HELP = new HelpSection();
public static InfoSection INFO = new InfoSection();
@@ -384,6 +464,19 @@ public class Storage {
public static class Blacklist {
public static class Experimental {
public static void forceCacheReset() {
for (Object o : CACHED_SERVER_BLACKLIST.getCache().asMap().keySet()) {
String s = (String) o;
clearServerBlacklists(s);
loadCachedServerBlacklists(s);
}
}
}
public enum BlockType {
CHAT("[CMD]"),
TAB("[TAB]"),
@@ -428,14 +521,9 @@ public class Storage {
BLACKLIST.getConfig().getKeys("global.servers", true).forEach(key -> {
GeneralBlacklist blacklist = BlacklistCreator.createGeneralBlacklist(key);
blacklist.load();
SERVER_BLACKLISTS.put(key, blacklist);
});
loadAllCachedServerBlacklists();
}
private static void loadAllCachedServerBlacklists() {
getServers().forEach(Blacklist::loadCachedServerBlacklists);
}
@@ -443,9 +531,7 @@ public class Storage {
List<GeneralBlacklist> blacklists = SERVER_BLACKLISTS.entrySet().stream()
.filter(entry ->
isServer(entry.getKey(), server)
).map(entry ->
entry.getValue()
).toList();
).map(Map.Entry::getValue).toList();
CACHED_SERVER_BLACKLIST.put(server, blacklists);
}
@@ -491,39 +577,62 @@ public class Storage {
return IGNORED_SERVERS.isListed(server);
}
public static boolean canPlayerAccess(Object player, String command, BlockType type) {
return canPlayerAccess(player, command, type, null);
public static boolean canPlayerAccess(CommandSender sender, List<Group> groups, String command, BlockType type) {
return canPlayerAccess(sender, groups, command, type, null);
}
public static boolean canPlayerAccessChat(Object player, String command) {
return canPlayerAccess(player, command, BlockType.CHAT, null);
public static boolean canPlayerAccessChat(CommandSender sender, List<Group> groups, String command) {
return canPlayerAccess(sender, groups, command, BlockType.CHAT, null);
}
public static boolean canPlayerAccessChat(Object player, String command, String server) {
return canPlayerAccess(player, command, BlockType.CHAT, server);
public static boolean canPlayerAccessChat(CommandSender sender, List<Group> groups, String command, String server) {
return canPlayerAccess(sender, groups, command, BlockType.CHAT, server);
}
public static boolean canPlayerAccessTab(Object player, String command) {
return canPlayerAccess(player, command, BlockType.TAB, null);
public static boolean canPlayerAccessTab(CommandSender sender, List<Group> groups, String command) {
return canPlayerAccess(sender, groups, command, BlockType.TAB, null);
}
public static boolean canPlayerAccessTab(Object player, String command, String server) {
return canPlayerAccess(player, command, BlockType.TAB, server);
public static boolean canPlayerAccessTab(CommandSender sender, List<Group> groups, String command, String server) {
return canPlayerAccess(sender, groups, command, BlockType.TAB, server);
}
public static boolean canPlayerAccess(Object player, String command, BlockType type, String server) {
boolean blocked = isBlocked(command, type, server);
public static boolean canPlayerAccess(CommandSender sender, List<Group> groups, String command, BlockType type, String server) {
final boolean allowGroupOverruling = ConfigSections.Settings.ALLOW_GROUP_OVERRULING.ENABLED;
final boolean blocked = isBlocked(command, type, server);
if (allowGroupOverruling) {
GroupManager.AccessResult groupResult = GroupManager.canAccessCommand(groups, command, type, server);
if (groupResult == GroupManager.AccessResult.NEGATED) {
return false;
}
if (!blocked) {
return true;
}
if (Storage.getPermissionPlugin() != PermissionPlugin.NONE) {
if (PermissionUtil.hasBypassPermission(sender, command)) {
return true;
}
}
return groupResult.asBoolean();
}
if (!blocked) {
return true;
}
if (PermissionUtil.hasBypassPermission(player, command)) {
return true;
if (Storage.getPermissionPlugin() != PermissionPlugin.NONE) {
if (PermissionUtil.hasBypassPermission(sender, command)) {
return true;
}
}
return GroupManager.canAccessCommand(player, command, type, server);
return GroupManager.canAccessCommand(groups, command, type, server).asBoolean();
}
public static boolean isBlockedChat(String command) {
@@ -547,31 +656,46 @@ public class Storage {
}
public static boolean isBlocked(String command, BlockType type, String server) {
boolean listed = isListed(command, type, server),
BlockType negation = BlockType.NEGATE;
String negatedCommand = negation + command;
boolean all = isListed("*", type, server),
listed = isListed(command, type, server),
negatedListed = isListed(negatedCommand, type, server),
turn = ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
return !(listed && turn);
if (all) {
// Only listens to negated commands
if (negatedListed) {
return turn;
}
return !turn;
}
return turn != listed;
}
private static boolean isListed(String unmodifiedCommand, BlockType type, String server) {
if (server != null && isDisabledServer(server))
if (server != null && isDisabledServer(server)) {
return false;
}
boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
boolean listed = false;
if (type == BlockType.NEGATE)
turn = !turn;
String command = type.toString() + unmodifiedCommand;
if (server == null || !isIgnoredServer(server))
listed = BLACKLIST.isListed(command, !turn);
if (server == null || !isIgnoredServer(server)) {
listed = BLACKLIST.isListed(command, false);
}
if (server == null) {
if (!listed && type != BlockType.BOTH)
if (!listed && type != BlockType.BOTH) {
return isListed(unmodifiedCommand, BlockType.BOTH, null);
}
return listed;
}
@@ -581,11 +705,11 @@ public class Storage {
blacklists.add(BLACKLIST);
for (GeneralBlacklist blacklist : blacklists) {
if (listed && turn) {
if (listed) {
break;
}
listed = blacklist.isListed(command, turn);
listed = blacklist.isListed(command, false);
}
if (!listed && type != BlockType.BOTH) {
@@ -597,6 +721,19 @@ public class Storage {
public static class BlockTypeFetcher {
public static boolean isNegated(String command) {
if (command.isEmpty()) {
return false;
}
boolean negated = command.charAt(0) == '!';
if (!negated && command.length() > 5)
negated = command.charAt(5) == '!';
return negated;
}
public static BlockType getType(String command) {
for (BlockType blockType : BLOCK_TYPES) {
if (!command.startsWith(blockType.toString()))
@@ -620,6 +757,17 @@ public class Storage {
return command.substring(type.toString().length());
}
// Remove all BlockType elements from String
public static String cleanse(String command) {
BlockType type = getType(command);
if (type == null || type == BlockType.BOTH) {
return command;
}
return modify(command, type);
}
}
}
}
@@ -0,0 +1,25 @@
package de.rayzs.pat.api.storage.config.messages;
import de.rayzs.pat.api.storage.storages.ConfigStorage;
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper;
public class ConvertSection extends ConfigStorage {
public MultipleMessagesHelper MESSAGE;
public ConvertSection() {
super("convert");
}
public String INVALID_CONVERTER, SUCCESS;
@Override
public void load() {
super.load();
INVALID_CONVERTER = new ConfigSectionHelper<String>(this, "converter-not-found", "&cConverter or necessary files could not be found!").getOrSet();
SUCCESS = new ConfigSectionHelper<String>(this, "success", "&aSuccessfully converted &e%converter% &ainto the PAT storage.yml!").getOrSet();
}
}
@@ -0,0 +1,31 @@
package de.rayzs.pat.api.storage.config.messages;
import de.rayzs.pat.api.storage.storages.ConfigStorage;
import de.rayzs.pat.utils.Reflection;
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper;
public class ExtractSection extends ConfigStorage {
public MultipleMessagesHelper MESSAGE;
public ExtractSection() {
super("extract");
}
public String USAGE, PLUGIN_NOT_FOUND, SUCCESS;
@Override
public void load() {
super.load();
if (Reflection.isProxyServer()) {
return;
}
USAGE = new ConfigSectionHelper<String>(this, "usage", "&7Usage: &f/pat extract (plugin) <option> &7or &f(group) <option>").getOrSet();
PLUGIN_NOT_FOUND = new ConfigSectionHelper<String>(this, "plugin-not-found", "&cPlugin %plugin% not found!").getOrSet();
SUCCESS = new ConfigSectionHelper<String>(this, "success", "&aSuccessfully extracted &e%amount% &anew commands from %plugin%!").getOrSet();
}
}
@@ -16,6 +16,7 @@ public class HelpSection extends ConfigStorage {
@Override
public void load() {
super.load();
MESSAGE = new MultipleMessagesHelper(this, null, Reflection.isProxyServer() ?
Arrays.asList(
"&7Available commands are: &f/%label%&7..."
@@ -26,6 +27,8 @@ public class HelpSection extends ConfigStorage {
, "&f postdebug &7to post the PAT logs"
, "&f update <player> &7to update player(s) permissions"
, "&f perms <player> &7to check a player's permissions"
, "&f extract (plugin) &7to extract all plugin commands"
, "&f convert (plugin) &7converts into a PAT storage.yml"
, "&f creategroup (group) &7Create a group"
, "&f deletegroup (group) &7Delete a group"
, "&f setpriority (group) (priority) &7to set the priority"
@@ -44,6 +47,7 @@ public class HelpSection extends ConfigStorage {
, "&f postdebug &7to post the PAT logs"
, "&f update <player> &7to update player(s) permissions"
, "&f perms <player> &7to check a player's permissions"
, "&f extract (plugin) &7to extract all plugin commands"
, "&f creategroup (group) &7Create a group"
, "&f deletegroup (group) &7Delete a group"
, "&f setpriority (group) (priority) &7to set the priority"
@@ -1,12 +1,13 @@
package de.rayzs.pat.api.storage.config.messages;
import de.rayzs.pat.api.storage.storages.ConfigStorage;
import de.rayzs.pat.utils.Reflection;
import de.rayzs.pat.utils.configuration.helper.*;
import java.util.Arrays;
public class InfoSection extends ConfigStorage {
public String VERSION_OUTDATED, VERSION_UPDATED, SYNC_TIME, SYNC_DISABLED;
public String VERSION_OUTDATED, VERSION_UPDATED, SYNC_TIME, SYNC_DISABLED, SYNC_WAITING;
public MultipleMessagesHelper MESSAGE;
public InfoSection() {
@@ -20,6 +21,11 @@ public class InfoSection extends ConfigStorage {
VERSION_UPDATED = new ConfigSectionHelper<String>(this, "version.updated", "&aLatest version").getOrSet();
VERSION_OUTDATED = new ConfigSectionHelper<String>(this, "version.outdated", "&cOutdated (%newest_version%)").getOrSet();
SYNC_TIME = new ConfigSectionHelper<String>(this, "proxy-sync.time", "&e%time%").getOrSet();
if (!Reflection.isProxyServer()) {
SYNC_WAITING = new ConfigSectionHelper<String>(this, "proxy-sync.waiting", "&cWaiting to establish connection...").getOrSet();
}
SYNC_DISABLED = new ConfigSectionHelper<String>(this, "proxy-sync.disabled", "&cDisabled").getOrSet();
MESSAGE = new MultipleMessagesHelper(this, "message",
@@ -28,6 +34,7 @@ public class InfoSection extends ConfigStorage {
, "&7 Version: &e%current_version%"
, "&7 Status: %version_status%"
, "&7 Last sync with proxy: &e%sync_time%"
, "&7 Last received alive packet: %last_alive_response%"
, "&7 Proxy sync-token: &e%token%"
, "&7 Proxy-received server name: &e%sync_server_name%"
)
@@ -18,12 +18,17 @@ public class StatsSection extends ConfigStorage {
@Override
public void load() {
super.load();
if(!Reflection.isProxyServer()) return;
if (!Reflection.isProxyServer()) {
return;
}
NO_SERVER = new ConfigSectionHelper<String>(this, "no-server", "&cNone!").getOrSet();
SPLITTER = new ConfigSectionHelper<String>(this, "message.splitter", "&7, ").getOrSet();
SERVER = new ConfigSectionHelper<String>(this, "message.server", "&f%servername% &8(%updated%)").getOrSet();
SERVER = new ConfigSectionHelper<String>(this, "message.server", "&f%servername% &8(&a%last_alive_response% &8/ &2%updated%&8)").getOrSet();
STATISTIC = new MultipleMessagesHelper(this, "message.statistic", Arrays.asList(
"&7Last sync sent to &f%server_count% &7servers. &8&o(%last_sync_time% ago)",
"&7Format: &eserver (last alive packet / last sync packet)",
"&7Last sync sent to &f%server_count% &7server(s) &e%last_sync_time% &7ago:",
"&7Sent to servers: &f%servers%"
));
}
@@ -0,0 +1,19 @@
package de.rayzs.pat.api.storage.config.settings;
import de.rayzs.pat.api.storage.storages.ConfigStorage;
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
public class AllowGroupOverrulingSection extends ConfigStorage {
public boolean ENABLED;
public AllowGroupOverrulingSection() {
super("allow-group-overruling");
}
@Override
public void load() {
super.load();
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
}
}
@@ -1,11 +1,9 @@
package de.rayzs.pat.api.storage.config.settings;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.api.storage.storages.ConfigStorage;
import de.rayzs.pat.utils.Reflection;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
import de.rayzs.pat.utils.permission.PermissionUtil;
public class AutoLowercaseCommandsSection extends ConfigStorage {
@@ -19,9 +17,6 @@ public class AutoLowercaseCommandsSection extends ConfigStorage {
public void load() {
super.load();
if (Reflection.isProxyServer())
return;
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
}
@@ -30,8 +25,4 @@ public class AutoLowercaseCommandsSection extends ConfigStorage {
return !StringUtils.isLowercased(command);
}
public boolean doesBypass(Object targetObj) {
return !ENABLED || PermissionUtil.hasPermission(targetObj, "auto-lowercase");
}
}
@@ -0,0 +1,22 @@
package de.rayzs.pat.api.storage.config.settings;
import de.rayzs.pat.api.storage.storages.ConfigStorage;
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper;
import java.util.Collections;
public class BaseCommandCaseSensitiveSection extends ConfigStorage {
public boolean ENABLED;
public BaseCommandCaseSensitiveSection() {
super("base-command-case-sensitive");
}
@Override
public void load() {
super.load();
ENABLED = new ConfigSectionHelper<Boolean>(this, null, true).getOrSet();
}
}
@@ -1,14 +1,13 @@
package de.rayzs.pat.api.storage.config.settings;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.api.storage.storages.ConfigStorage;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.utils.sender.CommandSender;
public class BlockNamespaceCommandsSection extends ConfigStorage {
public boolean ENABLED;
public boolean ENABLED, ALWAYS_BLOCK_COMMAND;
public BlockNamespaceCommandsSection() {
super("block-namespace-commands");
@@ -18,15 +17,22 @@ public class BlockNamespaceCommandsSection extends ConfigStorage {
public void load() {
super.load();
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
ALWAYS_BLOCK_COMMAND = new ConfigSectionHelper<Boolean>(this, "always-block-command", true).getOrSet();
}
public boolean doesAlwaysBlock(String command) {
return ALWAYS_BLOCK_COMMAND && isCommand(command);
}
public boolean isCommand(String command) {
if(!ENABLED || Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) return false;
if (!ENABLED) {
return false;
}
return StringUtils.getFirstArg(command).contains(":");
}
public boolean doesBypass(Object targetObj) {
return !ENABLED || PermissionUtil.hasPermission(targetObj, "namespace");
public boolean doesBypass(CommandSender sender) {
return !ENABLED || sender.hasPermission("namespace");
}
}
@@ -1,6 +1,7 @@
package de.rayzs.pat.api.storage.config.settings;
import de.rayzs.pat.api.storage.storages.ConfigStorage;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.configuration.helper.*;
import java.util.*;
@@ -31,13 +32,8 @@ public class CustomPluginsSection extends ConfigStorage {
public boolean isCommand(String command) {
if(!ENABLED) return false;
command = StringUtils.getFirstArg(command);
if (command.contains(" ")) {
String[] split = command.split(" ");
if (split.length > 0)
command = split[0];
command = command.split(" ")[0];
}
for (String currentCommand : COMMANDS.getLines()) {
if (currentCommand.equalsIgnoreCase(command))
return true;
@@ -25,7 +25,7 @@ public class CustomProtocolPingSection extends ConfigStorage {
public void load() {
super.load();
if (!Reflection.isProxyServer() && (!Reflection.isPaper() || Reflection.getMinor() < 12))
if (!Reflection.isProxyServer() && (!Reflection.isPaper() || Reflection.isBefore(1, 12)))
return;
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
@@ -0,0 +1,22 @@
package de.rayzs.pat.api.storage.config.settings;
import de.rayzs.pat.api.storage.storages.ConfigStorage;
import de.rayzs.pat.utils.Reflection;
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
public class ForwardConsoleNotificationAlertsSection extends ConfigStorage {
public boolean ENABLED;
public ForwardConsoleNotificationAlertsSection() {
super("forward-console-notification-alerts");
}
@Override
public void load() {
super.load();
if(!Reflection.isProxyServer()) return;
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
}
}
@@ -6,7 +6,7 @@ import de.rayzs.pat.utils.Reflection;
public class HandleThroughProxySection extends ConfigStorage {
public boolean ENABLED;
public boolean ENABLED, ALLOW_P2B_ACTIONS;
public boolean LOAD_FROM_ENV;
public String ENV_NAME;
@@ -20,12 +20,14 @@ public class HandleThroughProxySection extends ConfigStorage {
@Override
public void load() {
super.load();
if(Reflection.isProxyServer()) return;
if (Reflection.isProxyServer()) return;
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", false).getOrSet();
TOKEN = new ConfigSectionHelper<String>(this, "token", "insert-token-of-proxy-here").getOrSet();
ALLOW_P2B_ACTIONS = new ConfigSectionHelper<Boolean>(this, "allow-p2b-actions", false).getOrSet();
LOAD_FROM_ENV = new ConfigSectionHelper<Boolean>(this, "load-from-env.enabled", false).getOrSet();
ENV_NAME = new ConfigSectionHelper<String>(this, "load-from-env.name", false).getOrSet();
ENV_NAME = new ConfigSectionHelper<String>(this, "load-from-env.name", "PAT_TOKEN").getOrSet();
}
}
@@ -0,0 +1,23 @@
package de.rayzs.pat.api.storage.config.settings;
import de.rayzs.pat.api.storage.storages.ConfigStorage;
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
public class InjectionFailedSection extends ConfigStorage {
public boolean ENABLED, SUPPRESS_EXCEPTIONS;
public String KICK_MESSAGE, CONSOLE_MESSAGE;
public InjectionFailedSection() {
super("injection-failed");
}
@Override
public void load() {
super.load();
ENABLED = new ConfigSectionHelper<Boolean>(this, "kick-on-failure", true).getOrSet();
SUPPRESS_EXCEPTIONS = new ConfigSectionHelper<Boolean>(this, "suppress-exceptions", false).getOrSet();
KICK_MESSAGE = new ConfigSectionHelper<String>(this, "kick-message", "&cInjection process failed! Please reconnect.").getOrSet();
CONSOLE_MESSAGE = new ConfigSectionHelper<String>(this, "console-message", "&cInjection process failed! (%player%)").getOrSet();
}
}
@@ -0,0 +1,24 @@
package de.rayzs.pat.api.storage.config.settings;
import de.rayzs.pat.api.storage.storages.ConfigStorage;
import de.rayzs.pat.utils.Reflection;
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
public class UpdateGroupsPerServerSection extends ConfigStorage {
public boolean ENABLED = false;
public UpdateGroupsPerServerSection() {
super("update-groups-per-server");
}
@Override
public void load() {
super.load();
if (!Reflection.isProxyServer())
return;
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
}
}
@@ -0,0 +1,24 @@
package de.rayzs.pat.api.storage.config.settings;
import de.rayzs.pat.api.storage.storages.ConfigStorage;
import de.rayzs.pat.utils.Reflection;
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
public class UpdateGroupsPerWorldSection extends ConfigStorage {
public boolean ENABLED;
public UpdateGroupsPerWorldSection() {
super("update-groups-per-world");
}
@Override
public void load() {
super.load();
if (Reflection.isProxyServer())
return;
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
}
}
@@ -1,8 +1,6 @@
package de.rayzs.pat.api.storage.storages;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.api.storage.*;
import java.io.Serializable;
@@ -11,36 +9,50 @@ import java.util.*;
public class BlacklistStorage extends StorageTemplate implements Serializable {
private List<String> commands = new ArrayList<>();
private List<String> hiddenCommands = new ArrayList<>();
public BlacklistStorage(String navigatePath) {
super(Storage.Files.STORAGE, navigatePath);
}
public boolean isListed(String command) {
return isListed(command, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
return isListed(command, false);
}
public boolean isListed(String command, boolean ignoreCollons) {
if(commands == null) {
public boolean isListed(String command, boolean ignoreColons) {
final boolean caseSensitive = Storage.ConfigSections.Settings.BASE_COMMAND_CASE_SENSITIVE.ENABLED;
final boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
if (commands == null || command.isEmpty()) {
return false;
}
if (commands.contains("*"))
return true;
boolean isNegated = Storage.Blacklist.BlockTypeFetcher.isNegated(command);
for (String listedCommand : commands) {
if(listedCommand == null)
if (!isNegated == turn) {
command = StringUtils.getFirstArg(command);
}
for (String listedCommand : hiddenCommands) {
if (listedCommand == null)
continue;
if (ignoreCollons) {
if (ignoreColons) {
command = StringUtils.getFirstArg(command);
if (command.contains(":"))
command = command.substring(command.indexOf(':'));
}
if (StringUtils.getFirstArg(listedCommand).equalsIgnoreCase(StringUtils.getFirstArg(command)))
if (!isNegated == turn) {
listedCommand = StringUtils.getFirstArg(listedCommand);
}
if (caseSensitive && listedCommand.equals(command)) {
return true;
} else if (!caseSensitive && listedCommand.equalsIgnoreCase(command)) {
return true;
}
}
return false;
@@ -51,14 +63,17 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
}
public BlacklistStorage add(String command) {
if (!commands.contains(command))
if (!commands.contains(command)) {
commands.add(command);
hiddenCommands.add(command);
}
return this;
}
public BlacklistStorage remove(String command) {
commands.remove(command);
hiddenCommands.remove(command);
return this;
}
@@ -71,6 +86,10 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
return commands;
}
public List<String> getHiddenCommands() {
return hiddenCommands;
}
@Override
public void save() {
getConfig().setAndSave(getNavigatePath(), commands);
@@ -79,6 +98,54 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
@Override
public void load() {
getConfig().reload();
commands = (ArrayList<String>) getConfig().getOrSet(getNavigatePath(), commands);
final List<String> tmpCommands = commands != null ? new ArrayList<>(commands) : new ArrayList<>();
final Set<String> pluginListCommands = new HashSet<>(), negatedPluginListCommands = new HashSet<>();
final String pluginCommandPrefix = "plugin=";
final String negatedPluginCommandPrefix = Storage.Blacklist.BlockType.NEGATE + pluginCommandPrefix;
for (String command : tmpCommands) {
if (command.startsWith(pluginCommandPrefix)) {
pluginListCommands.add(command);
}
if (command.startsWith(negatedPluginCommandPrefix)) {
negatedPluginListCommands.add(command);
}
}
tmpCommands.removeAll(pluginListCommands);
tmpCommands.removeAll(negatedPluginListCommands);
for (String negatedPluginCommand : negatedPluginListCommands) {
negatedPluginCommand = negatedPluginCommand.substring(negatedPluginCommandPrefix.length());
List<String> pluginCommands = Storage.getLoader().getPluginCommands(negatedPluginCommand, false);
for (String pluginCommand : pluginCommands) {
tmpCommands.remove(pluginCommand);
tmpCommands.add(Storage.Blacklist.BlockType.NEGATE + pluginCommand);
}
}
for (String pluginListCommand : pluginListCommands) {
pluginListCommand = pluginListCommand.substring(pluginCommandPrefix.length());
List<String> pluginCommands = Storage.getLoader().getPluginCommands(pluginListCommand, false);
for (String pluginCommand : pluginCommands) {
final String negated = Storage.Blacklist.BlockType.NEGATE + pluginCommand;
if (!commands.contains(negated) && !tmpCommands.contains(negated)) {
tmpCommands.add(pluginCommand);
}
}
}
hiddenCommands = tmpCommands;
}
}
@@ -17,8 +17,11 @@ public class DisabledServersStorage extends StorageTemplate {
public DisabledServersStorage add(String server) {
server = server.toLowerCase();
if(!servers.contains(server))
if (!servers.contains(server)) {
servers.add(server);
}
return this;
}
@@ -29,7 +32,10 @@ public class DisabledServersStorage extends StorageTemplate {
}
public boolean isListed(String server) {
if(servers.isEmpty()) return false;
if (servers.isEmpty()) {
return false;
}
return Storage.isServer(server, servers);
}
@@ -42,7 +48,11 @@ public class DisabledServersStorage extends StorageTemplate {
@Override
public void load() {
if(!Reflection.isProxyServer()) return;
if (!Reflection.isProxyServer()) {
return;
}
getConfig().reload();
servers = (ArrayList<String>) getConfig().getOrSet(getNavigatePath(), servers);
}
@@ -1,13 +1,16 @@
package de.rayzs.pat.plugin;
import de.rayzs.pat.api.brand.CustomServerBrand;
import de.rayzs.pat.plugin.modules.SubArgsModule;
import de.rayzs.pat.api.communication.impl.BukkitClient;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.plugin.converter.StorageConverter;
import de.rayzs.pat.plugin.subarguments.SubArguments;
import de.rayzs.pat.plugin.process.CommandProcess;
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
import de.rayzs.pat.api.communication.BackendUpdater;
import de.rayzs.pat.utils.adapter.GroupManagerAdapter;
import de.rayzs.pat.utils.configuration.Configurator;
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
import de.rayzs.pat.utils.group.TinyGroup;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.utils.adapter.ViaVersionAdapter;
@@ -16,12 +19,12 @@ import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
import de.rayzs.pat.plugin.commands.BukkitCommand;
import de.rayzs.pat.utils.hooks.PlaceholderHook;
import de.rayzs.pat.plugin.listeners.bukkit.*;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.plugin.metrics.bStats;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.utils.response.action.ActionHandler;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.scheduler.*;
@@ -32,15 +35,22 @@ import org.bukkit.command.*;
import org.bukkit.plugin.*;
import org.bukkit.Bukkit;
import java.util.*;
import java.util.stream.Collectors;
public class BukkitLoader extends JavaPlugin implements PluginLoader {
private static List<String> commands = new ArrayList<>(),
allowedCommands = new ArrayList<>(),
disallowedCommands = new ArrayList<>();
private static Plugin plugin;
private static java.util.logging.Logger logger;
private static boolean loaded = false, checkUpdate = false, suggestions = false;
private static Map<String, Command> commandsMap = null;
private PATSchedulerTask updaterTask;
private final List<String> offlinePlayerNames = new ArrayList<>();
private long lastCommandsLoad = -1;
@Override
public void onLoad() {
Configurator.createResourcedFile("files\\bukkit-config.yml", "config.yml", false);
@@ -54,14 +64,19 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
plugin = this;
logger = getLogger();
for (OfflinePlayer offlinePlayerName : Bukkit.getOfflinePlayers()) {
offlinePlayerNames.add(offlinePlayerName.getName());
}
loadCommandMap();
CommandProcess.initialize();
Reflection.initialize(getServer());
CommandProcess.initialize();
ConfigUpdater.initialize();
Storage.initialize(this, getDescription().getVersion());
VersionComparer.setCurrentVersion(Storage.CURRENT_VERSION);
VersionComparer.get().setCurrentVersion(Storage.CURRENT_VERSION);
Storage.loadAll(true);
@@ -75,20 +90,18 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
PluginManager manager = getServer().getPluginManager();
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
loaded = true;
GroupManager.initialize();
BukkitPacketAnalyzer.injectAll();
} else BackendUpdater.handle();
manager.registerEvents(new BukkitPlayerConnectionListener(), this);
manager.registerEvents(new BukkitPlayerListener(), this);
manager.registerEvents(new BukkitBlockCommandListener(), this);
if (Reflection.getMinor() >= 13) {
suggestions = true;
if (Reflection.isAtLeast(1, 13)) {
manager.registerEvents(new BukkitAntiTabListener(), this);
}
if (Reflection.isPaper() && Reflection.getMinor() >= 12)
if (Reflection.isPaper() && Reflection.isAtLeast(1, 12))
manager.registerEvents(new PaperServerListPing(), this);
registerCommand("proantitab", "pat");
@@ -99,17 +112,32 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
if (getServer().getPluginManager().getPlugin("LuckPerms") != null) {
LuckPermsAdapter.initialize();
Bukkit.getOnlinePlayers().forEach(player -> PermissionUtil.setPlayerPermissions(player.getUniqueId()));
} else {
final Plugin groupManagerPlugin = getServer().getPluginManager().getPlugin("GroupManager");
if (groupManagerPlugin != null) {
GroupManagerAdapter.initialize(groupManagerPlugin);
Bukkit.getOnlinePlayers().forEach(player -> PermissionUtil.setPlayerPermissions(player.getUniqueId()));
}
}
if (getServer().getPluginManager().getPlugin("ViaVersion") != null)
if (getServer().getPluginManager().getPlugin("ViaVersion") != null) {
ViaVersionAdapter.initialize();
}
if (Storage.USE_SIMPLECLOUD)
Logger.warning("Detected SimpleCloud. Therefore, MiniMessages are disabled!");
Storage.broadcastPermissionsPluginNotice();
ConfigUpdater.broadcastMissingParts();
ActionHandler.initialize();
SubArgsModule.initialize();
SubArguments.initialize();
StorageConverter.initialize();
Communicator.initialize(new BukkitClient());
PATScheduler.createScheduler(() -> {
Storage.reload();
loadAllCommands();
});
}
@Override
@@ -128,6 +156,21 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
}
}
@Override
public void handleReload() {
loadAllCommands();
}
@Override
public boolean doesCommandExist(String command) {
if (commandsMap == null)
return false;
loadAllCommands();
return getAllCommands().contains(command);
}
@Override
public Object getConsoleSender() {
return Bukkit.getConsoleSender();
@@ -158,12 +201,15 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
@Override
public boolean doesPlayerExist(String playerName) {
return getOfflinePlayerNames().contains(playerName);
return isPlayerOnline(playerName) || ArrayUtils.containsIgnoreCase(getPlayerNames(), playerName);
}
@Override
public String getPlayerServerName(UUID uuid) {
return null;
final Player player = Bukkit.getPlayer(uuid);
if (player == null) { return null; }
return player.getWorld().getName();
}
@Override
@@ -178,7 +224,7 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
@Override
public List<UUID> getPlayerIds() {
return null;
return Bukkit.getOnlinePlayers().stream().map(Entity::getUniqueId).collect(Collectors.toList());
}
@Override
@@ -188,15 +234,14 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
@Override
public List<String> getOfflinePlayerNames() {
return new ArrayList<>(List.of(Bukkit.getOfflinePlayers())).stream().map(OfflinePlayer::getName).toList();
return offlinePlayerNames;
}
@Override
public List<String> getPlayerNames() {
List<String> playerNames = new ArrayList<>();
List<String> playerNames = new ArrayList<>(offlinePlayerNames);
playerNames.addAll(getOnlinePlayerNames());
playerNames.addAll(getOfflinePlayerNames());
return playerNames;
}
@@ -218,126 +263,168 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
return List.of();
}
@Override
public void delayedPermissionsReload() {
PATScheduler.createScheduler(PermissionUtil::reloadPermissions, 40);
}
public void startUpdaterTask() {
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED) return;
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED)
return;
updaterTask = PATScheduler.createAsyncScheduler(() -> {
String result = new ConnectionBuilder().setUrl("https://www.rayzs.de/proantitab/api/version.php")
.setProperties("ProAntiTab", "4654").connect().getResponse();
if (result == null)
result = "/";
if (!result.equals("/")) {
Storage.NEWER_VERSION = result;
VersionComparer.setNewestVersion(Storage.NEWER_VERSION);
if (VersionComparer.isDeveloperVersion()) {
updaterTask.cancelTask();
Logger.info("§8[§fPAT | Bukkit§8] §7Please be aware that you are currently using a §bdeveloper §7version of ProAntiTab. Bugs, errors and a lot of debug messages might be included.");
} else if (!checkUpdate && (VersionComparer.isNewest() || VersionComparer.isUnreleased())) {
updaterTask.cancelTask();
checkUpdate = true;
if (VersionComparer.isUnreleased()) {
Logger.info("§8[§fPAT | Bukkit§8] §7Please be aware that you are currently using an §eunreleased §7version of ProAntiTab.");
return;
}
Storage.ConfigSections.Settings.UPDATE.UPDATED.getLines().forEach(Logger::warning);
} else if (VersionComparer.isOutdated()) {
updaterTask.cancelTask();
Storage.OUTDATED = true;
Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines().forEach(Logger::warning);
}
} else {
Logger.warning("Failed to connect to plugin page! Version comparison cannot be made. (No internet?)");
}
if (VersionComparer.get().computeComparison())
updaterTask.cancelTask();
}, 20L, 20L * Storage.ConfigSections.Settings.UPDATE.PERIOD);
}
public static void synchronize(CommunicationPackets.PacketBundle packetBundle) {
Storage.LAST_SYNC = System.currentTimeMillis();
Communicator.sendFeedback();
public static void handleNotificationPacket(CommunicationPackets.Proxy2Backend.NotificationPacket packet) {
if (!Storage.SEND_CONSOLE_NOTIFICATION) { return; }
CommunicationPackets.UnknownCommandPacket unknownCommandPacket = packetBundle.getUnknownCommandPacket();
CommunicationPackets.CommandsPacket commandsPacket = packetBundle.getCommandsPacket();
CommunicationPackets.GroupsPacket groupsPacket = packetBundle.getGroupsPacket();
CommunicationPackets.NamespaceCommandsPacket namespaceCommandsPacket = packetBundle.getNamespaceCommandsPacket();
CommunicationPackets.MessagePacket messagePacket = packetBundle.getMessagePacket();
boolean updatedList = false;
if (!messagePacket.getBaseBlockedMessage().getLines().isEmpty())
Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE = messagePacket.getBaseBlockedMessage();
if (!messagePacket.getSubBlockedMessage().getLines().isEmpty())
Storage.ConfigSections.Settings.CANCEL_COMMAND.SUB_COMMAND_RESPONSE = messagePacket.getSubBlockedMessage();
if (!messagePacket.getPrefix().isEmpty())
Storage.ConfigSections.Messages.PREFIX.PREFIX = messagePacket.getPrefix();
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.ENABLED != namespaceCommandsPacket.isEnabled())
Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.ENABLED = namespaceCommandsPacket.isEnabled();
if (commandsPacket.getCommands() == null || commandsPacket.getCommands().isEmpty())
Storage.Blacklist.getBlacklist().setList(new ArrayList<>());
else if (!ArrayUtils.compareStringArrays(Storage.Blacklist.getBlacklist().getCommands(), commandsPacket.getCommands())) {
updatedList = true;
Storage.Blacklist.getBlacklist().setList(commandsPacket.getCommands());
final Player player = Bukkit.getPlayer(packet.playerId());
if (player == null) {
return;
}
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED != commandsPacket.turnBlacklistToWhitelistEnabled())
Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED = commandsPacket.turnBlacklistToWhitelistEnabled();
final List<String> notificationMessage = MessageTranslator.replaceMessageList(
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
"%player%", player.getName(),
"%command%", packet.command(),
"%server%", Storage.SERVER_NAME,
"%world%", player.getWorld().getName());
Map<String, List<String>> cpyCache = new HashMap<>();
GroupManager.getGroups().forEach(group -> {
cpyCache.put(group.getGroupName(), group.getCommands());
});
GroupManager.clearAllGroups();
for (TinyGroup group : groupsPacket.getGroups()) {
List<String> currentExistingList = cpyCache.get(group.getGroupName());
if (
!updatedList
&& currentExistingList != null
&& !ArrayUtils.compareStringArrays(currentExistingList, group.getCommands())
) {
updatedList = true;
}
GroupManager.setGroup(group.getGroupName(), group.getPriority(), group.getCommands());
}
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.MESSAGE = unknownCommandPacket.getMessage();
if (Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.ENABLED != unknownCommandPacket.isEnabled())
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.ENABLED = unknownCommandPacket.isEnabled();
if (!loaded)
loaded = true;
if (Reflection.getMinor() >= 13) {
if (updatedList) {
BukkitAntiTabListener.updateCommands();
Logger.debug("Force server to load all players tab-completion due to received sync!");
}
}
PATEventHandler.callReceiveSyncEvents(packetBundle);
Logger.info(notificationMessage);
}
public static boolean doesCommandExist(String command, boolean replace) {
if (commandsMap == null)
return false;
public static void handleUpdateCommandsPacket(CommunicationPackets.Proxy2Backend.UpdatePacket packet) {
if (Reflection.isBefore(1, 13)) {
return;
}
if (replace) command = StringUtils.replaceFirst(command, "/", "");
return getAllCommands().contains(command);
PATScheduler.createScheduler(() -> {
if (packet.forEveryone()) {
BukkitAntiTabListener.updateCommands();
return;
}
Player player = Bukkit.getPlayer(packet.playerId());
if (player != null) {
BukkitAntiTabListener.updateCommands(player);
}
});
}
public static void handlePlayerExecuteCommandPacket(CommunicationPackets.Proxy2Backend.ExecutePlayerCommandPacket packet) {
if (isP2BDisabled()) return;
final Player player = Bukkit.getPlayer(packet.playerId());
if (player == null) return;
PATScheduler.execute(() -> Bukkit.dispatchCommand(player, packet.command()), player);
}
public static void handleConsoleExecuteCommandPacket(CommunicationPackets.Proxy2Backend.ExecuteConsoleCommandPacket packet) {
if (isP2BDisabled()) return;
PATScheduler.execute(() -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), packet.command()), null);
}
public static void handleConsoleMessagePacket(CommunicationPackets.Proxy2Backend.ConsoleMessagePacket packet) {
if (isP2BDisabled()) return;
Logger.info(packet.message());
}
private static boolean isP2BDisabled() {
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ALLOW_P2B_ACTIONS) {
Logger.warning("P2B actions are currently disabled! You need to enable them manually.");
Logger.warning("For that, go to your 'plugins/ProAntiTab/config.yml' file and enable 'handle-through-proxy -> allow-p2b-actions'.");
return true;
}
return false;
}
public static void handleDataSyncPacket(CommunicationPackets.Proxy2Backend.DataSyncPacket packet) {
Storage.ConfigSections.Messages.PREFIX.PREFIX = packet.messages().prefix();
Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.ENABLED = packet.autoLowerCase().enabled();
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.ENABLED = packet.unknownCommand().enabled();
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.MESSAGE = packet.unknownCommand().message();
PATEventHandler.callReceiveSyncEvents(packet);
}
public static List<String> getAllCommands() {
return new ArrayList<>(commands);
}
public static List<String> getAllowedCommands() {
return new ArrayList<>(allowedCommands);
}
public static List<String> getDisallowedCommands() {
return disallowedCommands;
}
@Override
public List<String> getPluginNames(String format) {
List<String> pluginNames = new ArrayList<>();
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
PluginDescriptionFile description = plugin.getDescription();
pluginNames.add(
format.replace("%n", description.getName())
.replace("%v", description.getVersion())
);
}
return pluginNames;
}
@Override
public List<String> getAllCommands(boolean useColons) {
List<String> commands = new ArrayList<>();
for (Map.Entry<String, Command> entry : BukkitLoader.getCommandsMap().entrySet()) {
if (entry.getKey().toLowerCase().contains(":")) {
String command = entry.getKey().substring(entry.getKey().lastIndexOf(":") + 1);
commands.add(command);
if (useColons) {
commands.add(entry.getKey());
}
}
}
return commands;
}
@Override
public List<String> getPluginCommands(String pluginName, boolean useColons) {
List<String> commands = new ArrayList<>();
if (pluginName.isBlank()) return commands;
pluginName = pluginName.toLowerCase();
for (Map.Entry<String, Command> entry : BukkitLoader.getCommandsMap().entrySet()) {
if (entry.getKey().toLowerCase().startsWith(pluginName + ":")) {
String command = entry.getKey().substring(pluginName.length() + 1);
commands.add(command);
if (useColons) {
commands.add(entry.getKey());
}
}
}
return commands;
}
private void loadCommandMap() {
@@ -348,48 +435,64 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
SimpleCommandMap simpleCommandMap = (SimpleCommandMap) commandMapField.get(Bukkit.getPluginManager());
Field knownCommandsField = SimpleCommandMap.class.getDeclaredField("knownCommands");
knownCommandsField.setAccessible(true);
commandsMap = (Map<String, Command>)knownCommandsField.get(simpleCommandMap);
commandsMap = (Map<String, Command>) knownCommandsField.get(simpleCommandMap);
}
} catch (Throwable ignored) { }
if(commandsMap == null)
if (commandsMap == null) {
Logger.warning("Failed to get server commands!");
}
}
public static List<String> getNotBlockedCommands() {
List<String> commands = new ArrayList<>();
Bukkit.getHelpMap().getHelpTopics().stream()
.filter(topic -> !topic.getName().contains(":") && topic.getName().startsWith("/") && !Storage.Blacklist.getBlacklist().isListed(topic.getName().replaceFirst("/", "")))
.forEach(topic -> commands.add(topic.getName().replaceFirst("/", "")));
return commands;
}
private void loadAllCommands() {
public static List<String> getAllCommands() {
if (commandsMap == null) return getNotBlockedCommands();
if (lastCommandsLoad != -1 && System.currentTimeMillis() - lastCommandsLoad < 1000)
return;
List<String> result = new LinkedList<>();
for (String command : commandsMap.keySet()) if(!result.contains(command)) result.add(command);
List<String> result = new ArrayList<>();
if(Reflection.getMinor() == 20 && Reflection.getRelease() >= 5 || Reflection.getMinor() >= 21)
for (String s : commandsMap.keySet()) {
if (commandsMap.containsKey(s)) {
if (!commandsMap.get(s).getAliases().isEmpty()) {
for (String alias : commandsMap.get(s).getAliases()) {
if (!result.contains(alias)) result.add(alias);
}
if (commandsMap == null) {
result.addAll(
Bukkit.getHelpMap().getHelpTopics().stream()
.map(topic -> {
String name = topic.getName();
} else if (Bukkit.getServer().getCommandAliases().get(s) != null)
for (String alias : Bukkit.getServer().getCommandAliases().get(s))
if (!result.contains(alias)) result.add(alias);
}
if (name.startsWith("/"))
name = name.substring(1);
return name;
}).toList()
);
return;
}
commandsMap.entrySet().forEach(entry -> {
String key = entry.getKey();
Command command = entry.getValue();
result.add(key);
if (!command.getAliases().isEmpty()) {
result.addAll(command.getAliases());
}
});
return result;
boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
List<String> allowedCommands = new ArrayList<>(result).stream().filter(command -> {
boolean contains = Storage.Blacklist.getBlacklist().getCommands().contains(command);
return turn == contains;
}).toList();
lastCommandsLoad = System.currentTimeMillis();
BukkitLoader.commands = result;
BukkitLoader.allowedCommands = allowedCommands;
BukkitLoader.disallowedCommands = commands.stream().filter(command -> !allowedCommands.contains(command)).toList();
}
public static boolean useSuggestions() {
return suggestions;
public static Map<String, Command> getCommandsMap() {
return commandsMap;
}
public static Plugin getPlugin() {
@@ -399,8 +502,4 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
public static java.util.logging.Logger getPluginLogger() {
return logger;
}
public static boolean isLoaded() {
return loaded;
}
}
@@ -2,14 +2,17 @@ package de.rayzs.pat.plugin;
import de.rayzs.pat.api.brand.CustomServerBrand;
import de.rayzs.pat.api.communication.impl.BungeeClient;
import de.rayzs.pat.plugin.converter.StorageConverter;
import de.rayzs.pat.plugin.process.CommandProcess;
import de.rayzs.pat.plugin.modules.SubArgsModule;
import de.rayzs.pat.plugin.subarguments.SubArguments;
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
import de.rayzs.pat.utils.configuration.Configurator;
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
import de.rayzs.pat.api.communication.Communicator;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.utils.response.action.ActionHandler;
import net.md_5.bungee.api.scheduler.ScheduledTask;
import de.rayzs.pat.plugin.commands.BungeeCommand;
@@ -33,7 +36,6 @@ public class BungeeLoader extends Plugin implements PluginLoader {
private static Plugin plugin;
private static java.util.logging.Logger logger;
private static boolean checkUpdate = false;
private static final HashMap<String, CommandsCache> commandsCacheMap = new HashMap<>();
@Override
@@ -49,14 +51,13 @@ public class BungeeLoader extends Plugin implements PluginLoader {
plugin = this;
logger = getLogger();
CommandProcess.initialize();
Reflection.initialize(getProxy());
CommandProcess.initialize();
ConfigUpdater.initialize();
Storage.USE_SIMPLECLOUD = Reflection.doesClassExist("eu.thesimplecloud.plugin.startup.CloudPlugin");
Storage.initialize(this, getDescription().getVersion());
VersionComparer.setCurrentVersion(Storage.CURRENT_VERSION);
VersionComparer.get().setCurrentVersion(Storage.CURRENT_VERSION);
Storage.loadAll(true);
@@ -78,9 +79,6 @@ public class BungeeLoader extends Plugin implements PluginLoader {
startUpdaterTask();
if (!Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED)
ProxyServer.getInstance().getScheduler().schedule(this, Communicator::syncData, 5, TimeUnit.SECONDS);
Storage.PLUGIN_OBJECT = this;
if (manager.getPlugin("LuckPerms") != null)
@@ -91,13 +89,24 @@ public class BungeeLoader extends Plugin implements PluginLoader {
Logger.info("Successfully hooked into PAPIProxyBridge!");
}
if(Storage.USE_SIMPLECLOUD)
Logger.warning("Detected SimpleCloud and therefore MiniMessages by Kyori are disabled!");
BungeePacketAnalyzer.injectAll();
Storage.broadcastPermissionsPluginNotice();
ConfigUpdater.broadcastMissingParts();
ActionHandler.initialize();
SubArguments.initialize();
StorageConverter.initialize();
Communicator.initialize(new BungeeClient());
// Reload proxy commands after 1, 5, and 15 seconds.
for (int i : new Integer[] { 1, 5, 15 }) {
ProxyServer.getInstance().getScheduler().schedule(this, BungeePacketAnalyzer::loadProxyCommands, i, TimeUnit.SECONDS);
}
BungeePacketAnalyzer.injectAll();
ConfigUpdater.broadcastMissingParts();
ActionHandler.initialize();
SubArgsModule.initialize();
}
@Override
@@ -113,6 +122,31 @@ public class BungeeLoader extends Plugin implements PluginLoader {
}
}
@Override
public void handleReload() {
BungeePacketAnalyzer.loadProxyCommands();
}
@Override
public void delayedPermissionsReload() {
getProxy().getScheduler().schedule(this, () -> {
PermissionUtil.reloadPermissions();
Storage.getLoader().updateCommandCache();
Communicator.Proxy2Backend.sendUpdateCommand();
}, 1, TimeUnit.SECONDS);
}
@Override
public boolean doesCommandExist(String command) {
return false;
}
@Override
public List<String> getAllCommands(boolean useColons) {
return List.of();
}
@Override
public Object getConsoleSender() {
return ProxyServer.getInstance().getConsole();
@@ -140,10 +174,16 @@ public class BungeeLoader extends Plugin implements PluginLoader {
@Override
public String getPlayerServerName(UUID uuid) {
final String cachedServerName = Storage.getCachedPlayerServername(uuid);
if (cachedServerName != null) {
return cachedServerName;
}
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
if (player == null || player.getServer() == null || player.getServer().getInfo() == null)
if (player == null || player.getServer() == null || player.getServer().getInfo() == null) {
return null;
}
return player.getServer().getInfo().getName();
}
@@ -225,44 +265,36 @@ public class BungeeLoader extends Plugin implements PluginLoader {
return new ArrayList<>(ProxyServer.getInstance().getServers().keySet().stream().toList());
}
@Override
public List<String> getPluginNames(String format) {
List<String> pluginNames = new ArrayList<>();
for (Plugin plugin : ProxyServer.getInstance().getPluginManager().getPlugins()) {
PluginDescription description = plugin.getDescription();
pluginNames.add(
format.replace("%n", description.getName())
.replace("%v", description.getVersion())
);
}
return pluginNames;
}
@Override
public List<String> getPluginCommands(String pluginName, boolean useColons) {
return List.of();
}
public void startUpdaterTask() {
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED) return;
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED)
return;
updaterTask = getProxy().getScheduler().schedule(this, () -> {
String result = new ConnectionBuilder().setUrl("https://www.rayzs.de/proantitab/api/version.php")
.setProperties("ProAntiTab", "4654").connect().getResponse();
if (result == null)
result = "/";
if (VersionComparer.get().computeComparison())
getProxy().getScheduler().cancel(updaterTask);
if (!result.equals("/")) {
Storage.NEWER_VERSION = result;
VersionComparer.setNewestVersion(Storage.NEWER_VERSION);
if(VersionComparer.isDeveloperVersion()) {
getProxy().getScheduler().cancel(updaterTask);
Logger.info("§8[§fPAT | Proxy§8] §7Please be aware that you are currently using a §bdeveloper §7version of ProAntiTab. Bugs, errors and a lot of debug messages might be included.");
} else if(!checkUpdate && (VersionComparer.isNewest() || VersionComparer.isUnreleased())) {
getProxy().getScheduler().cancel(updaterTask);
checkUpdate = true;
if(VersionComparer.isUnreleased()) {
Logger.info("§8[§fPAT | Proxy§8] §7Please be aware that you are currently using an §eunreleased §7version of ProAntiTab.");
return;
}
checkUpdate = true;
Storage.ConfigSections.Settings.UPDATE.UPDATED.getLines().forEach(Logger::warning);
} else if(VersionComparer.isOutdated()) {
Storage.OUTDATED = true;
Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines().forEach(Logger::warning);
}
} else {
Logger.warning("Failed to connect to plugin page! Version comparison cannot be made. (No internet?)");
}
}, 20L, Storage.ConfigSections.Settings.UPDATE.PERIOD, TimeUnit.MILLISECONDS);
}
@@ -8,8 +8,13 @@ import java.util.UUID;
public interface PluginLoader {
void handleReload();
boolean doesCommandExist(String command);
HashMap<String, CommandsCache> getCommandsCacheMap();
void delayedPermissionsReload();
void updateCommandCache();
List<String> getServerNames();
@@ -35,4 +40,14 @@ public interface PluginLoader {
List<String> getPlayerNames();
List<String> getOnlinePlayerNames();
List<String> getOfflinePlayerNames();
List<String> getAllCommands(boolean useColons);
List<String> getPluginCommands(String pluginName, boolean useColons);
/**
* <pre>
* %n = Plugin name
* %v = Plugin version
*/
List<String> getPluginNames(String format);
}
@@ -5,8 +5,11 @@ import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import de.rayzs.pat.api.brand.CustomServerBrand;
import de.rayzs.pat.api.communication.impl.VelocityClient;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.plugin.modules.SubArgsModule;
import de.rayzs.pat.api.netty.proxy.VelocityPacketAnalyzer;
import de.rayzs.pat.plugin.converter.StorageConverter;
import de.rayzs.pat.plugin.subarguments.SubArguments;
import de.rayzs.pat.plugin.process.CommandProcess;
import de.rayzs.pat.utils.CommandsCache;
import de.rayzs.pat.plugin.metrics.impl.VelocityMetrics;
@@ -21,7 +24,6 @@ import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
import com.velocitypowered.api.proxy.ProxyServer;
import de.rayzs.pat.plugin.listeners.velocity.*;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.ConnectionBuilder;
import de.rayzs.pat.utils.VersionComparer;
import de.rayzs.pat.plugin.logger.Logger;
import com.velocitypowered.api.plugin.*;
@@ -38,9 +40,9 @@ import java.util.*;
@Plugin(name = "ProAntiTab",
id = "proantitab",
version = "2.0.3",
version = "2.3.2",
authors = "Rayzs_YT",
description = "Hide more than just your plugins. Hide almost everything!",
description = "Hides more than just your plugins.",
url = "https://www.rayzs.de/products/proantitab/page",
dependencies = {
@Dependency(id = "luckperms", optional = true),
@@ -58,7 +60,6 @@ public class VelocityLoader implements PluginLoader {
private ScheduledTask updaterTask;
private static final HashMap<String, CommandsCache> commandsCacheMap = new HashMap<>();
private static boolean checkUpdate = false;
@Inject
public VelocityLoader(ProxyServer server, org.slf4j.Logger logger, VelocityMetrics.Factory metricsFactory) {
@@ -79,13 +80,13 @@ public class VelocityLoader implements PluginLoader {
Configurator.createResourcedFile("files\\proxy-placeholders.yml", "placeholders.yml", false);
Configurator.createResourcedFile("files\\proxy-custom-responses.yml", "custom-responses.yml", false);
CommandProcess.initialize();
Reflection.initialize(server);
CommandProcess.initialize();
ConfigUpdater.initialize();
Storage.USE_SIMPLECLOUD = Reflection.doesClassExist("eu.thesimplecloud.plugin.startup.CloudPlugin");
Storage.initialize(this, pluginContainer.getDescription().getVersion().get());
VersionComparer.setCurrentVersion(Storage.CURRENT_VERSION);
VersionComparer.get().setCurrentVersion(Storage.CURRENT_VERSION);
Storage.loadAll(true);
MessageTranslator.initialize();
@@ -95,16 +96,13 @@ public class VelocityLoader implements PluginLoader {
metricsFactory.make(this, 21638);
server.getCommandManager().register("bpat", new VelocityCommand(), "bungeeproantitab");
//server.getEventManager().register(this, new VelocityBlockCommandListener(server));
server.getEventManager().register(this, new VelocityBlockCommandListener());
server.getEventManager().register(this, new VelocityAntiTabListener(server));
server.getEventManager().register(this, new VelocityConnectionListener(server, this));
server.getEventManager().register(this, new VelocityPingListener(server));
startUpdaterTask();
if (!Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED)
server.getScheduler().buildTask(this, Communicator::syncData).delay(5, TimeUnit.SECONDS).schedule();
Storage.PLUGIN_OBJECT = this;
if (server.getPluginManager().getPlugin("luckperms").isPresent())
@@ -115,19 +113,25 @@ public class VelocityLoader implements PluginLoader {
Logger.info("Successfully hooked into PAPIProxyBridge!");
}
if(Storage.USE_SIMPLECLOUD)
Logger.warning("Detected SimpleCloud and therefore MiniMessages by Kyori are disabled!");
Storage.broadcastPermissionsPluginNotice();
ConfigUpdater.broadcastMissingParts();
ActionHandler.initialize();
SubArgsModule.initialize();
SubArguments.initialize();
StorageConverter.initialize();
Communicator.initialize(new VelocityClient());
VelocityPacketAnalyzer.injectAll();
}
public static org.slf4j.Logger getPluginLogger() {
return logger;
}
public static void delayedPermissionsReload() {
@Override
public void delayedPermissionsReload() {
server.getScheduler().buildTask(VelocityLoader.instance, () -> {
PermissionUtil.reloadPermissions();
Storage.getLoader().updateCommandCache();
@@ -137,14 +141,27 @@ public class VelocityLoader implements PluginLoader {
public static void delayedPlayerReload(UUID uuid) {
server.getScheduler().buildTask(VelocityLoader.instance, () -> {
String serverName = Storage.getLoader().getPlayerServerName(uuid);
List<String> commands = new ArrayList<>(SubArgsModule.getServerCommands(serverName));
List<String> commands = new ArrayList<>(SubArguments.getServerCommands(serverName));
commands.addAll(SubArgsModule.getGroupCommands(uuid, serverName));
commands.addAll(SubArguments.getGroupCommands(uuid, serverName));
PATEventHandler.callUpdatePlayerCommandsEvents(uuid, commands, true);
}).delay(1, TimeUnit.SECONDS).schedule();
}
@Override
public void handleReload() {}
@Override
public boolean doesCommandExist(String command) {
return false;
}
@Override
public List<String> getAllCommands(boolean useColons) {
return List.of();
}
@Override
public Object getConsoleSender() {
return server.getConsoleCommandSource();
@@ -201,6 +218,11 @@ public class VelocityLoader implements PluginLoader {
@Override
public String getPlayerServerName(UUID uuid) {
final String cachedServerName = Storage.getCachedPlayerServername(uuid);
if (cachedServerName != null) {
return cachedServerName;
}
Optional<Player> optPlayer = server.getPlayer(uuid);
if (optPlayer.isEmpty())
@@ -209,8 +231,9 @@ public class VelocityLoader implements PluginLoader {
Player player = optPlayer.get();
Optional<ServerConnection> optConnection = player.getCurrentServer();
if (optConnection.isEmpty())
if (optConnection.isEmpty()) {
return null;
}
ServerConnection connection = optConnection.get();
return connection.getServer().getServerInfo().getName();
@@ -267,63 +290,40 @@ public class VelocityLoader implements PluginLoader {
return new ArrayList<>(server.getAllServers().stream().map(registeredServer -> registeredServer.getServerInfo().getName()).toList());
}
@Override
public List<String> getPluginNames(String format) {
List<String> pluginNames = new ArrayList<>();
for (PluginContainer plugin : server.getPluginManager().getPlugins()) {
PluginDescription description = plugin.getDescription();
String pluginName = description.getName().orElse("/");
String version = description.getVersion().orElse("/");
pluginNames.add(
format.replace("%n", pluginName)
.replace("%v", version)
);
}
return pluginNames;
}
@Override
public List<String> getPluginCommands(String pluginName, boolean useColons) {
return List.of();
}
public void startUpdaterTask() {
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED) return;
updaterTask = server.getScheduler().buildTask(this, () -> {
String result = new ConnectionBuilder().setUrl("https://www.rayzs.de/proantitab/api/version.php")
.setProperties("ProAntiTab", "4654").connect().getResponse();
if (result == null)
result = "/";
if (VersionComparer.get().computeComparison())
updaterTask.cancel();
if (!result.equals("/")) {
Storage.NEWER_VERSION = result;
VersionComparer.setNewestVersion(Storage.NEWER_VERSION);
if (VersionComparer.isDeveloperVersion()) {
updaterTask.cancel();
MessageTranslator.send(server.getConsoleCommandSource(), "<dark_gray>[</dark_gray><white>PAT | Proxy</white><dark_gray>]</dark_gray> <gray>Please be aware that you are currently using a</gray> <aqua>developer</aqua> <gray>version of ProAntiTab. Bugs, errors and a lot of debug messages might be included.</gray>");
} else if (!checkUpdate && (VersionComparer.isNewest() || VersionComparer.isUnreleased())) {
updaterTask.cancel();
checkUpdate = true;
if (VersionComparer.isUnreleased()) {
MessageTranslator.send(server.getConsoleCommandSource(), "<dark_gray>[</dark_gray><white>PAT | Proxy</white><dark_gray>]</dark_gray> <gray>Please be aware that you are currently using an</gray> <yellow>unreleased</yellow> <gray>version of ProAntiTab.</gray>");
return;
}
checkUpdate = true;
MessageTranslator.send(server.getConsoleCommandSource(), Storage.ConfigSections.Settings.UPDATE.UPDATED.getLines());
} else if (VersionComparer.isOutdated()) {
Storage.OUTDATED = true;
MessageTranslator.send(server.getConsoleCommandSource(), Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines());
}
} else {
Logger.warning("Failed to connect to plugin page! Version comparison cannot be made. (No internet?)");
}
}).delay(1, TimeUnit.SECONDS).repeat(Storage.ConfigSections.Settings.UPDATE.PERIOD, TimeUnit.SECONDS).schedule();
}
public static String getServerNameByPlayerUUID(UUID uuid) {
Optional<Player> optPlayer = server.getPlayer(uuid);
if(!optPlayer.isPresent()) return null;
Player player = optPlayer.get();
Optional<ServerConnection> optServer = player.getCurrentServer();
if(!optServer.isPresent()) return null;
ServerConnection server = optServer.get();
if(server.getServerInfo() == null) return null;
return server.getServerInfo().getName();
}
public static ProxyServer getServer() {
return server;
}
@@ -0,0 +1,46 @@
package de.rayzs.pat.plugin.converter;
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
import de.rayzs.pat.utils.configuration.ConfigurationBuilder;
import de.rayzs.pat.utils.configuration.Configurator;
import de.rayzs.pat.utils.sender.CommandSender;
import java.io.File;
import java.util.List;
public abstract class Converter {
private final String pluginName, fileName, folderPath;
protected final ConfigurationBuilder config;
public Converter(String pluginName, String folderName, String fileName) {
this.pluginName = pluginName;
this.fileName = fileName;
this.folderPath = "./plugins/" + folderName;
this.config = exists() ? Configurator.get(fileName, folderPath) : null;
}
public String getPluginName() {
return pluginName;
}
public boolean exists() {
return new File(folderPath, fileName + ".yml").exists();
}
protected void applyStorage(BlacklistStorage storage, List<String> commands) {
for (String command : commands) {
boolean exist = command.contains(" ")
? storage.getCommands().contains(command)
: storage.isListed(command);
if (exist) continue;
storage.add(command);
}
storage.save();
}
public abstract void apply(CommandSender sender);
}
@@ -0,0 +1,40 @@
package de.rayzs.pat.plugin.converter;
import de.rayzs.pat.plugin.converter.converters.*;
import org.jetbrains.annotations.NotNull;
import java.util.*;
public class StorageConverter {
private StorageConverter() {}
private static final Map<String, Converter> converters = new HashMap<>();
public static void initialize() {
if (!converters.isEmpty()) {
return;
}
registerConverter(new AdvancedPlHideConverter());
registerConverter(new CommandWhitelistConverter());
registerConverter(new PluginHiderPlus());
registerConverter(new PlHideFree());
registerConverter(new PlHidePro());
}
public static Set<String> getConverters() {
return converters.keySet();
}
public static Converter getConverter(@NotNull String name) {
return converters.get(name);
}
public static void registerConverter(@NotNull Converter converter) {
if (!converter.exists()) return;
converters.putIfAbsent(converter.getPluginName(), converter);
}
}
@@ -0,0 +1,40 @@
package de.rayzs.pat.plugin.converter.converters;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
import de.rayzs.pat.plugin.converter.Converter;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.sender.CommandSender;
import java.util.ArrayList;
import java.util.List;
public class AdvancedPlHideConverter extends Converter {
public AdvancedPlHideConverter() {
super("AdvancedPlHide", "AdvancedPlHide", "config");
}
@Override
public void apply(CommandSender sender) {
List<String> groups = config.getKeys("groups", false).stream().toList();
for (String groupName : groups) {
List<String> commands = (ArrayList<String>) config.get("groups."+ groupName + ".tabcomplete");
BlacklistStorage storage;
if (groupName.equalsIgnoreCase("default")) {
storage = Storage.Blacklist.getBlacklist();
} else {
Group group = GroupManager.registerAndGetGroup(groupName);
storage = group.getGeneralGroupBlacklist();
}
applyStorage(storage, commands);
}
sender.sendMessage("&e&lNotice: &7AdvanedPlHide works based on permissions whether to whitelist or blacklist commands from a group. Due to the fact that this cannot be detected by PAT and formatted in the exact way, all commands have been interpreted as whitelisted commands instead. Also, since PAT groups are only intended to whitelist commands, all created groups based on AdvancedPlHide have been created with the intention of whitelisting commands instead. If you wish to change that, please check out the GitHub wiki on how to use the storage.yml of PAT the intended way. (https://github.com/RayzsYT/ProAntiTab/wiki/How-to#introduction)");
}
}
@@ -0,0 +1,47 @@
package de.rayzs.pat.plugin.converter.converters;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
import de.rayzs.pat.plugin.converter.Converter;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.sender.CommandSender;
import java.util.ArrayList;
import java.util.List;
public class CommandWhitelistConverter extends Converter {
public CommandWhitelistConverter() {
super("CommandWhitelist", "CommandWhitelist", "config");
}
@Override
public void apply(CommandSender sender) {
List<String> groups = config.getKeys("groups", false).stream().toList();
for (String groupName : groups) {
List<String> commands = new ArrayList<>();
final List<String> l1 = (ArrayList<String>) config.get("groups." + groupName + ".commands");
final List<String> l2 = ((ArrayList<String>) config.get("groups." + groupName + ".subcommands"))
.stream()
.map(c -> Storage.Blacklist.BlockType.NEGATE + c)
.toList();
commands.addAll(l1);
commands.addAll(l2);
BlacklistStorage storage;
if (groupName.equalsIgnoreCase("default")) {
storage = Storage.Blacklist.getBlacklist();
} else {
Group group = GroupManager.registerAndGetGroup(groupName);
storage = group.getGeneralGroupBlacklist();
}
applyStorage(storage, commands);
}
}
}
@@ -0,0 +1,58 @@
package de.rayzs.pat.plugin.converter.converters;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
import de.rayzs.pat.plugin.converter.Converter;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.sender.CommandSender;
import java.util.ArrayList;
import java.util.List;
public class PlHideFree extends Converter {
public PlHideFree() {
super("PlHide", "Pl-Hide-Free", "config");
}
@Override
public void apply(CommandSender sender) {
List<String> groups = config.getKeys("groups", false).stream().toList();
for (String groupName : groups) {
List<String> execution = (ArrayList<String>) config.get("groups." + groupName + ".commands");
List<String> commands = execution.stream().filter(s -> !s.startsWith("!") && !s.equalsIgnoreCase("*")).map(this::translate).toList();
BlacklistStorage storage;
if (groupName.equalsIgnoreCase("default")) {
storage = Storage.Blacklist.getBlacklist();
} else {
Group group = GroupManager.registerAndGetGroup(groupName);
storage = group.getGeneralGroupBlacklist();
}
applyStorage(storage, commands);
}
sender.sendMessage("§e§lNotice: §7Since PAT is mainly focussed on either blocking or whitelisting commands entirely, PAT is viewing and converting the file such that commands are only working in whitelist mode. If you wish to use ProAntiTab in blacklist mode instead, then please checkout the wiki! (https://github.com/RayzsYT/ProAntiTab/wiki/How-to#introduction)");
}
private String translate(String input) {
if (input.contains(" ")) {
if (input.endsWith("~")) {
return translate(input.substring(0, input.length() - 1) + "_-");
}
if (input.endsWith("*")) {
return input.substring(0, input.length() - 2);
} else if (input.contains("*")) {
return input.substring(0, input.indexOf('*') - 1);
}
}
return input;
}
}
@@ -0,0 +1,99 @@
package de.rayzs.pat.plugin.converter.converters;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
import de.rayzs.pat.plugin.converter.Converter;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.sender.CommandSender;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class PlHidePro extends Converter {
public PlHidePro() {
super("PlHidePro", "Pl-Hide-Pro", "config");
}
@Override
public void apply(CommandSender sender) {
boolean updateGroupPerWorld = (boolean) config.get("per_world_group_updates");
Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_WORLD.getConfig().setAndSave("update-groups-per-world", updateGroupPerWorld);
boolean autoLowercaseCommands = (boolean) config.get("auto_lowercase_base_commands");
Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.getConfig().setAndSave("auto-lowercase-commands.enabled", autoLowercaseCommands);
boolean f3brand = (boolean) config.get("replace-f3-server-brand");
String f3brandString = (String) config.get("f3-server-brand");
Storage.ConfigSections.Settings.CUSTOM_BRAND.getConfig().setAndSave("custom-server-brand.enabled", f3brand);
if (f3brand) {
Storage.ConfigSections.Settings.CUSTOM_BRAND.getConfig().setAndSave("custom-server-brand.repeat-delay", -1);
Storage.ConfigSections.Settings.CUSTOM_BRAND.getConfig().setAndSave("custom-server-brand.brands", new ArrayList<>(Collections.singletonList(f3brandString.replace("§", "&"))));
}
List<String> groups = config.getKeys("groups", false).stream().toList();
for (String groupName : groups) {
List<String> commands = new ArrayList<>();
final List<String> execution = (ArrayList<String>) config.get("groups." + groupName + ".commands");
final List<String> tabCompletion = (ArrayList<String>) config.get("groups." + groupName + ".tabcomplete");
for (String s : execution) {
if (s.equalsIgnoreCase("*")) {
tabCompletion.remove("*");
continue;
}
if (!s.contains(" ") && s.startsWith("!")) {
tabCompletion.remove(s);
continue;
}
if (tabCompletion.contains(s)) {
commands.add(s);
tabCompletion.remove(s);
continue;
}
commands.add("[CMD]" + s);
}
commands.addAll(tabCompletion.stream().map(s -> "[TAB]" + s).toList());
commands = commands.stream().map(this::translate).toList();
BlacklistStorage storage;
if (groupName.equalsIgnoreCase("default")) {
storage = Storage.Blacklist.getBlacklist();
} else {
Group group = GroupManager.registerAndGetGroup(groupName);
storage = group.getGeneralGroupBlacklist();
}
applyStorage(storage, commands);
}
sender.sendMessage("§e§lNotice: §7Since PAT is mainly focussed on either blocking or whitelisting commands entirely, PAT is viewing and converting the file such that commands are only working in whitelist mode. If you wish to use ProAntiTab in blacklist mode instead, then please checkout the wiki! (https://github.com/RayzsYT/ProAntiTab/wiki/How-to#introduction)");
}
private String translate(String input) {
if (input.contains(" ")) {
if (input.endsWith("~")) {
return translate(input.substring(0, input.length() - 1) + "_-");
}
if (input.endsWith("*")) {
return input.substring(0, input.length() - 2);
} else if (input.contains("*")) {
return input.substring(0, input.indexOf('*') - 1);
}
}
return input;
}
}
@@ -0,0 +1,32 @@
package de.rayzs.pat.plugin.converter.converters;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.plugin.converter.Converter;
import de.rayzs.pat.utils.sender.CommandSender;
import java.util.ArrayList;
import java.util.List;
public class PluginHiderPlus extends Converter {
public PluginHiderPlus() {
super("PluginHider+", "PluginHiderPlus", "config");
}
@Override
public void apply(CommandSender sender) {
boolean blacklist = (boolean) config.get("reverse-suggestionsWhitelist");
Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.getConfig().setAndSave("turn-blacklist-to-whitelist", !blacklist);
List<String> commands = (ArrayList<String>) config.get("suggestionsWhitelist");
if (blacklist) {
List<String> blockedCommands = (ArrayList<String>) config.get("blockedCommands.everyone.commands");
commands.addAll(blockedCommands);
}
applyStorage(Storage.Blacklist.getBlacklist(), commands);
sender.sendMessage("&e&lNotice: &7Since PluginHider+ both blocks certain commands and whitelist a few, the conversion into PAT's storage.yml format won't be accurate. Only whitelisted commands have been added, and blocked commands for everyone if the plugin was used in blacklist mode.");
}
}
@@ -1,68 +1,94 @@
package de.rayzs.pat.plugin.listeners.bukkit;
import de.rayzs.pat.api.event.events.FilteredSuggestionEvent;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.scheduler.PATScheduler;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import org.bukkit.event.player.PlayerCommandSendEvent;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.utils.adapter.ViaVersionAdapter;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.plugin.BukkitLoader;
import org.bukkit.entity.Player;
import de.rayzs.pat.utils.*;
import org.bukkit.event.*;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.*;
public class BukkitAntiTabListener implements Listener {
private static final CommandsCache COMMANDS_CACHE = new CommandsCache();
private static final List<UUID> knownOperators = new ArrayList<>();
@EventHandler (priority = EventPriority.LOWEST)
public void onPlayerCommandSend(PlayerCommandSendEvent event) {
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
String uuidSubstring = uuid.toString().substring(uuid.toString().length() - 5);
final Player player = event.getPlayer();
final CommandSender sender = CommandSenderHandler.from(player);
final UUID uuid = player.getUniqueId();
if (Storage.USE_VELOCITY || player.isOp()) {
Logger.debug("Doesn't even tried to create the commands list for player with uuid " + uuidSubstring + ". (Veloctiy? " + Storage.USE_VELOCITY + ". OP? " + player.isOp() + ")");
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
return;
}
if (!BukkitLoader.isLoaded()) {
event.getCommands().clear();
Logger.debug("Doesn't even tried to create the commands list for player with uuid " + uuidSubstring + ". (not loaded)");
if (player.isOp()) {
if (!knownOperators.contains(uuid)) {
knownOperators.add(uuid);
}
return;
}
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
return;
if (event.getCommands().isEmpty()) {
Logger.debug("No available commands to filter! Ignoring rest of the code until at least one command is listed in there.");
return;
}
List<String> allCommands = getCommands();
List<String> allCommands = getCommands();
COMMANDS_CACHE.handleCommands(allCommands);
if (PermissionUtil.hasBypassPermission(player)) {
Logger.debug("Player with uuid " + uuidSubstring + " skipped the commands-list creation due to its permissions.");
if (!player.isOp() && knownOperators.contains(uuid)) {
knownOperators.remove(uuid);
if (Reflection.isCraftbukkit() && sender != null) {
PermissionUtil.reloadPermissions(sender);
} else {
PermissionUtil.reloadPermissions(uuid);
}
}
if (PermissionUtil.hasBypassPermission(sender)) {
return;
}
final List<String> playerCommands = COMMANDS_CACHE.getPlayerCommands(new ArrayList<>(event.getCommands()), player, player.getUniqueId());
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, playerCommands);
if (Reflection.isCraftbukkit() && !Bukkit.getOnlinePlayers().contains(player)) {
event.getCommands().clear();
PATScheduler.createScheduler(player::updateCommands, 10);
return;
}
final List<Group> groups = GroupManager.getPlayerGroups(sender);
final List<String> playerCommands = COMMANDS_CACHE.getPlayerCommands(new ArrayList<>(event.getCommands()), sender, groups);
final FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, playerCommands);
event.getCommands().clear();
if (filteredSuggestionEvent.isCancelled())
if (filteredSuggestionEvent.isCancelled()) {
return;
}
event.getCommands().addAll(filteredSuggestionEvent.getSuggestions());
Logger.debug("Player with uuid " + uuidSubstring + " has a total of " + playerCommands.size() + " commands.");
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.ALWAYS_TAB_COMPLETABLE) {
event.getCommands().addAll(Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines());
}
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.ALWAYS_TAB_COMPLETABLE) {
event.getCommands().addAll(Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines());
}
}
public static List<String> getCommands() {
@@ -71,26 +97,18 @@ public class BukkitAntiTabListener implements Listener {
}
private static boolean notUpdatablePlayer(UUID uuid) {
return Storage.USE_VIAVERSION && Reflection.getMinor() >= 16 && ViaVersionAdapter.getPlayerProtocol(uuid) < 754;
return Storage.USE_VIAVERSION && Reflection.isAtLeast(1, 16) && ViaVersionAdapter.getPlayerProtocol(uuid) < 754;
}
// --------------- LUCKPERMS SECTIONS --------------- //
public static void luckpermsNetworkSync() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(BukkitLoader.getPlugin(), PermissionUtil::reloadPermissions, 40);
}
public static void luckpermsNetworkUserSync(UUID uuid) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(BukkitLoader.getPlugin(), () -> PermissionUtil.reloadPermissions(uuid));
}
public static void updateCommands() {
Bukkit.getOnlinePlayers().forEach(BukkitAntiTabListener::updateCommands);
}
public static void updateCommands(Player player) {
if (Reflection.getMinor() >= 13 && !notUpdatablePlayer(player.getUniqueId()))
if (!notUpdatablePlayer(player.getUniqueId()))
player.updateCommands();
}
@@ -104,10 +122,12 @@ public class BukkitAntiTabListener implements Listener {
public static void handleTabCompletion(UUID uuid) {
Player player = Bukkit.getPlayer(uuid);
if (player == null)
return;
handleTabCompletion(player);
if (player == null) {
return;
}
handleTabCompletion(player, getCommands());
}
public static void handleTabCompletion(Player player) {
@@ -2,6 +2,10 @@ package de.rayzs.pat.plugin.listeners.bukkit;
import java.util.List;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
@@ -13,7 +17,6 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.plugin.BukkitLoader;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.message.MessageTranslator;
@@ -23,16 +26,23 @@ public class BukkitBlockCommandListener implements Listener {
@EventHandler (priority = EventPriority.HIGHEST)
public void onUnknownCommandRecognition(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
World world = player.getWorld();
final Player player = event.getPlayer();
final CommandSender sender = CommandSenderHandler.from(player);
final World world = player.getWorld();
String rawCommand = StringUtils.getFirstArg(event.getMessage()),
command = rawCommand.substring(1);
if (!Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.ENABLED || event.isCancelled()) return;
if (PermissionUtil.hasBypassPermission(player)) return;
//if (BukkitLoader.doesCommandExist(command, false)) return;
if (Bukkit.getHelpMap().getHelpTopic(rawCommand) != null) return;
if (PermissionUtil.hasBypassPermission(sender))
return;
if (Storage.getLoader().doesCommandExist(command))
return;
if (Bukkit.getHelpMap().getHelpTopic(rawCommand) != null)
return;
event.setCancelled(true);
MessageTranslator.send(player, Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.MESSAGE, "%command%", command, "%world%", world.getName());
@@ -40,9 +50,12 @@ public class BukkitBlockCommandListener implements Listener {
@EventHandler (priority = EventPriority.LOWEST)
public void onPlayerCommandProcess(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
final Player player = event.getPlayer();
final CommandSender sender = CommandSenderHandler.from(player);
if (Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.isCommand(StringUtils.getFirstArg(event.getMessage()))) {
final String commandFirstArg = StringUtils.getFirstArg(event.getMessage());
if (Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.isCommand(commandFirstArg)) {
String command = event.getMessage();
if (command.contains(" ")) {
@@ -51,47 +64,110 @@ public class BukkitBlockCommandListener implements Listener {
command = String.join(" ", args);
} else command = command.toLowerCase();
player.chat(command);
event.setCancelled(true);
return;
if (!commandFirstArg.equals(command)) {
player.chat(command);
event.setCancelled(true);
return;
}
}
World world = player.getWorld();
String command = event.getMessage(),
worldName = world.getName();
boolean bypassPermission = PermissionUtil.hasBypassPermission(player, command);
command = command.substring(1);
command = StringUtils.getFirstArg(command);
final String displayName = command;
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
return;
}
command = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
command = command.toLowerCase();
if (PermissionUtil.hasBypassPermission(sender, command)) {
return;
}
final String displayCommand = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
List<String> notificationMessage = MessageTranslator.replaceMessageList(
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
"%player%", player.getName(),
"%command%", displayName,
"%command%", displayCommand,
"%world%", worldName);
if (bypassPermission)
return;
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
return;
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
return;
MessageTranslator.send(
player,
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE,
"%command%", StringUtils.getFirstArg(displayCommand)
);
if (!Storage.Blacklist.canPlayerAccessChat(player, command)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), true);
if (Storage.SEND_CONSOLE_NOTIFICATION)
Logger.info(notificationMessage);
Storage.NOTIFY_PLAYERS.forEach(uuid -> {
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
if (p != null) {
MessageTranslator.send(p, notificationMessage);
}
});
event.setCancelled(true);
return;
}
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
MessageTranslator.send(
player,
Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE,
"%command%", StringUtils.getFirstArg(displayCommand)
);
if (Storage.SEND_CONSOLE_NOTIFICATION)
Logger.info(notificationMessage);
Storage.NOTIFY_PLAYERS.forEach(uuid -> {
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
if (p != null) {
MessageTranslator.send(p, notificationMessage);
}
});
event.setCancelled(true);
return;
}
final boolean cancelBlockedCommand = Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED;
final List<Group> groups = GroupManager.getPlayerGroups(sender);
boolean allowed = Storage.Blacklist.canPlayerAccessChat(sender, groups, command);
boolean blockedNamespace = false;
if (!Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender)) {
blockedNamespace = cancelBlockedCommand
? Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command)
: Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesAlwaysBlock(command);
if (blockedNamespace) allowed = false;
}
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED && !blockedNamespace) {
return;
}
if (!allowed) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
player,
event.getMessage(),
true,
!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
);
if (executeCommandEvent.isBlocked()) {
event.setCancelled(true);
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED)
if (!executeCommandEvent.doesNotify())
return;
if (Storage.SEND_CONSOLE_NOTIFICATION)
@@ -108,7 +184,7 @@ public class BukkitBlockCommandListener implements Listener {
return;
}
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), false);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), false, false);
if (executeCommandEvent.isBlocked())
event.setCancelled(true);
}
@@ -1,61 +0,0 @@
package de.rayzs.pat.plugin.listeners.bukkit;
import de.rayzs.pat.api.brand.CustomServerBrand;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
import de.rayzs.pat.api.communication.BackendUpdater;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.plugin.BukkitLoader;
import org.bukkit.event.player.*;
import org.bukkit.entity.Player;
import org.bukkit.event.*;
import org.bukkit.Bukkit;
public class BukkitPlayerConnectionListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
if(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
BackendUpdater.handle();
PermissionUtil.setPlayerPermissions(player.getUniqueId());
CustomServerBrand.preparePlayer(player);
if(CustomServerBrand.isEnabled())
CustomServerBrand.sendBrandToPlayer(player);
if(!BukkitPacketAnalyzer.inject(player)) player.kickPlayer("Failed to inject player!");
if(Storage.OUTDATED && PermissionUtil.hasPermission(player, "joinupdate")) {
Bukkit.getScheduler().runTaskLater(BukkitLoader.getPlugin(), () -> {
if (player.isOnline()) {
MessageTranslator.send(player, Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines());
}
}, 20);
}
}
@EventHandler (priority = EventPriority.LOWEST)
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
BukkitPacketAnalyzer.uninject(player.getUniqueId());
PermissionUtil.resetPermissions(player.getUniqueId());
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) return;
}
@EventHandler (priority = EventPriority.LOWEST)
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) return;
CustomServerBrand.sendBrandToPlayer(player);
}
}
@@ -0,0 +1,127 @@
package de.rayzs.pat.plugin.listeners.bukkit;
import de.rayzs.pat.api.brand.CustomServerBrand;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
import de.rayzs.pat.api.communication.BackendUpdater;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.utils.Reflection;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.utils.permission.PermissionPlugin;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.scheduler.PATScheduler;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import org.bukkit.event.player.*;
import org.bukkit.entity.Player;
import org.bukkit.event.*;
import java.util.UUID;
public class BukkitPlayerListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
final Player player = event.getPlayer();
final UUID uuid = player.getUniqueId();
final CommandSender sender = CommandSenderHandler.from(player);
sender.updateSenderObject(player);
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
BackendUpdater.handle();
}
CustomServerBrand.preparePlayer(player);
PermissionUtil.reloadPermissions(sender);
if (CustomServerBrand.isEnabled()) {
CustomServerBrand.sendBrandToPlayer(player);
}
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
if (Storage.getPermissionPlugin() != PermissionPlugin.LUCKPERMS) {
PATScheduler.createScheduler(() -> {
if (Storage.getPermissionPlugin() == PermissionPlugin.GROUPMANAGER) {
PermissionUtil.reloadPermissions(sender);
}
if (Reflection.isAtLeast(1, 13)) {
BukkitAntiTabListener.handleTabCompletion(player);
}
}, 20);
}
}
if (!BukkitPacketAnalyzer.inject(player)) {
PATScheduler.createScheduler(() -> {
if (player.isOnline()) {
if (!BukkitPacketAnalyzer.inject(player)) {
if (Storage.ConfigSections.Settings.INJECTION_FAILED.ENABLED) {
Logger.info(MessageTranslator.replaceMessage(
sender,
Storage.ConfigSections.Settings.INJECTION_FAILED.CONSOLE_MESSAGE
));
player.kickPlayer(MessageTranslator.replaceMessage(
sender,
Storage.ConfigSections.Settings.INJECTION_FAILED.KICK_MESSAGE
));
}
}
}
}, 10);
}
// Update sub arguments for <1.12.2 servers.
if (Reflection.isBefore(1, 13)) {
Storage.quickSubArgumentUpdate(uuid);
}
if (Storage.OUTDATED && PermissionUtil.hasPermission(sender, "joinupdate")) {
PATScheduler.createScheduler(() -> {
if (player.isOnline()) {
MessageTranslator.send(player, Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines());
}
}, 20);
}
}
@EventHandler (priority = EventPriority.LOWEST)
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
BukkitPacketAnalyzer.uninject(player.getUniqueId());
PermissionUtil.resetPermissions(player.getUniqueId());
}
@EventHandler (priority = EventPriority.LOWEST)
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
CustomServerBrand.sendBrandToPlayer(player);
}
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_WORLD.ENABLED) {
CommandSender sender = CommandSenderHandler.from(player);
assert sender != null;
PermissionUtil.reloadPermissions(sender);
if (Reflection.isAtLeast(1, 13)) {
BukkitAntiTabListener.handleTabCompletion(player);
}
}
}
}
@@ -39,7 +39,6 @@ public class PaperServerListPing implements Listener {
String versionName = Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PROTOCOL.replace("%online_extended%", String.valueOf(onlineExtend)).replace("%online%", String.valueOf(online)).replace("%max%", String.valueOf(max));
if (Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.HIDE_PLAYERS) {
event.getPlayerSample().clear();
event.setHidePlayers(true);
}
else if (Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.USE_CUSTOM_PLAYERLIST) {
@@ -2,27 +2,48 @@ package de.rayzs.pat.plugin.listeners.bungee;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.TabCompleteEvent;
import net.md_5.bungee.api.event.TabCompleteResponseEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import java.util.ArrayList;
import java.util.List;
public class BungeeAntiTabListener implements Listener {
@EventHandler
public void onTabComplete(TabCompleteEvent event) {
if(!(event.getSender() instanceof ProxiedPlayer)) return;
public void onTabCompleteResponse(TabCompleteResponseEvent event) {
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
if(!(event.getReceiver() instanceof ProxiedPlayer)) return;
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
CommandSender sender = CommandSenderHandler.from(player);
ServerInfo serverInfo = player.getServer().getInfo();
String serverName = serverInfo.getName();
String cursor = event.getCursor().substring(1);
String rawCursor = BungeePacketAnalyzer.getPlayerInput(player);
if (rawCursor == null) {
return;
}
if (!rawCursor.startsWith("/")) {
return;
}
String cursor = rawCursor.substring(1);
if (event.getSuggestions().isEmpty())
return;
@@ -30,38 +51,63 @@ public class BungeeAntiTabListener implements Listener {
if (Storage.Blacklist.isDisabledServer(serverName))
return;
if (PermissionUtil.hasBypassPermission(player))
if (PermissionUtil.hasBypassPermission(sender))
return;
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player, cursor, event.getSuggestions());
List<String> suggestions = filteredTabCompletionEvent.getCompletion();
event.getSuggestions().removeIf(suggestion -> !suggestions.contains(suggestion));
final List<Group> groups = GroupManager.getPlayerGroups(sender);
final boolean doesBypassNamespace = Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender);
final boolean spaces = cursor.contains(" ");
boolean cancelsBeforeHand = false;
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(cursor) && !doesBypassNamespace) {
cancelsBeforeHand = true;
}
if (!cancelsBeforeHand && !cursor.isEmpty()) {
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(sender, groups, StringUtils.getFirstArg(cursor), serverName);
}
if (!cancelsBeforeHand) {
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(cursor) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(cursor);
}
if (spaces) {
if (cancelsBeforeHand) {
event.getSuggestions().clear();
return;
}
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player.getUniqueId(), rawCursor, new ArrayList<>(event.getSuggestions()));
if (filteredTabCompletionEvent.isCancelled()) {
event.getSuggestions().clear();
} else {
event.getSuggestions().removeIf(s -> !filteredTabCompletionEvent.getCompletion().contains(s));
}
return;
}
event.getSuggestions().removeIf(s -> {
String cpy = s;
if (cpy.startsWith("/")) {
cpy = cpy.substring(1);
}
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(cpy) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(cpy)) {
return false;
}
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, cpy, serverName);
});
}
@EventHandler
public void onTabComplete(TabCompleteResponseEvent event) {
// Ignoring this at first, due to transfer to the packet-based solution only. Hehe
/*
if (!(event.getSender() instanceof ProxiedPlayer))
return;
public void onTabComplete(TabCompleteEvent event) {
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
ServerInfo serverInfo = player.getServer().getInfo();
String serverName = serverInfo.getName();
if (Storage.Blacklist.isDisabledServer(serverName))
return;
if(PermissionUtil.hasBypassPermission(player))
return;
event.getSuggestions().removeIf(command -> !Storage.Blacklist.canPlayerAccessTab(player, command, serverName));
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, event.getSuggestions());
if (filteredSuggestionEvent.isCancelled()) event.getSuggestions().clear();
*/
BungeePacketAnalyzer.setPlayerInput(player, event.getCursor());
}
}
@@ -1,8 +1,13 @@
package de.rayzs.pat.plugin.listeners.bungee;
import de.rayzs.pat.api.communication.Communicator;
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import net.md_5.bungee.api.event.ChatEvent;
import net.md_5.bungee.api.plugin.Listener;
import de.rayzs.pat.plugin.logger.Logger;
@@ -20,45 +25,117 @@ public class BungeeBlockCommandListener implements Listener {
public void onChat(ChatEvent event) {
if (event.isCancelled()) return;
Connection connection = event.getSender();
final Connection connection = event.getSender();
if (! (connection instanceof ProxiedPlayer) || !event.getMessage().startsWith("/"))
return;
ProxiedPlayer player = (ProxiedPlayer) connection;
String serverName = player.getServer().getInfo().getName();
final ProxiedPlayer player = (ProxiedPlayer) connection;
final CommandSender sender = CommandSenderHandler.from(player);
final String serverName = player.getServer().getInfo().getName();
String command = event.getMessage();
boolean bypassPermission = PermissionUtil.hasBypassPermission(player, command);
if (bypassPermission)
if (PermissionUtil.hasBypassPermission(sender, command) || Storage.Blacklist.isDisabledServer(serverName))
return;
command = command.startsWith("/") ? command.substring(1) : command;
command = StringUtils.getFirstArg(command);
final String displayCommand = command;
if (Communicator.get().hasConnectedClients() && Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.isCommand(command)) {
command = command.toLowerCase();
}
command = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
command = command.toLowerCase();
final String displayCommand = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
List<String> notificationMessage = MessageTranslator.replaceMessageList(
final List<String> notificationMessage = MessageTranslator.replaceMessageList(
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
"%player%", player.getName(),
"%command%", displayCommand,
"%server%", serverName);
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
return;
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
if (!Storage.Blacklist.canPlayerAccessChat(player, command, serverName)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), true);
Communicator.Proxy2Backend.sendNotification(player.getUniqueId(), serverName, displayCommand);
MessageTranslator.send(
player,
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE,
"%command%", StringUtils.getFirstArg(displayCommand)
);
if (Storage.SEND_CONSOLE_NOTIFICATION)
Logger.info(notificationMessage);
Storage.NOTIFY_PLAYERS.stream().forEach(uuid -> {
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
if (p != null) {
MessageTranslator.send(p, notificationMessage);
}
});
event.setCancelled(true);
return;
}
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
Communicator.Proxy2Backend.sendNotification(player.getUniqueId(), serverName, displayCommand);
MessageTranslator.send(
player,
Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE,
"%command%", StringUtils.getFirstArg(displayCommand)
);
if (Storage.SEND_CONSOLE_NOTIFICATION)
Logger.info(notificationMessage);
Storage.NOTIFY_PLAYERS.forEach(uuid -> {
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
if (p != null) {
MessageTranslator.send(p, notificationMessage);
}
});
event.setCancelled(true);
return;
}
final List<Group> groups = GroupManager.getPlayerGroups(sender);
final boolean cancelBlockedCommand = Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED;
boolean allowed = Storage.Blacklist.canPlayerAccessChat(sender, groups, command, serverName);
boolean blockedNamespace = false;
if (!Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender)) {
blockedNamespace = cancelBlockedCommand
? Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command)
: Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesAlwaysBlock(command);
if (blockedNamespace) allowed = false;
}
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED && !blockedNamespace) {
return;
}
if (!allowed) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
player,
event.getMessage(),
true,
!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
);
if (executeCommandEvent.isBlocked()) {
event.setCancelled(true);
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED)
if (!executeCommandEvent.doesNotify())
return;
Communicator.Proxy2Backend.sendNotification(player.getUniqueId(), serverName, displayCommand);
if (Storage.SEND_CONSOLE_NOTIFICATION)
Logger.info(notificationMessage);
@@ -76,7 +153,7 @@ public class BungeeBlockCommandListener implements Listener {
return;
}
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), false);
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), false, false);
if (executeCommandEvent.isBlocked())
event.setCancelled(true);
}
@@ -24,7 +24,7 @@ public class BungeePingListener implements Listener {
try {
max = proxyServer.getConfigurationAdapter().getListeners().iterator().next().getMaxPlayers();
} catch (Throwable throwable) {
Logger.debug("Failed to read max-players count for %max% placeholder! Using -1 as default value instead.");
Logger.warning("Failed to read max-players count for %max% placeholder! Using -1 as default value instead.");
}
ServerPing serverPing = event.getResponse();
@@ -6,6 +6,8 @@ import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Listener;
import de.rayzs.pat.api.storage.Storage;
@@ -19,7 +21,10 @@ public class BungeePlayerConnectionListener implements Listener {
@EventHandler (priority = EventPriority.LOWEST)
public void onPostLogin(PostLoginEvent event) {
ProxiedPlayer player = event.getPlayer();
final ProxiedPlayer player = event.getPlayer();
final CommandSender sender = CommandSenderHandler.from(player);
sender.updateSenderObject(player);
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
if(CustomServerBrand.isEnabled())
@@ -27,9 +32,9 @@ public class BungeePlayerConnectionListener implements Listener {
if (player.isConnected()) CustomServerBrand.sendBrandToPlayer(player);
}, 500, TimeUnit.MILLISECONDS);
PermissionUtil.setPlayerPermissions(player.getUniqueId());
PermissionUtil.setPlayerPermissions(sender);
if(Storage.OUTDATED && PermissionUtil.hasPermission(player, "joinupdate")) {
if (Storage.OUTDATED && PermissionUtil.hasPermission(sender, "joinupdate")) {
ProxyServer.getInstance().getScheduler().schedule(BungeeLoader.getPlugin(), () -> {
if (player.isConnected()) {
MessageTranslator.send(player, Storage.ConfigSections.Settings.UPDATE.OUTDATED, "%player%", player.getName());
@@ -44,8 +49,16 @@ public class BungeePlayerConnectionListener implements Listener {
BungeePacketAnalyzer.inject(player);
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1)
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_SERVER.ENABLED) {
CommandSender sender = CommandSenderHandler.from(player);
assert sender != null;
PermissionUtil.reloadPermissions(sender);
}
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) {
return;
}
CustomServerBrand.sendBrandToPlayer(player);
}
@@ -58,8 +71,9 @@ public class BungeePlayerConnectionListener implements Listener {
PermissionUtil.resetPermissions(player.getUniqueId());
BungeePacketAnalyzer.uninject(player);
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1)
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) {
return;
}
CustomServerBrand.sendBrandToPlayer(player);
}
@@ -9,7 +9,11 @@ import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.api.event.events.FilteredSuggestionEvent;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.CommandsCache;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import io.github.waterfallmc.waterfall.event.ProxyDefineCommandsEvent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
@@ -21,36 +25,44 @@ public class WaterfallAntiTabListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void onProxyDefineCommands(ProxyDefineCommandsEvent event) {
System.out.println("CALL");
if(!(event.getReceiver() instanceof ProxiedPlayer) || event.getCommands().isEmpty()) return;
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
String serverName = player.getServer().getInfo().getName();
if (Storage.Blacklist.isDisabledServer(serverName))
if (!(event.getReceiver() instanceof ProxiedPlayer) || event.getCommands().isEmpty()) {
return;
}
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
final ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
final CommandSender sender = CommandSenderHandler.from(player);
final String serverName = player.getServer().getInfo().getName();
if(!cache.containsKey(serverName))
if (Storage.Blacklist.isDisabledServer(serverName) || PermissionUtil.hasBypassPermission(sender)) {
return;
}
final List<Group> groups = GroupManager.getPlayerGroups(sender);
final Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
if (!cache.containsKey(serverName)) {
cache.put(serverName, new CommandsCache());
}
CommandsCache commandsCache = cache.get(serverName);
List<String> commandsAsString = new ArrayList<>();
HashMap<String, Command> commandsMap = new HashMap<>(event.getCommands());
final CommandsCache commandsCache = cache.get(serverName);
final List<String> commandsAsString = new ArrayList<>();
final HashMap<String, Command> commandsMap = new HashMap<>(event.getCommands());
event.getCommands().forEach((key, value) -> commandsAsString.add(key));
commandsCache.handleCommands(commandsAsString, serverName);
if(PermissionUtil.hasBypassPermission(player)) return;
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, sender, groups, serverName);
event.getCommands().entrySet().removeIf(command -> {
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
event.getCommands().entrySet().removeIf(command -> playerCommands.contains(command.getKey()));
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command.getKey()) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command.getKey())) {
return false;
}
return playerCommands.contains(command.getKey());
});
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, new ArrayList<>(event.getCommands().keySet()));
if(filteredSuggestionEvent.isCancelled()) event.getCommands().clear();
if (filteredSuggestionEvent.isCancelled()) event.getCommands().clear();
for (String commandName : filteredSuggestionEvent.getSuggestions()) {
@@ -1,7 +1,6 @@
package de.rayzs.pat.plugin.listeners.velocity;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -15,8 +14,13 @@ import com.velocitypowered.api.proxy.ProxyServer;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.api.event.events.FilteredSuggestionEvent;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.utils.CommandsCache;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
public class VelocityAntiTabListener {
@@ -28,61 +32,104 @@ public class VelocityAntiTabListener {
@Subscribe (order = PostOrder.LAST)
public void onTabComplete(TabCompleteEvent event) {
Player player = event.getPlayer();
String serverName = player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "unknown";
final Player player = event.getPlayer();
if (Storage.Blacklist.isDisabledServer(serverName))
if (!event.getPartialMessage().startsWith("/")) {
return;
}
if (PermissionUtil.hasBypassPermission(player) || event.getSuggestions().isEmpty() || !player.getCurrentServer().isPresent()) return;
final String serverName = player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "unknown";
if (Storage.Blacklist.isDisabledServer(serverName)) {
return;
}
final CommandSender sender = CommandSenderHandler.from(player);
if (PermissionUtil.hasBypassPermission(sender) || event.getSuggestions().isEmpty() || player.getCurrentServer().isEmpty()) {
return;
}
final List<Group> groups = GroupManager.getPlayerGroups(sender);
event.getSuggestions().removeIf(command -> {
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command)) {
return false;
}
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command, serverName);
});
event.getSuggestions().removeIf(command -> !Storage.Blacklist.canPlayerAccessTab(player, command, serverName));
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, event.getSuggestions());
if(filteredSuggestionEvent.isCancelled()) event.getSuggestions().clear();
}
@Subscribe (order = PostOrder.LAST)
public void onPlayerAvailableCommands(PlayerAvailableCommandsEvent event) {
Player player = event.getPlayer();
try {
final Player player = event.getPlayer();
if(event.getRootNode().getChildren().isEmpty() || !player.getCurrentServer().isPresent())
return;
if (event.getRootNode().getChildren().isEmpty() || !player.getCurrentServer().isPresent()) {
return;
}
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
final CommandSender sender = CommandSenderHandler.from(player);
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
if (PermissionUtil.hasBypassPermission(sender)) {
return;
}
if(!cache.containsKey(serverName))
cache.put(serverName, new CommandsCache());
final String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
CommandsCache commandsCache = cache.get(serverName);
if (Storage.Blacklist.isDisabledServer(serverName)) {
return;
}
List<String> commandsAsString = new ArrayList<>();
event.getRootNode().getChildren().stream().filter(command -> command != null && command.getName() != null).forEach(command -> commandsAsString.add(command.getName()));
commandsCache.handleCommands(commandsAsString, serverName);
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
if (PermissionUtil.hasBypassPermission(player))
return;
if (!cache.containsKey(serverName)) {
cache.put(serverName, new CommandsCache());
}
final boolean newer = player.getProtocolVersion().getProtocol() > 340, argsChildrenExist = event.getRootNode().getChild("args") != null;
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
final CommandsCache commandsCache = cache.get(serverName);
final List<Group> groups = GroupManager.getPlayerGroups(sender);
final List<String> commandsAsString = new ArrayList<>();
if (event.getRootNode().getChildren().size() == 1
&& newer && argsChildrenExist
&& event.getRootNode().getChild("args").getChildren().isEmpty()) {
return;
event.getRootNode().getChildren().stream()
.filter(command -> command != null && command.getName() != null)
.forEach(command -> commandsAsString.add(command.getName()));
commandsCache.handleCommands(commandsAsString, serverName);
final boolean newer = player.getProtocolVersion().getProtocol() > 340, argsChildrenExist = event.getRootNode().getChild("args") != null;
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, sender, groups, serverName);
if (event.getRootNode().getChildren().size() == 1
&& newer && argsChildrenExist
&& event.getRootNode().getChild("args").getChildren().isEmpty()) {
return;
}
if (event.getRootNode().getChildren().size() == 1 && newer && argsChildrenExist) {
return;
}
event.getRootNode().getChildren().removeIf(command -> {
if (command == null || command.getName() == null)
return true;
if (command.getName().equals("args"))
return false;
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command.getName()) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command.getName())) {
return false;
}
return !playerCommands.contains(command.getName());
});
} catch (Exception exception) {
Logger.warning("An error occurred while processing commands in PAT: " + exception.getMessage());
exception.printStackTrace();
}
if(event.getRootNode().getChildren().size() == 1 && newer && argsChildrenExist) return;
event.getRootNode().getChildren().removeIf(command -> {
if (command == null || command.getName() == null)
return true;
if (command.getName().equals("args"))
return false;
return !playerCommands.contains(command.getName());
});
}
}
@@ -1,73 +1,159 @@
package de.rayzs.pat.plugin.listeners.velocity;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.command.CommandExecuteEvent;
import com.velocitypowered.api.command.CommandSource;
import de.rayzs.pat.api.communication.Communicator;
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.utils.permission.PermissionUtil;
import com.velocitypowered.api.proxy.Player;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.api.event.*;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import java.util.List;
public class VelocityBlockCommandListener {
@Subscribe
public void onCommandExecute(CommandExecuteEvent event) {
handleCommand(event);
}
public static CommandExecuteEvent handleCommand(Player player, String command) {
return handleCommand(new CommandExecuteEvent(player, command));
}
public static CommandExecuteEvent handleCommand(CommandExecuteEvent event) {
if(!event.getResult().isAllowed())
if (!event.getResult().isAllowed()) {
return event;
}
CommandSource commandSource = event.getCommandSource();
Object consoleSender = Storage.getLoader().getConsoleSender();
final CommandSource commandSource = event.getCommandSource();
final Object consoleSender = Storage.getLoader().getConsoleSender();
if(! (commandSource instanceof Player))
return event;
Player player = (Player) commandSource;
String command = StringUtils.getFirstArg(event.getCommand());
String serverName = player.getCurrentServer().isPresent()
final Player player = (Player) commandSource;
final CommandSender sender = CommandSenderHandler.from(player);
final String serverName = player.getCurrentServer().isPresent()
? player.getCurrentServer().get().getServerInfo().getName()
: "unknown";
boolean bypassPermission = PermissionUtil.hasBypassPermission(player, command);
String tmpCommand = StringUtils.getFirstArg(event.getCommand());
if (Communicator.get().hasConnectedClients() && Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.isCommand(tmpCommand)) {
tmpCommand = tmpCommand.toLowerCase();
}
if (bypassPermission)
final String command = tmpCommand;
if (PermissionUtil.hasBypassPermission(sender, command) || Storage.Blacklist.isDisabledServer(serverName))
return event;
final String displayCommand = command;
command = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
command = command.toLowerCase();
final String displayCommand = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
List<String> notificationMessage = MessageTranslator.replaceMessageList(
final List<String> notificationMessage = MessageTranslator.replaceMessageList(
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
"%player%", player.getUsername(),
"%command%", displayCommand,
"%server%", serverName
);
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
return event;
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
if (!Storage.Blacklist.canPlayerAccessChat(player, command, serverName)) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getCommand(), true);
Communicator.Proxy2Backend.sendNotification(player.getUniqueId(), serverName, displayCommand);
MessageTranslator.send(
player,
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE,
"%command%", StringUtils.getFirstArg(displayCommand)
);
if (Storage.SEND_CONSOLE_NOTIFICATION)
MessageTranslator.send(consoleSender, notificationMessage);
Storage.NOTIFY_PLAYERS.forEach(uuid -> {
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
if (p != null) {
MessageTranslator.send(p, notificationMessage);
}
});
event.setResult(CommandExecuteEvent.CommandResult.denied());
return event;
}
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
Communicator.Proxy2Backend.sendNotification(player.getUniqueId(), serverName, displayCommand);
MessageTranslator.send(
player,
Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE,
"%command%", StringUtils.getFirstArg(displayCommand)
);
if (Storage.SEND_CONSOLE_NOTIFICATION)
MessageTranslator.send(consoleSender, notificationMessage);
Storage.NOTIFY_PLAYERS.forEach(uuid -> {
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
if (p != null) {
MessageTranslator.send(p, notificationMessage);
}
});
event.setResult(CommandExecuteEvent.CommandResult.denied());
return event;
}
final boolean cancelBlockedCommand = Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED;
final List<Group> groups = GroupManager.getPlayerGroups(sender);
boolean allowed = Storage.Blacklist.canPlayerAccessChat(sender, groups, command, serverName);
boolean blockedNamespace = false;
if (!Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender)) {
blockedNamespace = cancelBlockedCommand
? Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command)
: Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesAlwaysBlock(command);
if (blockedNamespace) allowed = false;
}
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED && !blockedNamespace) {
return event;
}
if (!allowed) {
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
player,
event.getCommand(),
true,
!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
if (executeCommandEvent.isBlocked()) {
event.setResult(CommandExecuteEvent.CommandResult.denied());
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED)
if (!executeCommandEvent.doesNotify())
return event;
Communicator.Proxy2Backend.sendNotification(player.getUniqueId(), serverName, displayCommand);
if (Storage.SEND_CONSOLE_NOTIFICATION)
MessageTranslator.send(consoleSender, notificationMessage);
Storage.NOTIFY_PLAYERS.stream().forEach(uuid -> {
Storage.NOTIFY_PLAYERS.forEach(uuid -> {
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
if (p != null) {
MessageTranslator.send(p, notificationMessage);
@@ -79,9 +165,12 @@ public class VelocityBlockCommandListener {
return event;
}
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getCommand(), false);
if (executeCommandEvent.isBlocked())
final ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getCommand(), false, false);
if (executeCommandEvent.isBlocked()) {
event.setResult(CommandExecuteEvent.CommandResult.denied());
}
return event;
}
@@ -1,10 +1,12 @@
package de.rayzs.pat.plugin.listeners.velocity;
import com.velocitypowered.api.event.connection.DisconnectEvent;
import com.velocitypowered.api.proxy.server.ServerInfo;
import de.rayzs.pat.api.brand.CustomServerBrand;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
import de.rayzs.pat.api.netty.proxy.VelocityPacketAnalyzer;
import de.rayzs.pat.plugin.logger.Logger;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.utils.permission.PermissionUtil;
import com.velocitypowered.api.event.Subscribe;
@@ -12,6 +14,10 @@ import com.velocitypowered.api.event.player.*;
import de.rayzs.pat.plugin.VelocityLoader;
import de.rayzs.pat.api.storage.Storage;
import com.velocitypowered.api.proxy.*;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import net.kyori.adventure.text.Component;
import java.util.concurrent.TimeUnit;
public class VelocityConnectionListener {
@@ -26,7 +32,16 @@ public class VelocityConnectionListener {
@Subscribe
public void onServerPreConnect(ServerPreConnectEvent event) {
Player player = event.getPlayer();
final Player player = event.getPlayer();
final CommandSender sender = CommandSenderHandler.from(player);
sender.updateSenderObject(player);
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_SERVER.ENABLED) {
final ServerInfo serverInfo = event.getOriginalServer().getServerInfo();
if (serverInfo != null) Storage.tempCachePlayerToServer(player.getUniqueId(), serverInfo.getName());
}
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
if(CustomServerBrand.isEnabled())
@@ -34,9 +49,9 @@ public class VelocityConnectionListener {
if (player.isActive()) CustomServerBrand.sendBrandToPlayer(player);
}).delay(500, TimeUnit.MILLISECONDS).schedule();
PermissionUtil.setPlayerPermissions(player.getUniqueId());
PermissionUtil.setPlayerPermissions(sender);
if(Storage.OUTDATED && PermissionUtil.hasPermission(player, "joinupdate")) {
if (Storage.OUTDATED && PermissionUtil.hasPermission(sender, "joinupdate")) {
server.getScheduler().buildTask(loader, () -> {
if (player.isActive())
MessageTranslator.send(player, Storage.ConfigSections.Settings.UPDATE.OUTDATED, "%player%", player.getUsername());
@@ -46,12 +61,47 @@ public class VelocityConnectionListener {
@Subscribe
public void onServerSwitch(ServerConnectedEvent event) {
Player player = event.getPlayer();
final Player player = event.getPlayer();
if(!VelocityPacketAnalyzer.isInjected(player))
VelocityPacketAnalyzer.inject(player);
if (!VelocityPacketAnalyzer.isInjected(player)) {
if (!VelocityPacketAnalyzer.inject(player)) {
server.getScheduler().buildTask(loader, () -> {
if (!VelocityPacketAnalyzer.inject(player)) {
if (Storage.ConfigSections.Settings.INJECTION_FAILED.ENABLED) {
Logger.info(MessageTranslator.replaceMessage(
player,
Storage.ConfigSections.Settings.INJECTION_FAILED.CONSOLE_MESSAGE
));
player.disconnect(Component.text(
MessageTranslator.replaceMessage(
player,
Storage.ConfigSections.Settings.INJECTION_FAILED.KICK_MESSAGE
)
));
}
}
}).delay(1, TimeUnit.SECONDS).schedule();
}
}
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_SERVER.ENABLED) {
final ServerInfo serverInfo = event.getServer().getServerInfo();
if (serverInfo != null) Storage.tempCachePlayerToServer(player.getUniqueId(), serverInfo.getName());
CommandSender sender = CommandSenderHandler.from(player);
assert sender != null;
PermissionUtil.reloadPermissions(sender);
}
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) {
return;
}
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) return;
CustomServerBrand.sendBrandToPlayer(player);
}
@@ -1,21 +1,42 @@
package de.rayzs.pat.plugin.logger;
import de.rayzs.pat.api.communication.Communicator;
import de.rayzs.pat.api.communication.client.ClientInfo;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
import de.rayzs.pat.plugin.logger.impl.*;
import java.nio.charset.StandardCharsets;
import javax.net.ssl.HttpsURLConnection;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.Reflection;
import de.rayzs.pat.utils.*;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.permission.PermissionPlugin;
import java.net.URL;
import java.util.*;
import java.io.*;
public class Logger {
private static final String LOG_HEADER;
static {
final String software = Reflection.getSoftware().isProxySoftware()
? Reflection.getSoftware().toString()
: Reflection.getVersionName();
final String version = Reflection.isProxyServer() ? "" : " " + Reflection.getRawVersionName().replace("_", ".");
LOG_HEADER = "> ProAntiTab v" + Storage.CURRENT_VERSION + " [" + software + version + "]";
}
private final static LoggerTemplate LOGGER =
Reflection.isVelocityServer() ? new VelocityLogger()
: Reflection.isProxyServer() ? new BungeeLogger()
: new BukkitLogger();
public static void info(List<String> messages) {
LOGGER.info(messages);
}
@@ -24,10 +45,6 @@ public class Logger {
LOGGER.warn(messages);
}
public static void debug(List<String> messages) {
LOGGER.debug(messages);
}
public static void info(String message) {
LOGGER.info(message);
}
@@ -36,25 +53,9 @@ public class Logger {
LOGGER.warn(message);
}
public static void debug(String message) {
LOGGER.debug(message);
}
public static String post() throws IOException {
ArrayList<String> clonedLogs = new ArrayList<>(LOGGER.getLogs());
int startIndex = clonedLogs.size() > 980 ? clonedLogs.size() - 980 : 0;
StringBuilder textBuilder = new StringBuilder("[ProAntiTab " + Storage.CURRENT_VERSION + " | " + (Reflection.isProxyServer() ? Reflection.isVelocityServer() ? "Velocity" : "Proxy" : Reflection.isPaper() ? "Paper" : "Bukkit") + "]" + (Reflection.getRawVersionName() != null ? " Server version: " + Reflection.getVersionName() + " " + Reflection.getRawVersionName().replace("_", ".") : "") + "\n" + (startIndex != 0 ? "... another part is split!\n\n" : ""));
for (int i = startIndex; i < clonedLogs.size(); i++) {
if (clonedLogs.get(i) == null)
continue;
String line = clonedLogs.get(i);
textBuilder.append("\n");
textBuilder.append(line);
}
byte[] textInBytes = textBuilder.toString().getBytes(StandardCharsets.UTF_8);
byte[] textInBytes = (LOG_HEADER + "\n\n" + createInfo()).getBytes(StandardCharsets.UTF_8);
int postDataLength = textInBytes.length;
URL url = new URL("https://haste.rayzs.de/documents");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
@@ -77,4 +78,111 @@ public class Logger {
response = response.substring(response.indexOf(":") + 2, response.length() - 2);
return "https://haste.rayzs.de/" + response + ".txt";
}
private static String createInfo() {
StringBuilder builder = new StringBuilder();
if (!Reflection.isProxyServer()) {
builder.append("Detected Software-API: ")
.append(Reflection.getSoftware().toString())
.append("\n\n");
}
builder.append("Updated: ")
.append(!Storage.OUTDATED)
.append("\n\n");
builder.append("Mode: ")
.append(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED ? "WHITELIST" : "BLACKLIST")
.append("\n");
builder.append("Installed plugins: \n ")
.append(String.join("\n ", Storage.getLoader().getPluginNames("%n (%v)")))
.append("\n\n");
builder.append("Detected supported plugins:")
.append("\n");
builder.append(" LuckPerms: ")
.append(Storage.getPermissionPlugin() == PermissionPlugin.LUCKPERMS)
.append("\n");
if (!Reflection.isProxyServer()) {
builder.append(" GroupManager: ")
.append(Storage.getPermissionPlugin() == PermissionPlugin.GROUPMANAGER)
.append("\n");
}
builder.append(" PlaceholderAPI: ")
.append(Storage.USE_PLACEHOLDERAPI)
.append("\n");
builder.append(" ViaVersion: ")
.append(Storage.USE_VIAVERSION)
.append("\n\n");
if (!Reflection.isProxyServer()) {
builder.append("server-name: ")
.append(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ? Storage.SERVER_NAME : "Not connected to a proxy using PAT")
.append("\n");
builder.append("last-received-sync: ")
.append(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ? TimeConverter.calcAndGetTime(Communicator.get().getLastSync()) : "Deactivated")
.append("\n");
builder.append("last-received-alive-response-packet: ")
.append(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ? TimeConverter.calcAndGetTime(Communicator.get().getLastReceivedKeepAliveResponse()) : "Deactivated")
.append("\n");
}
builder.append("\ncommands: ")
.append(String.join(", ", Storage.Blacklist.getBlacklist().getCommands()))
.append("\n\n");
if (Reflection.isProxyServer()) {
builder.append("\nservers: ")
.append(String.join(", ", Storage.getServers()))
.append("\n");
builder.append("last-sent-sync: ")
.append(Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED ? "Deactivated" : (TimeConverter.calcAndGetTime(Communicator.get().getLastSync())))
.append("\n\n");
builder.append("synced-server: ");
Iterator<ClientInfo> iterator = Communicator.get().getClients().iterator();
while (iterator.hasNext()) {
ClientInfo clientInfo = iterator.next();
builder.append(clientInfo.getServerName())
.append(" (")
.append(clientInfo.getFormattedLastReceivedKeepAlivePacketTime() + " / " + clientInfo.getFormattedSyncTime())
.append(")");
if (iterator.hasNext()) {
builder.append(", ");
}
}
builder.append("\n\n");
}
if (Reflection.isProxyServer()) {
builder.append("server-commands:").append("\n");
for (Map.Entry<String, GeneralBlacklist> blacklist : Storage.Blacklist.getBlacklists()) {
builder.append(" ")
.append(blacklist.getKey()).append(": ")
.append(String.join(", ", blacklist.getValue().getCommands()))
.append("\n");
}
}
builder.append("\ngroups:");
for (Group group : GroupManager.getGroups()) {
builder.append("\n")
.append(group.getGroupInfo());
}
return builder.toString();
}
}
@@ -1,3 +1,3 @@
package de.rayzs.pat.plugin.logger;
public enum LoggerPriority { INFO, WARNING, DEBUG }
public enum LoggerPriority { INFO, WARNING }
@@ -1,23 +1,16 @@
package de.rayzs.pat.plugin.logger;
import java.text.SimpleDateFormat;
import java.util.List;
public interface LoggerTemplate {
SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss:SS");
List<String> getLogs();
void info(List<String> messages);
void warn(List<String> messages);
void debug(List<String> messages);
void send(LoggerPriority priority, List<String> messages);
void info(String message);
void warn(String message);
void debug(String message);
void send(LoggerPriority priority, String message);
}
@@ -1,25 +1,15 @@
package de.rayzs.pat.plugin.logger.impl;
import de.rayzs.pat.plugin.BukkitLoader;
import de.rayzs.pat.plugin.logger.LoggerPriority;
import de.rayzs.pat.plugin.logger.LoggerTemplate;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.plugin.BukkitLoader;
import de.rayzs.pat.plugin.logger.*;
import org.bukkit.Bukkit;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
public class BukkitLogger implements LoggerTemplate {
private final List<String> LOGS = new ArrayList<>();
private final java.util.logging.Logger logger = BukkitLoader.getPluginLogger();
@Override
public List<String> getLogs() {
return LOGS;
}
@Override
public void info(List<String> messages) {
messages.forEach(this::info);
@@ -30,11 +20,6 @@ public class BukkitLogger implements LoggerTemplate {
messages.forEach(this::warn);
}
@Override
public void debug(List<String> messages) {
messages.forEach(this::debug);
}
@Override
public void send(LoggerPriority priority, List<String> messages) {
messages.forEach(message -> send(priority, message));
@@ -50,22 +35,10 @@ public class BukkitLogger implements LoggerTemplate {
send(LoggerPriority.WARNING, message);
}
@Override
public void debug(String message) {
send(LoggerPriority.DEBUG, message);
}
@Override
public void send(LoggerPriority priority, String message) {
message = MessageTranslator.replaceMessage(message);
String time = TIME_FORMAT.format(new Date(System.currentTimeMillis()));
if(time.length() != 12) time = time.substring(0, 9) + 0 + time.split(":")[3];
LOGS.add("[" + priority.name() + " | " + time + "] " + MessageTranslator.colorless(message));
if (priority == LoggerPriority.DEBUG)
return;
if (message.contains("§")) {
MessageTranslator.send(Bukkit.getServer().getConsoleSender(), message);
return;
@@ -1,25 +1,15 @@
package de.rayzs.pat.plugin.logger.impl;
import de.rayzs.pat.plugin.BungeeLoader;
import de.rayzs.pat.plugin.logger.LoggerPriority;
import de.rayzs.pat.plugin.logger.LoggerTemplate;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.plugin.BungeeLoader;
import net.md_5.bungee.api.ProxyServer;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import de.rayzs.pat.plugin.logger.*;
import java.util.*;
public class BungeeLogger implements LoggerTemplate {
private final List<String> LOGS = new ArrayList<>();
private final java.util.logging.Logger logger = BungeeLoader.getPluginLogger();
@Override
public List<String> getLogs() {
return LOGS;
}
@Override
public void info(List<String> messages) {
messages.forEach(this::info);
@@ -30,11 +20,6 @@ public class BungeeLogger implements LoggerTemplate {
messages.forEach(this::warn);
}
@Override
public void debug(List<String> messages) {
messages.forEach(this::debug);
}
@Override
public void send(LoggerPriority priority, List<String> messages) {
messages.forEach(message -> send(priority, message));
@@ -50,22 +35,10 @@ public class BungeeLogger implements LoggerTemplate {
send(LoggerPriority.WARNING, message);
}
@Override
public void debug(String message) {
send(LoggerPriority.DEBUG, message);
}
@Override
public void send(LoggerPriority priority, String message) {
message = MessageTranslator.replaceMessage(message);
String time = TIME_FORMAT.format(new Date(System.currentTimeMillis()));
if(time.length() != 12) time = time.substring(0, 9) + 0 + time.split(":")[3];
LOGS.add("[" + priority.name() + " | " + time + "] " + MessageTranslator.colorless(message));
if (priority == LoggerPriority.DEBUG)
return;
if (message.contains("§")) {
MessageTranslator.send(ProxyServer.getInstance().getConsole(), message);
return;
@@ -1,25 +1,15 @@
package de.rayzs.pat.plugin.logger.impl;
import de.rayzs.pat.plugin.VelocityLoader;
import de.rayzs.pat.plugin.logger.LoggerPriority;
import de.rayzs.pat.plugin.logger.LoggerTemplate;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.plugin.VelocityLoader;
import de.rayzs.pat.plugin.logger.*;
import org.slf4j.Logger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
public class VelocityLogger implements LoggerTemplate {
private final List<String> LOGS = new ArrayList<>();
private final Logger logger = VelocityLoader.getPluginLogger();
@Override
public List<String> getLogs() {
return LOGS;
}
@Override
public void info(List<String> messages) {
messages.forEach(this::info);
@@ -30,11 +20,6 @@ public class VelocityLogger implements LoggerTemplate {
messages.forEach(this::warn);
}
@Override
public void debug(List<String> messages) {
messages.forEach(this::debug);
}
@Override
public void send(LoggerPriority priority, List<String> messages) {
messages.forEach(message -> send(priority, message));
@@ -50,22 +35,10 @@ public class VelocityLogger implements LoggerTemplate {
send(LoggerPriority.WARNING, message);
}
@Override
public void debug(String message) {
send(LoggerPriority.DEBUG, message);
}
@Override
public void send(LoggerPriority priority, String message) {
message = MessageTranslator.replaceMessage(message);
String time = TIME_FORMAT.format(new Date(System.currentTimeMillis()));
if(time.length() != 12) time = time.substring(0, 9) + 0 + time.split(":")[3];
LOGS.add("[" + priority.name() + " | " + time + "] " + MessageTranslator.colorless(message));
if (priority == LoggerPriority.DEBUG)
return;
if (message.contains("§")) {
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(), message);
return;
@@ -1,5 +1,6 @@
package de.rayzs.pat.plugin.metrics.impl;
import de.rayzs.pat.utils.scheduler.PATScheduler;
import org.bukkit.configuration.file.YamlConfiguration;
import java.nio.charset.StandardCharsets;
import javax.net.ssl.HttpsURLConnection;
@@ -171,7 +172,7 @@ public class BukkitMetrics {
}
// Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
// Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
Bukkit.getScheduler().runTask(plugin, this::submitData);
PATScheduler.createScheduler(this::submitData);
};
// Many servers tend to restart at a fixed time at xx:00 which causes an uneven distribution of requests on the
@@ -1,127 +0,0 @@
package de.rayzs.pat.plugin.modules;
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
import de.rayzs.pat.plugin.modules.events.ExecuteCommand;
import de.rayzs.pat.plugin.modules.events.TabCompletion;
import de.rayzs.pat.plugin.modules.events.UpdateList;
import de.rayzs.pat.utils.node.CommandNodeHelper;
import de.rayzs.pat.utils.response.ResponseHandler;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.subargs.*;
import java.util.stream.Collectors;
import de.rayzs.pat.utils.group.*;
import de.rayzs.pat.utils.*;
import java.util.*;
public class SubArgsModule {
public static List<String> GENERAL_LIST, BLOCKED_MESSAGE, PLAYER_NAMES, ONLINE_PLAYERS;
public static HashMap<UUID, Arguments> PLAYER_COMMANDS = new HashMap<>();
public static void initialize() {
updateList();
updateMessages();
updatePlayerNames();
PATEventHandler.register(new TabCompletion());
PATEventHandler.register(new ExecuteCommand());
PATEventHandler.register(UpdateList.UPDATE_PLUGIN_EVENT);
PATEventHandler.register(UpdateList.RECEIVE_SYNC_EVENT);
PATEventHandler.register(UpdateList.UPDATE_PLAYER_COMMANDS_EVENT);
PATEventHandler.register(UpdateList.SERVER_PLAYERS_CHANGE_EVENT);
}
public static void updatePlayerNames() {
PLAYER_NAMES = Storage.getLoader().getPlayerNames();
ONLINE_PLAYERS = Storage.getLoader().getOnlinePlayerNames();
}
public static List<String> getPlayerNames() {
return PLAYER_NAMES;
}
public static List<String> getOnlinePlayerNames() {
return ONLINE_PLAYERS;
}
public static void updateList() {
GENERAL_LIST = Storage.Blacklist.getBlacklist().getCommands().stream().filter(command -> command.contains(" ")).collect(Collectors.toList());
Arguments.ARGUMENTS.clearArguments();
GENERAL_LIST.forEach(command -> Arguments.ARGUMENTS.buildArgumentStacks(command));
SubArgsModule.PLAYER_COMMANDS = new HashMap<>();
}
public static void updateMessages() {
Storage.Files.CUSTOM_RESPONSES.reload();
ResponseHandler.update();
}
public static void handleCommandNode(UUID uuid, CommandNodeHelper helper) {
if (!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED)
return;
Arguments arguments = PLAYER_COMMANDS.get(uuid);
if (arguments == null) {
return;
}
ArgumentSource source = arguments.TAB_ARGUMENTS;
if (source == null) return;
List<String> inputs = source.getAllInputs().stream().filter(str -> !str.contains("%")).toList();
List<String> allEntries = inputs.stream().map(StringUtils::getFirstArg).toList();
helper.removeIf(allEntries::contains);
inputs.forEach(helper::add);
}
public static List<String> getServerCommands(UUID uuid) {
return getServerCommands(Storage.getLoader().getPlayerServerName(uuid));
}
public static List<String> getServerCommands(String serverName) {
List<String> commands = new ArrayList<>(Storage.Blacklist.getBlacklist().getCommands());
if (!Reflection.isProxyServer())
return commands;
if (serverName == null)
return commands;
List<GeneralBlacklist> blacklists = Storage.Blacklist.getServerBlacklists(serverName);
for (GeneralBlacklist blacklist : blacklists)
commands.addAll(blacklist.getCommands());
return commands;
}
public static List<String> getGroupCommands(UUID uuid) {
return getGroupCommands(uuid, null);
}
public static List<String> getGroupCommands(UUID uuid, String serverName) {
List<String> commands = new ArrayList<>();
List<Group> groups = GroupManager.getPlayerGroups(uuid);
if (serverName == null) {
groups.forEach(group -> commands.addAll(group.getCommands()));
return commands;
}
groups.forEach(group -> {
commands.addAll(group.getCommands());
List<String> associatedServerNames = group.getBlacklistServerNames(serverName);
associatedServerNames.forEach(s -> {
commands.addAll(group.getCommands(s));
});
});
return commands;
}
}
@@ -1,174 +0,0 @@
package de.rayzs.pat.plugin.modules.events;
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
import de.rayzs.pat.plugin.modules.SubArgsModule;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.utils.response.ResponseHandler;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import de.rayzs.pat.utils.subargs.*;
import de.rayzs.pat.utils.*;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class ExecuteCommand extends ExecuteCommandEvent {
@Override
public void handle(ExecuteCommandEvent event) {
String command = event.getCommand();
command = command.startsWith("/")
? command.substring(1)
: command;
final String displayCommand = StringUtils.getFirstArg(command);
CommandSender sender = CommandSenderHandler.from(event.getSenderObj());
if (sender == null)
return;
UUID uuid = sender.getUniqueId();
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
MessageTranslator.send(
event.getSenderObj(),
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE,
"%command%", displayCommand
);
event.setBlocked(true);
event.setCancelled(true);
return;
}
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
MessageTranslator.send(
event.getSenderObj(),
Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE,
"%command%", displayCommand
);
event.setBlocked(true);
event.setCancelled(true);
return;
}
if (command.contains(" ") && !canPlayerExecute(sender, command)) {
event.setBlocked(true);
event.setCancelled(true);
MessageTranslator.send(event.getSenderObj(),
ResponseHandler.getResponse(uuid, event.getCommand()),
"%command%", command);
return;
}
if (!event.isBlocked())
return;
event.setCancelled(true);
MessageTranslator.send(
event.getSenderObj(),
ResponseHandler.getResponse(uuid, event.getCommand(), Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE.getLines()),
"%command%", displayCommand
);
}
private boolean canPlayerExecute(CommandSender sender, String command) {
boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
boolean listed = false;
Arguments arguments = SubArgsModule.PLAYER_COMMANDS.getOrDefault(sender.getUniqueId(), Arguments.ARGUMENTS);
List<String> commands = new ArrayList<>(arguments.CHAT_ARGUMENTS.getGeneralArgument().getInputs());
final String unmodifiable = command;
if (commands.stream().noneMatch(c -> StringUtils.getFirstArg(c).equalsIgnoreCase(StringUtils.getFirstArg(unmodifiable)))) {
return true;
}
commands = commands.stream().map(c -> {
if (c.contains("%hidden")) {
return c.replace("%hidden_", "%");
}
return c;
}).toList();
List<String> placeholderCommands = commands.stream().filter(s -> s.contains("%")).toList();
if (!placeholderCommands.isEmpty())
command = replacePlaceholders(command, placeholderCommands);
String cpyCommand;
for (String c : commands) {
cpyCommand = command;
if (listed)
break;
if (cpyCommand.contains("%both_players%")) {
if (c.contains("%online_players%"))
cpyCommand = StringUtils.replace(command, "%both_players%", "%online_players%");
if (c.contains("%players%"))
cpyCommand = StringUtils.replace(command, "%both_players%", "%players%");
}
boolean ends = c.endsWith("_-");
if (ends) {
c = StringUtils.replace(c, "_-", "");
if (c.endsWith(" "))
c = StringUtils.replaceLast(c, " ", "");
}
listed = c.equalsIgnoreCase(cpyCommand) || cpyCommand.startsWith(c + " ");
if (listed && ends && cpyCommand.length() > c.length()) {
listed = false;
break;
}
}
return turn == listed;
}
private String replacePlaceholders(String input, List<String> abnormalCommands) {
String[] split = input.split(" ");
for (int i = 0; i < split.length; i++) {
String s = split[i];
boolean number = NumberUtils.isDigit(split[i]),
online = Storage.getLoader().isPlayerOnline(s),
general = Storage.getLoader().doesPlayerExist(s);
if (number) {
split[i] = "%numbers%";
continue;
}
if (online && general) {
split[i] = "%both_players%";
continue;
}
if (online) {
split[i] = "%online_players%";
continue;
}
if (general)
split[i] = "%players%";
}
return String.join(" ", split);
}
}
@@ -1,92 +0,0 @@
package de.rayzs.pat.plugin.modules.events;
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
import de.rayzs.pat.plugin.modules.SubArgsModule;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.*;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import de.rayzs.pat.utils.subargs.Arguments;
import java.util.*;
public class TabCompletion extends FilteredTabCompletionEvent {
@Override
public void handle(FilteredTabCompletionEvent event) {
String cursor = StringUtils.replaceFirst(event.getCursor(), "/", "");
if (event.getCompletion().isEmpty()) return;
UUID uuid = event.getSenderObj() instanceof UUID
? (UUID) event.getSenderObj()
: CommandSenderHandler.from(event.getSenderObj()).getUniqueId();
Arguments arguments = SubArgsModule.PLAYER_COMMANDS.getOrDefault(uuid, Arguments.ARGUMENTS);
List<String> possibilities = event.getCompletion(), result = new ArrayList<>(arguments.getResultTab(cursor));
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
possibilities = result;
if (result.contains("%numbers%")) {
possibilities.remove("%numbers%");
possibilities.addAll(possibilities.stream().filter(NumberUtils::isDigit).toList());
}
if (result.contains("%players%")) {
possibilities.remove("%players%");
possibilities.addAll(SubArgsModule.getPlayerNames());
}
if (result.contains("%online_players%")) {
possibilities.remove("%online_players%");
possibilities.addAll(SubArgsModule.getOnlinePlayerNames());
}
if (result.contains("%hidden_players%")) {
possibilities.remove("%hidden_players%");
possibilities.addAll(event.getCompletion().stream().filter(completion -> {
if (SubArgsModule.getPlayerNames().contains(completion))
return false;
return result.contains(completion);
}).toList());
if (possibilities.isEmpty())
possibilities.add("///////////");
}
if (result.contains("%hidden_online_players%")) {
possibilities.remove("%hidden_online_players%");
possibilities.addAll(event.getCompletion().stream().filter(completion -> {
if (SubArgsModule.getOnlinePlayerNames().contains(completion))
return false;
return result.contains(completion);
}).toList());
if (possibilities.isEmpty()) possibilities.add("///////////");
}
} else {
if (result.contains("%numbers%"))
possibilities.removeIf(NumberUtils::isDigit);
if (result.contains("%players%"))
possibilities.removeIf(possibility -> SubArgsModule.getPlayerNames().contains(possibility));
if (result.contains("%online_players%"))
possibilities.removeIf(possibility -> SubArgsModule.getOnlinePlayerNames().contains(possibility));
possibilities.removeAll(result);
}
cursor = StringUtils.getFirstArg(cursor.toLowerCase());
if(possibilities.isEmpty() && !SubArgsModule.GENERAL_LIST.contains(cursor)) return;
event.setCompletion(possibilities);
}
}
@@ -1,82 +0,0 @@
package de.rayzs.pat.plugin.modules.events;
import de.rayzs.pat.plugin.modules.SubArgsModule;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import de.rayzs.pat.api.event.events.*;
import de.rayzs.pat.utils.subargs.Arguments;
import java.util.*;
public class UpdateList {
public static UpdatePluginEvent UPDATE_PLUGIN_EVENT = new UpdatePluginEvent() {
@Override
public void handle(UpdatePluginEvent event) {
SubArgsModule.updateMessages();
SubArgsModule.updateList();
}
};
public static ServerPlayersChangeEvent SERVER_PLAYERS_CHANGE_EVENT = new ServerPlayersChangeEvent() {
@Override
public void handle(ServerPlayersChangeEvent event) {
SubArgsModule.updatePlayerNames();
}
};
public static ReceiveSyncEvent RECEIVE_SYNC_EVENT = new ReceiveSyncEvent() {
@Override
public void handle(ReceiveSyncEvent event) {
SubArgsModule.updateList();
}
};
public static UpdatePlayerCommandsEvent UPDATE_PLAYER_COMMANDS_EVENT = new UpdatePlayerCommandsEvent() {
@Override
public void handle(UpdatePlayerCommandsEvent event) {
final UUID uuid = event.getSenderObj() instanceof UUID
? (UUID) event.getSenderObj()
: CommandSenderHandler.from(event.getSenderObj()).getUniqueId();
final Arguments argument = SubArgsModule.PLAYER_COMMANDS.getOrDefault(uuid, new Arguments());
final String serverName = Storage.getLoader().getPlayerServerName(uuid);
argument.clearArguments();
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
for (String command : event.getCommands())
argument.buildArgumentStacks(command);
for (String command : argument.CHAT_ARGUMENTS.getGeneralArgument().getInputs())
argument.CHAT_ARGUMENTS.buildArguments(Storage.Blacklist.BlockTypeFetcher.modify(command));
for (String command : argument.TAB_ARGUMENTS.getGeneralArgument().getInputs())
argument.TAB_ARGUMENTS.buildArguments(Storage.Blacklist.BlockTypeFetcher.modify(command));
for (String command : SubArgsModule.getGroupCommands(uuid, serverName))
argument.buildArgumentStacks(command);
for (String command : SubArgsModule.getServerCommands(uuid))
argument.buildArgumentStacks(command);
} else {
List<String> groupCommands = SubArgsModule.getGroupCommands(uuid, serverName);
for (String command : argument.CHAT_ARGUMENTS.getGeneralArgument().getInputs()) {
if (groupCommands.contains(command)) continue;
argument.CHAT_ARGUMENTS.buildArguments(Storage.Blacklist.BlockTypeFetcher.modify(command));
}
for (String command : argument.TAB_ARGUMENTS.getGeneralArgument().getInputs()) {
if (groupCommands.contains(command)) continue;
argument.TAB_ARGUMENTS.buildArguments(Storage.Blacklist.BlockTypeFetcher.modify(command));
}
}
SubArgsModule.PLAYER_COMMANDS.putIfAbsent(uuid, argument);
}
};
}
@@ -9,6 +9,7 @@ import de.rayzs.pat.plugin.process.impl.local.modify.list.ListPrioritiesCommand;
import de.rayzs.pat.plugin.process.impl.local.system.NotifyCommand;
import de.rayzs.pat.plugin.process.impl.local.system.PostDebugCommand;
import de.rayzs.pat.plugin.process.impl.local.system.ReloadCommand;
import de.rayzs.pat.plugin.process.impl.local.system.UpdateCommand;
import de.rayzs.pat.plugin.process.impl.server.ServAddCommand;
import de.rayzs.pat.plugin.process.impl.server.ServClearCommand;
import de.rayzs.pat.plugin.process.impl.server.ServRemoveCommand;
@@ -34,6 +35,12 @@ public class CommandProcess {
COMMANDS.add(new RemoveCommand());
COMMANDS.add(new ClearCommand());
COMMANDS.add(new ConvertCommand());
if (!Reflection.isProxyServer()) {
COMMANDS.add(new ExtractCommand());
}
COMMANDS.add(new CreateGroupCommand());
COMMANDS.add(new DeleteGroupCommand());
@@ -1,5 +1,6 @@
package de.rayzs.pat.plugin.process.impl.local.info;
import de.rayzs.pat.api.communication.BackendUpdater;
import de.rayzs.pat.api.communication.Communicator;
import de.rayzs.pat.api.command.ProCommand;
import de.rayzs.pat.api.storage.Storage;
@@ -22,17 +23,33 @@ public class InfoCommand extends ProCommand {
String message = StringUtils.getStringList(Storage.ConfigSections.Messages.INFO.MESSAGE.getLines(), "\n");
String syncTime = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED || Reflection.isProxyServer()
? Storage.ConfigSections.Messages.INFO.SYNC_TIME.replace("%time%", TimeConverter.calcAndGetTime(Reflection.isProxyServer()
? Communicator.LAST_DATA_UPDATE : Communicator.LAST_BUKKIT_SYNC))
String syncTime = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ||
Reflection.isProxyServer()
? Storage.ConfigSections.Messages.INFO.SYNC_TIME.replace("%time%", TimeConverter.calcAndGetTime(Communicator.get().getLastSync()))
: Storage.ConfigSections.Messages.INFO.SYNC_DISABLED;
String versionStatus = Storage.OUTDATED
String lastAlivePacketTime = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ||
Reflection.isProxyServer()
? Storage.ConfigSections.Messages.INFO.SYNC_TIME.replace("%time%", TimeConverter.calcAndGetTime(Communicator.get().getLastReceivedKeepAliveResponse()))
: Storage.ConfigSections.Messages.INFO.SYNC_DISABLED;
if (!Reflection.isProxyServer()
&& !BackendUpdater.isConnected()
&& Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
{
syncTime = Storage.ConfigSections.Messages.INFO.SYNC_WAITING;
lastAlivePacketTime = Storage.ConfigSections.Messages.INFO.SYNC_WAITING;
}
final String versionStatus = Storage.OUTDATED
? Storage.ConfigSections.Messages.INFO.VERSION_OUTDATED
: Storage.ConfigSections.Messages.INFO.VERSION_UPDATED;
message = StringUtils.replace(message,
"%sync_time%", syncTime,
"%last_alive_response%", lastAlivePacketTime,
"%version_status%", versionStatus
);
@@ -7,7 +7,9 @@ import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.*;
import de.rayzs.pat.utils.sender.CommandSender;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
public class StatsCommand extends ProCommand {
@@ -29,26 +31,28 @@ public class StatsCommand extends ProCommand {
return true;
}
final int length = Communicator.CLIENTS.size() - 1;
boolean tmpFound = false;
final Set<ClientInfo> clients = Communicator.get().getClients();
final Iterator<ClientInfo> iterator = clients.iterator();
boolean tmpFound = false;
StringBuilder statsBuilder = new StringBuilder();
for (int i = 0; i < Communicator.CLIENTS.size(); i++) {
ClientInfo client = Communicator.CLIENTS.get(i);
while (iterator.hasNext()) {
ClientInfo client = iterator.next();
if (!client.hasSentFeedback())
continue;
if (!tmpFound)
if (!tmpFound) {
tmpFound = true;
}
statsBuilder.append(StringUtils.replace(Storage.ConfigSections.Messages.STATS.SERVER,
"%updated%", client.getSyncTime(), "%servername%", client.getName()
"%updated%", client.getFormattedSyncTime(),
"%servername%", client.getServerName(),
"%last_alive_response%", client.getFormattedLastReceivedKeepAlivePacketTime()
));
if (i <= length)
if (iterator.hasNext()) {
statsBuilder.append(Storage.ConfigSections.Messages.STATS.SPLITTER);
}
}
final boolean found = tmpFound;
@@ -56,8 +60,9 @@ public class StatsCommand extends ProCommand {
Storage.ConfigSections.Messages.STATS.STATISTIC.getLines().forEach(message -> {
message = StringUtils.replace(message,
"%server_count%", String.valueOf(Communicator.SERVER_DATA_SYNC_COUNT),
"%last_sync_time%", TimeConverter.calcAndGetTime(Communicator.LAST_DATA_UPDATE),
"%server_count%", String.valueOf(Communicator.get().getClients().size()),
"%last_sync_time%", TimeConverter.calcAndGetTime(Communicator.get().getLastSync()),
"%last_alive_response_time%", TimeConverter.calcAndGetTime(Communicator.get().getLastReceivedKeepAliveResponse()),
"%servers%", found ? statsBuilder.toString() : Storage.ConfigSections.Messages.STATS.NO_SERVER
);
@@ -1,53 +0,0 @@
package de.rayzs.pat.plugin.process.impl.local.info;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.api.command.ProCommand;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.sender.CommandSender;
import java.util.*;
public class UpdateCommand extends ProCommand {
public UpdateCommand() {
super(
"update",
""
);
}
@Override
public boolean execute(CommandSender sender, String[] args) {
if (args.length == 0) {
PermissionUtil.reloadPermissions();
sender.sendMessage(Storage.ConfigSections.Messages.UPDATE_PERMISSIONS.UPDATE_ALL);
return true;
}
String name = args[0];
UUID uuid = Storage.getLoader().getUUIDByName(name);
boolean exist = uuid != null;
if (exist) {
name = Storage.getLoader().getNameByUUID(uuid);
}
String message = exist
? Storage.ConfigSections.Messages.UPDATE_PERMISSIONS.UPDATE_SPECIFIC
: Storage.ConfigSections.Messages.UPDATE_PERMISSIONS.PLAYER_NOT_ONLINE;
message = message.replace("%target%", name);
if (exist) {
PermissionUtil.reloadPermissions(uuid);
}
sender.sendMessage(message);
return true;
}
@Override
public List<String> tabComplete(CommandSender sender, String[] args) {
return args.length < 2 ? Storage.getLoader().getPlayerNames() : null;
}
}
@@ -58,6 +58,7 @@ public class AddCommand extends ProCommand {
if (command.isEmpty())
return false;
final boolean loadBlacklist = command.startsWith("plugin=") || command.startsWith("!");
final int length = args.length;
if (length == 1) {
@@ -67,6 +68,8 @@ public class AddCommand extends ProCommand {
if (!exist) {
Storage.Blacklist.getBlacklist().add(command).save();
if (loadBlacklist) Storage.Blacklist.getBlacklist().load();
Storage.handleChange();
}
@@ -107,7 +110,9 @@ public class AddCommand extends ProCommand {
if (Reflection.isProxyServer())
return null;
return BukkitLoader.getNotBlockedCommands();
return Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
? BukkitLoader.getDisallowedCommands()
: BukkitLoader.getAllowedCommands();
}
String fullString = String.join(" ", args);
@@ -34,6 +34,7 @@ public class ClearCommand extends ProCommand {
}
Storage.Blacklist.getBlacklist().clear().save();
Storage.Blacklist.getBlacklist().load();
Storage.handleChange();
CONFIRMATION.remove(sender.getUniqueId());
@@ -0,0 +1,51 @@
package de.rayzs.pat.plugin.process.impl.local.modify;
import de.rayzs.pat.api.command.ProCommand;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.plugin.converter.Converter;
import de.rayzs.pat.plugin.converter.StorageConverter;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.sender.CommandSender;
import java.util.List;
public class ConvertCommand extends ProCommand {
public ConvertCommand() {
super(
"convert",
""
);
}
@Override
public boolean execute(CommandSender sender, String[] args) {
if (args.length != 1)
return false;
String converterName = args[0];
Converter converter = StorageConverter.getConverter(converterName);
if (converter == null) {
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.CONVERT.INVALID_CONVERTER,
"%converter%", converterName)
);
return true;
}
converterName = converter.getPluginName();
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.CONVERT.SUCCESS,
"%converter%", converterName)
);
converter.apply(sender);
Storage.reload();
return true;
}
@Override
public List<String> tabComplete(CommandSender sender, String[] args) {
return StorageConverter.getConverters().stream().toList();
}
}
@@ -8,6 +8,7 @@ import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import java.util.Collections;
import java.util.List;
public class CreateGroupCommand extends ProCommand {
@@ -50,6 +51,6 @@ public class CreateGroupCommand extends ProCommand {
@Override
public List<String> tabComplete(CommandSender sender, String[] args) {
return args.length < 2 ? GroupManager.getGroupNames() : null;
return Collections.emptyList();
}
}
@@ -0,0 +1,157 @@
package de.rayzs.pat.plugin.process.impl.local.modify;
import de.rayzs.pat.api.command.ProCommand;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.group.Group;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.utils.sender.CommandSender;
import java.util.*;
public class ExtractCommand extends ProCommand {
public ExtractCommand() {
super(
"extract",
""
);
}
private enum Mode {
BOTH("both", true), ONLY_COLON("only-colon", true), NON_COLON("non-colon", false);
private static Mode getMode(final String name) {
for (final Mode mode : Mode.values()) {
if (mode.getName().equalsIgnoreCase(name)) {
return mode;
}
}
return null;
}
public String getName() {
return name;
}
public boolean doesIncludesColons() {
return includesColons;
}
private final String name;
private final boolean includesColons;
Mode(final String name, final boolean includesColons) {
this.name = name;
this.includesColons = includesColons;
}
}
@Override
public boolean execute(CommandSender sender, String[] args) {
if (args.length < 1) {
sender.sendMessage(Storage.ConfigSections.Messages.EXTRACT.USAGE);
return true;
}
Mode mode = Mode.NON_COLON;
String pluginName = args[0].toLowerCase();
boolean failed = false;
Group group = null;
if (args.length == 2) {
group = GroupManager.getGroupByName(args[1]);
if (group == null) {
mode = Mode.getMode(args[1]);
failed = mode == null;
}
} else if (args.length == 3) {
group = GroupManager.getGroupByName(args[1]);
mode = Mode.getMode(args[2]);
if (group == null || mode == null) {
failed = true;
}
}
if (failed) {
sender.sendMessage(Storage.ConfigSections.Messages.EXTRACT.USAGE);
return true;
}
List<String> pluginNames = Storage.getLoader().getPluginNames("%n");
boolean pluginFound = false, all = pluginName.equalsIgnoreCase("*");
for (String name : pluginNames) {
if (name.equalsIgnoreCase(pluginName)) {
pluginFound = true;
break;
}
}
if (!all && !pluginFound) {
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.EXTRACT.PLUGIN_NOT_FOUND,
"%plugin%", pluginName)
);
return true;
}
List<String> commands = all
? Storage.getLoader().getAllCommands(mode.doesIncludesColons())
: Storage.getLoader().getPluginCommands(args[0], mode.doesIncludesColons());
if (mode == Mode.ONLY_COLON) {
commands = commands.stream().filter(command -> command.contains(":")).toList();
}
BlacklistStorage storage = group == null
? Storage.Blacklist.getBlacklist()
: group.getGeneralGroupBlacklist();
commands = commands.stream().filter(command -> !storage.isListed(command)).toList();
commands.forEach(storage::add);
storage.save();
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.EXTRACT.SUCCESS,
"%amount%", String.valueOf(commands.size()),
"%plugin%", pluginName
));
return true;
}
@Override
public List<String> tabComplete(CommandSender sender, String[] args) {
final int length = args.length;
if (length <= 1) {
final List<String> suggestions = Storage.getLoader().getPluginNames("%n");
suggestions.add("*");
return suggestions;
}
List<String> result = new ArrayList<>();
if (length == 2 || length == 3 && GroupManager.getGroupByName(args[1]) != null) {
result.addAll(Arrays.stream(Mode.values()).map(Mode::getName).toList());
}
if (length == 2) {
result.addAll(GroupManager.getGroupNames());
}
return result;
}
}
@@ -57,15 +57,16 @@ public class RemoveCommand extends ProCommand {
if (command.isEmpty())
return false;
final boolean loadBlacklist = command.startsWith("plugin=") || command.startsWith("!");
final int length = args.length;
if (length == 1) {
boolean exist = command.contains(" ")
? Storage.Blacklist.getBlacklist().getCommands().contains(command)
: Storage.Blacklist.getBlacklist().isListed(command);
boolean exist = Storage.Blacklist.getBlacklist().getCommands().contains(command);
if (exist) {
Storage.Blacklist.getBlacklist().remove(command).save();
if (loadBlacklist) Storage.Blacklist.getBlacklist().load();
Storage.handleChange();
}
@@ -51,7 +51,7 @@ public class ListCommand extends ProCommand {
String message = Storage.ConfigSections.Messages.GROUP.LIST_MESSAGE;
message = StringUtils.replace(message,
"%group%", groupName,
"%size%", String.valueOf(Storage.Blacklist.getBlacklist().getCommands().size()),
"%size%", String.valueOf(group.getCommands().size()),
"%commands%", commandsListMessage
);
@@ -26,7 +26,7 @@ public class ListGroupsCommand extends ProCommand {
String message = Storage.ConfigSections.Messages.GROUP.LIST_GROUP_MESSAGE;
message = StringUtils.replace(message,
"%size%", String.valueOf(Storage.Blacklist.getBlacklist().getCommands().size()),
"%size%", String.valueOf(GroupManager.getGroups().size()),
"%groups%", groupsListMessage
);
@@ -18,20 +18,20 @@ public class NotifyCommand extends ProCommand {
@Override
public boolean execute(CommandSender sender, String[] args) {
boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !Reflection.isProxyServer();
if (backend) {
sender.sendMessage(Storage.ConfigSections.Messages.NO_PROXY.MESSAGE);
return true;
}
boolean enabled = false;
boolean enabled;
if (sender.isConsole()) {
enabled = Storage.SEND_CONSOLE_NOTIFICATION;
Storage.SEND_CONSOLE_NOTIFICATION = !Storage.SEND_CONSOLE_NOTIFICATION;
} else {
boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !Reflection.isProxyServer();
if (backend) {
sender.sendMessage(Storage.ConfigSections.Messages.NO_PROXY.MESSAGE);
return true;
}
enabled = Storage.NOTIFY_PLAYERS.contains(sender.getUniqueId());
if (enabled)
@@ -2,6 +2,7 @@ package de.rayzs.pat.plugin.process.impl.local.system;
import de.rayzs.pat.api.communication.BackendUpdater;
import de.rayzs.pat.api.brand.CustomServerBrand;
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
import de.rayzs.pat.utils.group.GroupManager;
import de.rayzs.pat.api.command.ProCommand;
@@ -21,28 +22,8 @@ public class ReloadCommand extends ProCommand {
@Override
public boolean execute(CommandSender sender, String[] args) {
boolean proxy = Reflection.isProxyServer();
boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !proxy;
sender.sendMessage(Storage.ConfigSections.Messages.RELOAD.LOADING);
Storage.loadAll(Reflection.isProxyServer() || !backend);
CustomServerBrand.initialize();
GroupManager.clearAllGroups();
GroupManager.initialize();
if (!proxy) {
BackendUpdater.stop();
BackendUpdater.start();
}
ConfigUpdater.broadcastMissingParts();
if (!backend) {
Storage.handleChange();
}
ConfigUpdater.initialize();
Storage.reload();
sender.sendMessage(Storage.ConfigSections.Messages.RELOAD.DONE);
return true;
}
@@ -0,0 +1,84 @@
package de.rayzs.pat.plugin.process.impl.local.system;
import de.rayzs.pat.api.communication.Communicator;
import de.rayzs.pat.plugin.listeners.bukkit.BukkitAntiTabListener;
import de.rayzs.pat.utils.Reflection;
import de.rayzs.pat.utils.permission.PermissionUtil;
import de.rayzs.pat.api.command.ProCommand;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import java.util.*;
public class UpdateCommand extends ProCommand {
public UpdateCommand() {
super(
"update",
""
);
}
@Override
public boolean execute(CommandSender sender, String[] args) {
if (args.length == 0) {
Storage.getLoader().getOnlinePlayerNames().forEach(name -> {
Object playerObj = Storage.getLoader().getPlayerObjByName(name);
if (playerObj != null) {
CommandSender s = CommandSenderHandler.from(playerObj);
assert s != null;
PermissionUtil.reloadPermissions(s);
}
});
if (!Reflection.isProxyServer() && Reflection.isAtLeast(1, 13)) {
BukkitAntiTabListener.handleTabCompletion();
} else if (Reflection.isProxyServer()) {
Communicator.Proxy2Backend.sendUpdateCommand();
}
sender.sendMessage(Storage.ConfigSections.Messages.UPDATE_PERMISSIONS.UPDATE_ALL);
return true;
}
String name = args[0];
UUID uuid = Storage.getLoader().getUUIDByName(name);
Object playerObj = Storage.getLoader().getPlayerObjByUUID(uuid);
CommandSender targetSender = CommandSenderHandler.from(playerObj);
boolean exist = targetSender != null;
if (exist) {
name = targetSender.getName();
}
String message = exist
? Storage.ConfigSections.Messages.UPDATE_PERMISSIONS.UPDATE_SPECIFIC
: Storage.ConfigSections.Messages.UPDATE_PERMISSIONS.PLAYER_NOT_ONLINE;
message = message.replace("%target%", name);
if (exist) {
PermissionUtil.reloadPermissions(targetSender);
if (!Reflection.isProxyServer() && Reflection.isAtLeast(1, 13)) {
BukkitAntiTabListener.handleTabCompletion(uuid);
} else if (Reflection.isProxyServer()) {
Communicator.Proxy2Backend.sendUpdateCommand(uuid, targetSender.getServerName());
}
}
sender.sendMessage(message);
return true;
}
@Override
public List<String> tabComplete(CommandSender sender, String[] args) {
return args.length < 2 ? Storage.getLoader().getOnlinePlayerNames() : null;
}
}
@@ -90,7 +90,15 @@ public class ServAddCommand extends ProCommand {
Group group = GroupManager.getGroupByName(groupName);
if (group == null) {
sender.sendMessage(Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER.replace("%group%", groupName));
String message = Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER;
message = StringUtils.replace(message,
"%group%", groupName,
"%server%", serverName
);
sender.sendMessage(message);
return true;
}
@@ -2,6 +2,7 @@ package de.rayzs.pat.plugin.process.impl.server;
import de.rayzs.pat.api.command.ProCommand;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.StringUtils;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.ExpireCache;
import de.rayzs.pat.utils.group.Group;
@@ -66,12 +67,14 @@ public class ServClearCommand extends ProCommand {
if (group == null) {
sender.sendMessage(
Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER
.replace("%group%", groupName)
.replace("%server%", serverName)
String message = Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER;
message = StringUtils.replace(message,
"%group%", groupName,
"%server%", serverName
);
sender.sendMessage(message);
return true;
}
@@ -95,12 +95,14 @@ public class ServRemoveCommand extends ProCommand {
if (group == null) {
sender.sendMessage(
Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER
.replace("%group%", groupName)
.replace("%server%", serverName)
String message = Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER;
message = StringUtils.replace(message,
"%group%", groupName,
"%server%", serverName
);
sender.sendMessage(message);
return true;
}
@@ -43,6 +43,7 @@ public class ServListCommand extends ProCommand {
);
String message = Storage.ConfigSections.Messages.BLACKLIST.LIST_SERVER_MESSAGE;
message = StringUtils.replace(message,
"%size%", String.valueOf(blacklist.getCommands().size()),
"%commands%", commandsListMessage,
@@ -57,7 +58,15 @@ public class ServListCommand extends ProCommand {
Group group = GroupManager.getGroupByName(groupName);
if (group == null) {
sender.sendMessage(Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER.replace("%group%", groupName));
String message = Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER;
message = StringUtils.replace(message,
"%group%", groupName,
"%server%", serverName
);
sender.sendMessage(message);
return true;
}
@@ -0,0 +1,261 @@
package de.rayzs.pat.plugin.subarguments;
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
import de.rayzs.pat.plugin.subarguments.events.ExecuteCommand;
import de.rayzs.pat.plugin.subarguments.events.TabCompletion;
import de.rayzs.pat.plugin.subarguments.events.UpdateList;
import de.rayzs.pat.utils.node.BukkitCommandNodeHelper;
import de.rayzs.pat.utils.node.ProxyCommandNodeHelper;
import de.rayzs.pat.utils.permission.PermissionPlugin;
import de.rayzs.pat.utils.response.ResponseHandler;
import de.rayzs.pat.api.event.PATEventHandler;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import de.rayzs.pat.utils.subargs.*;
import java.util.stream.Collectors;
import de.rayzs.pat.utils.group.*;
import de.rayzs.pat.utils.*;
import java.util.*;
public class SubArguments {
public static List<String> GENERAL_LIST, BLOCKED_MESSAGE, PLAYER_NAMES, ONLINE_PLAYERS;
public static HashMap<UUID, Arguments> PLAYER_COMMANDS = new HashMap<>();
public static void initialize() {
updateList();
updateMessages();
updatePlayerNames();
PATEventHandler.register(new TabCompletion());
PATEventHandler.register(new ExecuteCommand());
PATEventHandler.register(UpdateList.UPDATE_PLUGIN_EVENT);
PATEventHandler.register(UpdateList.RECEIVE_SYNC_EVENT);
PATEventHandler.register(UpdateList.UPDATE_PLAYER_COMMANDS_EVENT);
PATEventHandler.register(UpdateList.SERVER_PLAYERS_CHANGE_EVENT);
}
public static void updatePlayerNames() {
PLAYER_NAMES = Storage.getLoader().getPlayerNames();
ONLINE_PLAYERS = Storage.getLoader().getOnlinePlayerNames();
}
public static List<String> getPlayerNames() {
return PLAYER_NAMES;
}
public static List<String> getOnlinePlayerNames() {
return ONLINE_PLAYERS;
}
public static void updateList() {
GENERAL_LIST = Storage.Blacklist.getBlacklist().getCommands().stream().filter(command -> command.contains(" ")).collect(Collectors.toList());
Arguments.ARGUMENTS.clearArguments();
GENERAL_LIST.forEach(command -> Arguments.ARGUMENTS.buildArgumentStacks(command));
SubArguments.PLAYER_COMMANDS = new HashMap<>();
}
public static void updateMessages() {
Storage.Files.CUSTOM_RESPONSES.reload();
ResponseHandler.update();
}
public static void handleCommandNode(UUID uuid, ProxyCommandNodeHelper helper) {
final boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
Arguments arguments = PLAYER_COMMANDS.get(uuid);
if (arguments == null) {
return;
}
ArgumentSource source = arguments.TAB_ARGUMENTS;
if (source == null) {
return;
}
final List<String> inputs = source.getAllInputs();
final List<String> actuallyExistingCommands = helper.getChildrenNames();
if (turn) {
List<String> allEntries = inputs.stream().map(StringUtils::getFirstArg).toList();
helper.removeIf(allEntries::contains);
}
final int length = inputs.size();
for (int i = 0; i < length; i++) {
String input;
try {
input = inputs.get(i);
} catch (IndexOutOfBoundsException indexOutOfBoundsException) {
break;
}
final boolean negated = Storage.Blacklist.BlockTypeFetcher.isNegated(input);
if (!negated) {
if (turn && actuallyExistingCommands.contains(StringUtils.getFirstArg(input))) {
helper.add(input, true);
} else helper.removeSubArguments(input);
continue;
}
final Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(input);
if (type == Storage.Blacklist.BlockType.CHAT) {
continue;
}
input = Storage.Blacklist.BlockTypeFetcher.cleanse(input);
if (turn) helper.removeSubArguments(input);
else if (actuallyExistingCommands.contains(StringUtils.getFirstArg(input))) {
helper.add(input, true);
}
}
}
public static void handleCommandNode(UUID uuid, BukkitCommandNodeHelper helper) throws Exception {
final boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
Arguments arguments = PLAYER_COMMANDS.get(uuid);
if (arguments == null) {
return;
}
ArgumentSource source = arguments.TAB_ARGUMENTS;
if (source == null) {
return;
}
final List<String> inputs = new ArrayList<>(source.getAllInputs());
final List<String> argumentsList = new ArrayList<>();
final int length = inputs.size();
for (int i = 0; i < length; i++) {
String input;
try {
input = inputs.get(i);
} catch (IndexOutOfBoundsException indexOutOfBoundsException) {
break;
}
final Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(input);
if (type == Storage.Blacklist.BlockType.CHAT) {
continue;
}
final boolean negated = Storage.Blacklist.BlockTypeFetcher.isNegated(input);
input = Storage.Blacklist.BlockTypeFetcher.cleanse(input);
if (!negated) {
if (turn) argumentsList.add(input);
else helper.removeSubArguments(input);
continue;
}
if (turn) helper.removeSubArguments(input);
else argumentsList.add(input);
}
if (argumentsList.isEmpty()) {
return;
}
helper.spareRecursively(argumentsList);
}
public static List<String> getServerCommands(UUID uuid) {
return getServerCommands(Storage.getLoader().getPlayerServerName(uuid));
}
public static List<String> getServerCommands(String serverName) {
List<String> commands = new ArrayList<>(Storage.Blacklist.getBlacklist().getCommands());
if (!Reflection.isProxyServer())
return commands;
if (serverName == null)
return commands;
List<GeneralBlacklist> blacklists = Storage.Blacklist.getServerBlacklists(serverName);
for (GeneralBlacklist blacklist : blacklists)
commands.addAll(blacklist.getCommands());
return commands;
}
public static List<String> getGroupCommands(UUID uuid) {
return getGroupCommands(uuid, null);
}
public static List<String> getGroupCommands(UUID uuid, String serverName) {
List<String> commands = new ArrayList<>();
List<Group> groups;
if (Storage.getPermissionPlugin() == PermissionPlugin.NONE) {
CommandSender sender = CommandSenderHandler.from(uuid);
groups = GroupManager.getPlayerGroups(sender);
} else {
groups = GroupManager.getPlayerGroups(uuid);
}
if (serverName == null) {
groups.forEach(group -> commands.addAll(group.getCommands()));
return commands;
}
groups.forEach(group -> {
commands.addAll(group.getCommands());
List<String> associatedServerNames = group.getBlacklistServerNames(serverName);
associatedServerNames.forEach(s -> {
commands.addAll(group.getCommands(s));
});
});
return commands;
}
public static String replacePlaceholders(String input) {
String[] split = input.split(" ");
for (int i = 0; i < split.length; i++) {
String s = split[i];
boolean number = NumberUtils.isDigit(split[i]),
online = Storage.getLoader().isPlayerOnline(s),
general = Storage.getLoader().doesPlayerExist(s);
if (online && general) {
split[i] = "%both_players%";
continue;
}
if (online) {
split[i] = "%online_players%";
continue;
}
if (general) {
split[i] = "%players%";
continue;
}
if (number) {
split[i] = "%numbers%";
}
}
return String.join(" ", split);
}
}
@@ -0,0 +1,177 @@
package de.rayzs.pat.plugin.subarguments.events;
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
import de.rayzs.pat.plugin.subarguments.SubArguments;
import de.rayzs.pat.utils.message.MessageTranslator;
import de.rayzs.pat.utils.response.ResponseHandler;
import de.rayzs.pat.api.storage.Storage;
import de.rayzs.pat.utils.sender.CommandSender;
import de.rayzs.pat.utils.sender.CommandSenderHandler;
import de.rayzs.pat.utils.subargs.*;
import de.rayzs.pat.utils.*;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class ExecuteCommand extends ExecuteCommandEvent {
@Override
public void handle(ExecuteCommandEvent event) {
String command = event.getCommand();
command = command.startsWith("/")
? command.substring(1)
: command;
final String displayCommand = StringUtils.replaceTriggers(
command, "",
"\\", "<", ">", "&"
);
CommandSender sender = CommandSenderHandler.from(event.getSenderObj());
if (sender == null)
return;
UUID uuid = sender.getUniqueId();
String serverName = sender.getServerName();
String playerName = sender.getName();
if (isBlocked(sender, command)) {
event.setBlocked(true);
event.setCancelled(true);
MessageTranslator.send(event.getSenderObj(),
ResponseHandler.getResponse(uuid, playerName, serverName, event.getCommand()),
"%command%", displayCommand);
return;
}
if (!event.isBlocked())
return;
event.setCancelled(true);
MessageTranslator.send(
event.getSenderObj(),
ResponseHandler.getResponse(uuid, playerName, serverName, event.getCommand(), Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE.getLines()),
"%command%", StringUtils.getFirstArg(displayCommand)
);
}
private boolean isBlocked(CommandSender sender, String command) {
final Arguments arguments = SubArguments.PLAYER_COMMANDS.getOrDefault(sender.getUniqueId(), Arguments.ARGUMENTS);
final List<String> commands = new ArrayList<>(arguments.CHAT_ARGUMENTS.getGeneralArgument().getInputs());
final String firstArgument = StringUtils.getFirstArg(command);
final String blockBaseCommandStr = firstArgument + " -_";
final boolean blockBaseCommand = commands.contains(blockBaseCommandStr);
if (!command.contains(" ")) {
return blockBaseCommand;
}
if (blockBaseCommand) {
commands.remove(blockBaseCommandStr);
}
boolean inCommands = commands.stream().anyMatch(c -> StringUtils.getFirstArg(c).equalsIgnoreCase(firstArgument));
boolean negationInCommands = commands.stream().anyMatch(c -> StringUtils.getFirstArg(c).equalsIgnoreCase("!" + firstArgument));
if (!inCommands && !negationInCommands) {
return false;
}
boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
boolean listed = isListed(command, commands);
boolean negated = isListed("!" + command, commands);
if (!listed && !inCommands) {
listed = turn;
}
if (negated) {
listed = !turn;
}
return turn != listed;
}
private boolean isListed(String command, List<String> commands) {
boolean listed = false;
final String unmodifiable = command;
final String firstArgUnmodifiable = StringUtils.getFirstArg(unmodifiable);
commands = commands.stream().map(c -> {
if (c.contains("%hidden")) {
return c.replace("%hidden_", "%");
}
return c;
}).toList();
List<String> placeholderCommands = commands.stream().filter(s ->
StringUtils.getFirstArg(s).equalsIgnoreCase(firstArgUnmodifiable) && s.contains("%")
).toList();
if (!placeholderCommands.isEmpty()) {
command = SubArguments.replacePlaceholders(command);
}
String cpyCommand;
for (String c : commands) {
cpyCommand = command;
if (listed)
break;
if (cpyCommand.contains("%both_players%")) {
if (c.contains("%online_players%"))
cpyCommand = StringUtils.replace(command, "%both_players%", "%online_players%");
if (c.contains("%players%"))
cpyCommand = StringUtils.replace(command, "%both_players%", "%players%");
}
if (c.contains("%offline_players%")) {
final String[] cSplit = c.split(" ");
final String[] cpyCommandSplit = cpyCommand.split(" ");
for (int i = 0; i < cSplit.length; i++) {
if (i >= cpyCommandSplit.length) {
break;
}
if (cSplit[i].equals("%offline_players%") && !cpyCommandSplit[i].endsWith("players%")) {
cpyCommandSplit[i] = "%offline_players%";
}
}
cpyCommand = String.join(" ", cpyCommandSplit);
}
boolean ends = c.endsWith("_-");
if (ends) {
c = StringUtils.replace(c, "_-", "");
if (c.endsWith(" "))
c = StringUtils.replaceLast(c, " ", "");
}
listed = c.equalsIgnoreCase(cpyCommand) || cpyCommand.startsWith(c + " ");
if (listed && ends && cpyCommand.length() > c.length()) {
listed = false;
break;
}
}
return listed;
}
}
Loaded 100 of 159 files, more files were not shown because too many files have changed in this diff. Show more