Compare commits

...
256 Commits
Author SHA1 Message Date
Luck 6f54e57d43 Implement luckiness calculator 2021-04-01 06:45:02 +01:00
Luck d150bd39a5 Send messaging service ping for creategroup command (#2956) 2021-03-25 22:28:52 +00:00
Federico López f813122468 Fix 'meta settemp' ignoring temporary modifier (#2958) 2021-03-24 21:28:00 +00:00
Luck 2e62c98c45 Avoid blocking worker pool for command timeout check (#2951)
3rd time lucky...
2021-03-24 12:40:24 +00:00
Luck f0e1a8f092 Remove some BungeeCord/Velocity command aliases 2021-03-23 13:45:34 +00:00
Luck 2dc6902001 Fix deadlock when lots of commands are executed at the same time (#2951) 2021-03-23 11:10:18 +00:00
Luck 21f5c24847 Optimize Bukkit/Nukkit ChildProcessor refresh (#2952) 2021-03-20 18:17:17 +00:00
Luck 6b2c4bca58 Change command manager lock handling to avoid non-fair tryLock call 2021-03-20 15:28:45 +00:00
Luck 4564a97371 Update fabric-loop, explicitly set archivesBaseName to 'luckperms' (#2880) 2021-03-19 20:39:42 +00:00
Luck 1df66255e4 Fix RCON permission checking for LP commands on Bukkit (#2948) 2021-03-19 20:03:21 +00:00
Luck 1c7e2dfb8c Fix very lenient duration parsing (#2940) 2021-03-19 19:59:15 +00:00
Luck ad1ba3c126 Fix player locale retrieval on Bukkit 1.8 (#2930) 2021-03-19 19:33:18 +00:00
lucko 0f63b024e4 Update readme to clarify build output dirs 2021-03-15 12:17:02 +00:00
Daniil a17b441165 Don't rely on getPackage to determine generated class name (#2937) 2021-03-15 12:12:02 +00:00
Luck e3138eb94c Make console detection more resilient against spoofed UUIDs 2021-03-13 14:25:33 +00:00
Luck 53bb61f9b2 Allow server name to be specified by a system property 2021-03-13 14:16:02 +00:00
Luck 370e2aed0d Add some missing null annotations 2021-03-13 14:14:59 +00:00
Luck b7f05a2f91 API 5.3 2021-03-04 15:13:40 +00:00
Luck bb01c74642 Fix typo 2021-03-04 15:01:47 +00:00
Luck ba71345cbd Improve Vault sync lookup error message 2021-03-04 14:58:00 +00:00
Luck 2c636c5ac6 Further javadoc improvements 2021-03-04 00:25:11 +00:00
Luck 0884dd7e97 Add package description javadocs to the API 2021-03-03 11:48:20 +00:00
Luck c948632dfa Create a copy of args for command timeout catcher 2021-03-02 17:53:10 +00:00
Luck 9647b7de43 Translation file fixes 2021-03-01 13:20:47 +00:00
Luck e7f2a8d713 Add config option to disable built-in contexts 2021-03-01 11:18:21 +00:00
Luck bf0ac1a867 Micro-optimise some frequently iterated lists 2021-03-01 10:38:48 +00:00
Luck 89894353b6 Add web editor deletion cause 2021-03-01 10:16:21 +00:00
Luck ca65e2175d Add getMetaValue API method that accepts a value transformer function 2021-02-28 12:04:23 +00:00
Luck 84c5b818b8 Add cancellable UserUnloadEvent 2021-02-27 18:24:39 +00:00
Luck 843eaaed0c Fix getLocale on older Bukkit releases (#2915) 2021-02-27 15:43:46 +00:00
Luck 4ff2c75538 Add config option to set Hikari keepalive property 2021-02-22 23:02:43 +00:00
Luck 734b011dc7 Some minor tidying 2021-02-22 22:51:45 +00:00
Federico López 4018493285 Fix holder type and name on hover and click events in meta info entries (#2906) 2021-02-22 11:14:45 +00:00
Hai-tun 435e039b38 Bump PostgreSQL version (#2903) 2021-02-20 11:09:07 +00:00
Luck 7579bbe549 Update gradle wrapper 2021-02-20 11:06:41 +00:00
Luck 16ee500054 Fix NoClassDefFoundError when loading extensions on non-JiJ platforms 2021-02-19 16:33:59 +00:00
Luck 88f040e822 Allow extensions to opt to be added to the parent classloader instead 2021-02-19 16:25:11 +00:00
Luck a766c0e9aa Support the web editor payload format in /lp import
This means that if a user accidentally deletes data locally but still has a working web editor session, they can automatically recover the data contained in the session by importing it with the --upload flag.

Of course, this will only be able to recover the data present in the session. The sensible thing would be to create proper backups (using /lp export or otherwise) - but hey, people are dumb.
2021-02-19 14:33:54 +00:00
Luck 40e8038604 Fix non-lower-case meta lookups via the API (#2900) 2021-02-19 09:43:37 +00:00
Luck 3c4091018c Fix bukkit legacy 1.7 build 2021-02-18 13:28:47 +00:00
lucko 75d8f00400 Implement jar-in-jar loader system (#2899)
This fixes an issue that prevented LuckPerms from loading on Java 16
2021-02-18 12:21:17 +00:00
Luck cb5f403043 Invalidate context cache on Bukkit PlayerJoinEvent
The players world is first defined just before this event, so we need to invalidate here as well as on world change
2021-02-16 17:38:45 +00:00
Luck 997e3c7ef7 Add timeout for command executions (#2887) 2021-02-10 11:38:35 +00:00
Luck cb9e0899fc Misc refactoring and tidying up 2021-02-10 11:12:30 +00:00
Luck ab009ed110 Don't use pretty-printed JSON when uploading to bytebin for web apps 2021-02-05 12:44:48 +00:00
Luck c8b89f245e Tidy up RabbitMQMessenger a bit 2021-02-05 12:00:16 +00:00
Callum Seabrook d8aefd23d3 Added virtual host support for RabbitMQ (#2877) 2021-02-05 11:38:13 +00:00
ruViolence a8dfd38fe6 RabbitMQ messenger support (#2874) 2021-02-04 17:10:30 +00:00
Luck b7ac05a0a5 Improve Fabric initial connection debug 2021-02-04 13:29:33 +00:00
Luck b8e044c4e3 Fix Sponge build 2021-01-31 12:51:16 +00:00
Federico López b708d04141 Improve CraftBukkit detection (#2867) 2021-01-31 11:01:44 +00:00
Federico López d485017744 Fix trailing period in translation bundle (#2868) 2021-01-31 11:00:55 +00:00
Luck 35f5944d7b Make separated flat-file read/writes atomic (#2860)
This has become an issue as a result of removing the global per user/group/track IO locks in 478fddc486
2021-01-29 11:42:48 +00:00
Federico López d12be01ecd Fix checking for table existence on SQL storage types (#2864) 2021-01-29 09:34:55 +00:00
Conclure 8043b84dc4 Substitute null check with Configuration#isSet (#2851) 2021-01-26 11:52:12 +00:00
Luck 284e260bc2 Fix node change events not being called for web editor changes (#2857) 2021-01-26 11:41:38 +00:00
Luck ec296460b2 Always allow console to use LP commands (#2841) 2021-01-22 19:16:53 +00:00
Luck 20fee360fb Don't use a WeakReference to hold platform sender objects (#2838) 2021-01-21 12:58:59 +00:00
Luck cd496fdc39 Default apply-default-negated-permissions-before-wildcards to false on Bukkit/Nukkit (#2787) 2021-01-19 14:34:54 +00:00
Luck f9030825fd Add some more annotations to mark API methods 2021-01-19 14:29:49 +00:00
Luck 0a92597767 Don't use adventure-platform on Sponge (#2822) 2021-01-18 22:57:27 +00:00
Luck 6c34da6b32 Catch another Hikari/classloading issue 2021-01-18 13:18:05 +00:00
Luck d5cefac65d Fix Fabric permissions not being copied during player respawn (#2818) 2021-01-16 18:25:26 +00:00
Luck 2a44572fb2 Fix non-daemon command manager thread sometimes preventing shutdown 2021-01-16 18:24:10 +00:00
Luck 73230bc9b6 Tidy up node + context comparators a bit 2021-01-14 20:45:51 +00:00
Luck be1b9d45fa Show the full redis exception in logger output 2021-01-14 20:43:39 +00:00
Luck 238a4fba75 Rename MapProcessor to DirectProcessor 2021-01-13 18:25:02 +00:00
Luck 33e412f663 Include info about wildcards in permission check command output 2021-01-13 17:55:41 +00:00
Luck c904ede972 Improve & consolidate permission check commands 2021-01-13 16:40:57 +00:00
Luck 489c09ddfc Add /lp track <track> editor command (#2752) 2021-01-13 14:33:01 +00:00
Luck 505c073c8e Add config to control whether display names are returned by the Vault hook 2021-01-09 20:36:08 +00:00
Luck 443ea510bb Implement plugin message messenger service on Fabric 2021-01-06 13:14:41 +00:00
Luck 848c36928f Fix logging in on Fabric using offline mode (#2810) 2021-01-05 10:30:28 +00:00
i509VCB 21abb94796 Fabric (#2029) 2021-01-04 15:23:54 +00:00
Luck 0a99a96188 Tidy up Node add/remove/clear API events 2021-01-02 21:16:45 +00:00
Luck a8b1dc8c07 Only store ids of received messages for 1 hour to prevent high memory usage on instances with high uptime (#2807) 2021-01-02 20:08:56 +00:00
Luck c3581c00d3 Fix verbose command no checks message format 2021-01-02 00:50:18 +00:00
Luck 8124a17adb Conserve expiry time when promoting/demoting (#2794) 2021-01-01 20:25:47 +00:00
Luck 68167490d4 Fix permissible injection issue on Nukkit (#2791, #2799) 2021-01-01 20:00:03 +00:00
Luck 657cf2a45e Brigadier arguments in the same parse tree need unique names (#2798) 2021-01-01 19:38:55 +00:00
Luck d83559b949 Change permission tree size limits to be less restrictive 2021-01-01 18:17:56 +00:00
Luck 8167fbf73f Give false default permissions priority over wildcards
I think this is a good compromise. It won't apply to registered permissions that are defaulted to 'op' (Bukkit) or 'undefined' (Sponge), only to those that are specifically set to false.

The change is configurable, enabled by default for new installs of LP.

Will hopefully go some way to resolving:
- #2787
- https://v2.nucleuspowered.org/docs/nowildcard.html
- NucleusPowered/Nucleus#1093 (and related)

cc: @dualspiral @slipcor
2020-12-23 14:36:31 +00:00
Luck 8dfeef9575 Some misc tidying up 2020-12-23 12:16:14 +00:00
Luck 5c44333892 Move migration commands to a separate jar 2020-12-22 14:53:22 +00:00
Luck 142cdc8e89 Add some unit tests
This is a start at least.. I have some catching up to do!
2020-12-22 14:40:29 +00:00
Luck abb608b856 Support Bukkit-Forge hacks which add enum constants at runtime (#2779) 2020-12-20 15:45:57 +00:00
Luck c28b1949a9 Process 'give default if needed' when saving instead of after each change made in the API (#2775) 2020-12-18 19:17:01 +00:00
Luck 8ef871f6db Fix bug with NodeMap#remove (#2772) 2020-12-15 14:31:04 +00:00
Federico López fa89236e48 Fix translation key used for parent clear (#2773) 2020-12-14 21:49:25 +00:00
Luck 2d4af4c691 Mark a number of API methods as NonExtendable 2020-12-14 16:07:20 +00:00
Luck 16fbf566f3 Ensure child permissions are handled as lowercase when resolving (#2761) 2020-12-14 15:22:41 +00:00
Luck e6a5cb06af Include note in verbose command-exec-as response if there were no matches (#2734) 2020-12-14 15:11:49 +00:00
Luck 7bc422c83f Add soft-dependency on ViaVersion to avoid warning msg (#2771) 2020-12-14 14:54:12 +00:00
lucko 478fddc486 Track individual changes to users/groups instead of writing in full on each save (#2767) 2020-12-13 13:08:15 +00:00
Luck 97d1deec9c Slightly optimize weight and display name lookups 2020-12-11 10:38:57 +00:00
Luck 45188c6334 Fix NPE from null path in AbstractFileWatcher (#2759) 2020-12-09 18:21:54 +00:00
Luck 17f67f6e13 Use case insensitive LIKE command on H2 databases (#2760) 2020-12-09 18:08:17 +00:00
Luck 39a5ccf9a9 Some tidying up 2020-12-09 10:46:22 +00:00
Luck 5fbb80f16a Ensure meta keys are always lowercase, and fix 'similar' comparison case sensitivity (#2760) 2020-12-09 10:38:22 +00:00
Luck 798a539024 Fix saving to flatfile storage when sections become empty (#2755) 2020-12-05 14:28:54 +00:00
Luck 645efb0e5b Cleanup applying bulkupdates to Node objects directly 2020-12-05 14:27:32 +00:00
Luck 5bfbf26e2f Fix ArrayIndexOutOfBoundsException from null environment in BukkitPlayerCalculator 2020-12-04 14:17:35 +00:00
Luck 7d7d40b087 Add some missing arg-based permission checks 2020-12-04 14:12:36 +00:00
Luck e183f520d6 Cleanup EventDispatcher and some other minor tidying 2020-12-01 23:31:20 +00:00
Sven Arends 727c2f92c3 PowerRanks migration (#2718) 2020-11-26 17:52:31 +00:00
Luck fdd3b117f1 Reduce translation cache refresh slightly to 23 hours 2020-11-26 17:24:37 +00:00
Luck 8a38c5f4b7 Properly open URLClassLoader module on Java 9+ to allow reflection and avoid access warning (#952) 2020-11-26 15:52:39 +00:00
Luck 53fb46ee85 Expose uuid/username lookups and validity checks as events in the API 2020-11-23 23:54:02 +00:00
Luck d136359cd9 Fix Bungee identifyClassLoader method (again) 2020-11-19 16:51:36 +00:00
Luck d449834767 Fix Bungee identifyClassLoader method 2020-11-19 16:50:31 +00:00
powercas_gamer e851234723 Remove debug command & add more usages to commands (#2725) 2020-11-18 23:52:26 +00:00
Federico López 26f7dfcb24 Fix .verbose.enabled and enabled-recording args (#2732) 2020-11-18 23:51:32 +00:00
Luck d1b53f65ae Cleanup flatfile database handling 2020-11-16 01:17:24 +00:00
Luck c39749e526 Use a better approach for avoiding MySQL driver sharing 2020-11-14 14:10:54 +00:00
Luck 23c7eb79d0 Fix leftover code in MariaDbConnectionFactory 2020-11-14 13:50:37 +00:00
Luck 9af6dccd9d Use the non-registering MySQL driver and revert to using DataSource for MariaDB 2020-11-14 13:44:32 +00:00
Luck 129a10aa60 Automatically install translation bundles 2020-11-12 00:28:02 +00:00
Luck 62270bfd93 Set serverTimezone property on MySQL driver 2020-11-11 13:00:02 +00:00
Luck 9f8b4b2404 Fix inf loop when sending messages to command blocks on Bukkit (#2702) 2020-11-10 16:17:23 +00:00
Luck 00d4a2a1da Update MySQL driver to 8.0, cleanup Hikari usage 2020-11-10 16:00:36 +00:00
Luck 4ce8ea21f9 Sort users with no known username to the bottom of the editor menu 2020-11-10 15:04:36 +00:00
Luck 93d0c54687 Cache some PermissionProcessor instances 2020-11-10 15:04:05 +00:00
Luck 6564cc89f4 Fix NPE when player gamemode or world is null 2020-11-07 17:46:38 +00:00
Luck 9796d2421f Player context calculator fixes, fix compat with Sponge API 7 (#2703) 2020-11-07 11:40:26 +00:00
Luck 0ea0ce9d26 Provide 'gamemode' and 'dimension-type' contexts by default
Also, optimize world rewrites
2020-11-07 00:57:57 +00:00
Luck 3f04d439b4 Fix permission check message arg ordering 2020-11-03 12:17:05 +00:00
Federico López 5bdc798237 Allow creategroup command to take weight and display name as optional arguments (#2698) 2020-11-02 09:48:02 +00:00
Federico López 5d0c578da1 Fix bulk update command failing on SQL based storages when tracking operation stats with multiple constraints (#2699) 2020-11-02 09:46:45 +00:00
MrMicky 7854de8991 Move exception printing to logger (#2695) 2020-10-31 22:25:11 +00:00
Luck 4c23f93a67 Improve locale display names 2020-10-30 13:14:52 +00:00
Luck 7b3beae57f Change wiki links from GitHub to luckperms.net 2020-10-28 11:58:41 +00:00
Luck 15d3000fc1 Make storage meta keys translatable 2020-10-28 10:42:47 +00:00
Luck ad174742e9 Implement localisation for displaying durations 2020-10-25 13:39:14 +00:00
Luck ab0e25a56d Fix loading custom en based translations 2020-10-22 09:17:30 +01:00
Luck 6b05e47deb Include expiry in meta info command (#2663) 2020-10-20 13:10:39 +01:00
Luck b9eb022011 Fix null player locale causing NPE (#2678) 2020-10-20 12:25:35 +01:00
Luck 7d47b31bcb Retain compatibility with older velocity versions (#2676) 2020-10-19 15:15:14 +01:00
Federico López f3857090fa Format group info prefix and suffix (#2677) 2020-10-19 14:47:36 +01:00
Luck d7fa9e08f3 Fix various translation issues 2020-10-19 13:24:44 +01:00
Luck 2c7ff2120c Fix legacy codes in formatted holder display names 2020-10-19 12:37:27 +01:00
Federico López 703b18e51c Make bulk update operations a bit more verbose (#2647) 2020-10-16 12:11:30 +01:00
Luck 3b779dbbd3 Add note to build scripts about our repackaged version of the adventure library 2020-10-16 00:17:42 +01:00
Luck 9af397c2bc Change some of the wording slightly in the translations command 2020-10-15 23:47:51 +01:00
Luck b6e5b0bd47 Fix sending messages on Velocity proxies 2020-10-15 23:35:59 +01:00
Luck 6e7c49488d Add /lp translations command 2020-10-15 23:02:11 +01:00
Underscore11 c5841b58a7 Fix some formatting issues (#2671) 2020-10-15 00:50:00 +01:00
Federico López e8b1214219 Make import take 3 args max so lp import <code> --upload --replace is possible (#2651) 2020-10-14 12:38:05 +01:00
Luck 4811129ab1 Convert to text components and implement new translation system 2020-10-14 12:26:09 +01:00
Luck 63878166db Release 5.2 2020-10-14 12:18:50 +01:00
Luck 2ea43d4b2e Some misc refactoring and cleanup 2020-09-10 21:13:12 +01:00
Luck 442c7d46f9 Ensure that player data is removed even if a corresponding user doesn't exist 2020-09-07 18:16:25 +01:00
Luck 971bb67b51 Add support for user deletion from the web editor 2020-09-07 18:13:33 +01:00
Luck 020aff66aa Refactor web editor session handling 2020-09-07 18:06:40 +01:00
Luck 198b86d7c3 Implement the basis for deleting player uuid data from storage 2020-09-07 17:22:42 +01:00
Luck 84e7fd4d09 Update usage string for /lp import 2020-09-07 16:55:08 +01:00
Luck 4027129052 Default to merge when using /lp import (#2601) 2020-09-07 16:54:27 +01:00
Luck 63f67ca72c Default use-vault-server to false (#2599) 2020-09-07 16:51:07 +01:00
Luck 2adaea2dac Avoid calling JsonObject#size for compat with older gson versions (#2598) 2020-09-05 22:00:56 +01:00
Luck 5e48224c78 Use a map factory when resolving permissions for cached data 2020-08-30 09:14:33 +01:00
Luck cc1d8984da Config option for registering brigadier command list data 2020-08-30 09:13:59 +01:00
Luck 8d9b4182f4 Modify issue templates slightly 2020-08-29 18:37:21 +01:00
Luck f972113d11 Add GitHub issue templates
Credit to @Andre601 and PR #1735 for the original proposal of these templates.

I've held off from adding this for a while, but I now feel that the GitHub UI is nice enough to justify the change.
2020-08-29 18:32:39 +01:00
Luck 4d5a24f2c4 ContextSetJsonSerializer output should be sorted 2020-08-14 16:25:55 +01:00
Luck e2b575dd24 Handle null or empty server/world field in SQL (#2553) 2020-08-13 11:40:33 +01:00
Luck 7fae141e33 Ignore cancelled events for OP command disabling (#2527) 2020-08-13 11:03:24 +01:00
Luck 6f90e545fc Don't attempt further poll operations after SQL messenger has closed (#2516) 2020-08-13 10:49:18 +01:00
Luck ee3bb22c2c Improve Bukkit identifyClassLoader (#2444) 2020-08-13 10:31:20 +01:00
Luck 361a4d66bc Refactor exporter into separate classes 2020-08-13 10:12:36 +01:00
Luck e1bac438aa Add /lp export --without-groups (#2498) 2020-08-13 10:00:49 +01:00
Luck ac9706b83f Ignore FileAlreadyExistsException in MoreFiles#createDirectories (#2525) 2020-08-10 22:29:12 +01:00
Luck fea757887c Use official configurate 3.7 branch 2020-08-01 11:08:46 +01:00
Luck 1eab127f50 Refactor op command detection 2020-08-01 10:20:49 +01:00
Luck 92e008ff0a Fix bug in PermissionHolder#hasNode (#2490)
Regression introduced in bd6d3ab7c0
2020-07-26 14:14:41 +01:00
Luck 9659333d0e Some misc cleanup for migration commands 2020-07-25 16:56:52 +01:00
Larry d8020e77fe Fix import with no users object (#2488, #2489) 2020-07-24 11:43:49 +01:00
Luck 232d17436c Rename config based static calculator 2020-07-21 11:26:16 +01:00
Luck 1461651e22 Include a wider range of potential contexts in web editor payload (#2470) 2020-07-21 11:25:50 +01:00
Luck ef556f7cf7 Pre-generate event classes (#2463) 2020-07-16 21:00:17 +01:00
Luck 47ca6b162b Catch throwable instead of exception when handling hikari errors (#2444) 2020-07-16 20:26:54 +01:00
Luck f72a5cb6b5 Ensure group/track names are always lowercase'd when created via the API (#2440) 2020-07-16 20:19:33 +01:00
Luck cd0fd80b33 Impose 15 second timeout on all http calls (#2436) 2020-07-16 20:15:53 +01:00
Sam Goodger 0fd7f643a7 Add option to use bytebin for exports/imports (#2432) 2020-07-04 20:41:34 +01:00
Mark 6c7c1b67b8 Try to reopen Redis pub-sub connection on failure (#2430) 2020-07-04 20:08:58 +01:00
Luck 4514a17eaf Remove MRUCache
Now we're using ConcurrentHashMap, it's usefulness in terms of performance is debatable
2020-07-03 18:23:34 +01:00
Luck adbd2fc81f Use ConcurrentHashMap instead of Caffeine in CachedDataManager
The behaviour of Caffeine cache invalidation calls is "undefined for an entry that is being loaded (or reloaded)" - this causes a nasty race condition in CachedDataManager, because we rely on the call to #invalidate to completely clear the cache and prevent old/outdated data from sticking around & being used for permission queries.

This is an unfortunate characteristic of Caffeine, because other than that, it is perfect for our use-case.
2020-07-03 17:57:53 +01:00
Luck 8b506b6a95 Don't re-use PermissionCache instances 2020-07-03 15:18:58 +01:00
Luck 426c8565fd Small optimization to processExportedPermissions 2020-07-03 14:57:46 +01:00
Luck bd6d3ab7c0 Optimize PermissionHolder#hasNode 2020-07-02 12:28:30 +01:00
Luck d12d13d6ea Fix NodeMap#size method and rename some things 2020-07-02 12:16:13 +01:00
Luck cc08390abe Remove NodeMap immutable cache 2020-07-02 12:06:37 +01:00
Luck b460e282b1 Add ConstraintNodeMatcher toString method for use in commands 2020-07-02 10:44:52 +01:00
Tobi 005d19f2a3 Fix JavaDoc typo (#2421) 2020-07-02 10:42:37 +01:00
Jonas Baars 8817e17d2c Fix typo in config file 2020-06-29 15:17:42 +01:00
Luck 0f23b7a460 Avoid calling #stream on the result of Bukkit getOnlinePlayers 2020-06-25 10:24:33 +01:00
Luck 21ae1dbac0 Fix potential race condition in MRUCache 2020-06-21 22:07:53 +01:00
Luck 6cb0f5e810 Use a non-async cache in CachedDataManager 2020-06-21 21:23:57 +01:00
Luck 2ac7d3dfe6 Refactor command argument parsing 2020-06-21 19:58:17 +01:00
Luck bfaa543ecd Fix NPE in ConfigurateConfigAdapter#getStringList (#2399) 2020-06-21 10:18:27 +01:00
Luck f893b1c632 Add optional time parameters to permission/parent removetemp commands (#1384) 2020-06-20 22:01:27 +01:00
Luck cb5a28f043 Use the only/default track if one is not specifed in the promote/demote command (#1581) 2020-06-20 21:03:01 +01:00
Luck bd9718c5af Add log notification filters (#1980) 2020-06-20 20:46:54 +01:00
Luck 97a0dbebcb Add DataTypeFilter#NONE 2020-06-13 21:07:59 +01:00
Luck df324de9ec Add DataTypeFilter 2020-06-12 23:14:33 +01:00
Luck 6fa690a49d Update API pom description 2020-06-12 20:36:41 +01:00
Luck 2bb1aa7511 Change behaviour of resolveInheritanceTree when 'resolve inheritance' flag is false 2020-06-12 20:34:57 +01:00
Luck 0bef0902c0 Update some dependencies 2020-06-10 20:41:39 +01:00
Luck f10f60e27f Define dependency on Vault during enable (#1959) 2020-06-10 20:24:11 +01:00
Luck 91337b49ea Just use the section char instead of some other random one
Idk wtf I was thinking
2020-06-08 23:47:10 +01:00
Luck f5e41f7e7e Cleanup chat meta commands 2020-06-08 23:44:25 +01:00
Luck fe0e82f285 Verbose command shouldn't be able to run as console 2020-06-04 14:46:11 +01:00
Luck 8996cf02af Add player argument to'/lp verbose command' to execute the test command as another player 2020-06-04 01:32:56 +01:00
Luck e37c77a1be Add '/lp verbose command <command>' for easy testing of command permissions 2020-06-03 22:32:24 +01:00
Luck 11998b2dd6 Some misc cleanup 2020-06-03 21:20:41 +01:00
Luck 8754123535 Fix parsing second optional argument in editor command 2020-05-30 02:39:37 +01:00
Luck 91d75424f4 Include users which inherit the group when running /lp group <group> editor 2020-05-30 02:13:18 +01:00
Luck c5c99abd16 Improve argument based perm checks for the editor 2020-05-30 01:54:18 +01:00
Luck 6c88f7629e Add optional filter argument to editor command 2020-05-30 01:47:31 +01:00
Luck 98c71739f8 Fix user ordering in the editor 2020-05-30 01:37:24 +01:00
Luck 25551641fc Add option to merge into instead of overriding existing data in imports (#2324) 2020-05-28 21:36:06 +01:00
Luck 00b701f129 Improve undo command generation (#2318) 2020-05-28 20:53:07 +01:00
Luck ab082aa311 Group names should always be lowercase in inheritance nodes 2020-05-28 00:49:46 +01:00
Joshua Schmitt dc32c84bb3 Increase world column max length (#2334) 2020-05-27 14:02:53 +01:00
Luck 0bb4161397 Use nicer toString for Durations in log messages 2020-05-27 10:46:24 +01:00
Luck 4a049ca732 Use contains instead of startsWith for context tab completions 2020-05-27 10:43:30 +01:00
Luck d5ac45d230 Formalize more of the contexts spec 2020-05-25 22:46:26 +01:00
Luck 6b3e4bdc71 Add ContextUpdateEvent and related functionality 2020-05-25 21:49:49 +01:00
Luck 5c0d82f306 Refactor config handler classes 2020-05-25 10:42:32 +01:00
Luck 5a6176def5 Enforce removal of server=global and world=global contexts at a higher level 2020-05-21 17:30:13 +01:00
Luck 13ebc87b29 Fix compatibility with modified SimplePluginManager in Mohist fork
https://github.com/Mohist-Community/Mohist/blob/eab0f722a48759152f5d562b39689317f647ce99/src/main/java/org/bukkit/plugin/SimplePluginManager.java#L674
2020-05-20 21:37:07 +01:00
Luck 1ca1bcf1d1 Make getUniqueUsers more resilient to invalid uuids 2020-05-20 21:23:40 +01:00
Luck ea5a05d770 Fix incorrectly reading node value from the value field when reading from the flatfile meta section (#2312) 2020-05-20 18:22:10 +01:00
Luck ed85ab1bfd Change ContextSet 'satisfy' behaviour (#2300) 2020-05-20 14:51:03 +01:00
Luck c09e4a1aa0 Update web app urls 2020-05-20 14:45:20 +01:00
Luck ee36fa9d81 Fix prefix being displayed twice in extensions info section 2020-05-19 17:47:07 +01:00
Luck bfa5fc43cd Rename getWithPermission method internally 2020-05-19 17:45:16 +01:00
Luck 5d6389249a Fix bug with searching for group permissions via the api 2020-05-19 13:32:06 +01:00
Luck 637cb0d836 Fix group info command 2020-05-19 09:55:00 +01:00
Luck bfebe6a5d0 Cleanup MetaStack, cache the computed prefix/suffix when meta accumulator completes 2020-05-19 00:36:39 +01:00
Luck 4cbbbd390f Don't schedule command list updates if the server is stopping (#2301) 2020-05-16 18:19:05 +01:00
Luck c120fa6a4d Fix startup on Nukkit (#2290) 2020-05-16 11:52:51 +01:00
Luck 918ea7503a Fix bug with duplicated users in editor (lucko/LuckPermsWeb#235) 2020-05-13 11:20:11 +01:00
Luck dbe07827bd Update readme 2020-05-12 23:12:53 +01:00
Luck 98eb756951 Add contextual data section to group info command too 2020-05-12 18:34:07 +01:00
Luck 86eeeb5b94 Slightly change plugin prefix 2020-05-12 17:54:06 +01:00
Luck a3e6628e11 Improve user info command 2020-05-12 16:54:02 +01:00
Luck 84bc4217de Fix command arg rewriting 2020-05-12 16:35:43 +01:00
Luck b88819b9bb Cleanup Bukkit/Nukkit dummy classes, some aren't necessary anymore 2020-05-11 21:58:24 +01:00
Luck c7a0e59919 Catch RejectedExecutionException in BufferedRequest (#2289) 2020-05-11 21:15:42 +01:00
Luck 9984d4be42 Optimize ActionLog and Paginated util 2020-05-11 21:00:42 +01:00
Luck a1c91b9007 Improve sync task performance 2020-05-11 13:46:02 +01:00
Luck 6a256d59f5 Fix null check in selectAllGroupPermissions 2020-05-11 13:12:30 +01:00
Luck fca2f1e6de Optimize loading lots of groups from SQL storage types (#2287) 2020-05-11 12:54:42 +01:00
Luck ec7994a561 Print more useful debug message when a LinkageError is thrown due to bad SLF4J classloading
This is a longstanding issue, mostly caused by plugins with bad Maven shade configurations.

https://github.com/lucko/LuckPerms/issues?q=slf4j
2020-05-11 01:41:01 +01:00
Luck 2839c36ea2 Fix NPE in Nukkit disconnect handling (#2269) 2020-05-10 22:24:47 +01:00
Luck 9f22bf2fbf Update the client commands list when permissions are changed (#2262) 2020-05-10 22:18:01 +01:00
Luck 5f0df1b167 Increase editor users limit to 1000 & sort users according to their max inherited group weight 2020-05-10 16:31:35 +01:00
625 changed files with 25365 additions and 13839 deletions

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
---
name: 🐛 ​ Bug report
about: Report an issue or problem with the way LuckPerms is functioning.
title: ''
labels: 'type: issue'
assignees: ''
---
<!-- Before going any further, please check to see if your problem is fixed by updating to a newer version. The latest development builds can be obtained from https://luckperms.net/download -->
### Description
<!-- Please provide a short description of the issue in the space below. -->
### Reproduction steps
<!-- Please provide a clear list of steps we should follow in order to reproduce your issue in the space below. -->
1. Open the config.yml file and set example to true.
2. Restart the server
3. Run /lp user example permission set x from the console
4. See error
### Expected behaviour
<!-- Please provide a description of what you expected to happen. -->
### Environment details
<!-- Please provide details of your server environment in the space below. -->
* Server type/version: `ExampleSpigot` running version `1.12.2` build `???`
* LuckPerms version: `v???`
<!-- If you think it would be helpful, please also include a "pastebin" of any relevant config files or log output. You should use https://gist.github.com/ to upload, then include the link below. -->
### Any other relevant details
<!-- Please include any other relevant details in the space below. -->
+5
View File
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: 💬 ​ Ask a question
url: https://discord.gg/luckperms
about: We use Discord to provide support for the project. If you have a question, need help, or aren't sure if you've found a bug or not, please come and talk to us there!
+16
View File
@@ -0,0 +1,16 @@
---
name: 💡 ​ Suggestion
about: Suggest an idea for an improvement or change to LuckPerms.
title: ''
labels: 'type: suggestion'
assignees: ''
---
### Description
<!-- Please provide a short description of the suggestion in the space below. -->
### Proposed behaviour
<!-- Please provide a short explanation of how the feature should work / be changed, and how this will effect the project. -->
+4 -4
View File
@@ -1,6 +1,6 @@
### :speech_balloon: Looking for support?
Details about support for the project can be found [here, on the Wiki Homepage](https://github.com/lucko/LuckPerms/wiki#support).
Details about support for the project can be found [here, on the Wiki Homepage](https://luckperms.net/wiki/Home#support).
### :bug: Reporting bugs?
@@ -16,11 +16,11 @@ If you make any changes or improvements to the plugin which you think would be b
LuckPerms loosely follows the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). Generally, try to copy the style of code found in the class you're editing.
If you're considering submitting a substantial pull request, please open an issue so we can discuss the change before starting work on the contribution. Most pull requests are happily accepted, but larger changes may have an inpact on the maintainability of the project, and require more consideration.
If you're considering submitting a substantial pull request, please open an issue so we can discuss the change before starting work on the contribution. Most pull requests are happily accepted, but larger changes may have an impact on the maintainability of the project, and require more consideration.
#### Project Layout
The project is split up into a few seperate modules.
The project is split up into a few separate modules.
* **API** - The public, semantically versioned API used by other plugins wishing to integrate with and retrieve data from LuckPerms. This module (for the most part) does not contain any implementation itself, and is provided by the plugin.
* **Common** - The common module contains most of the code which implements the respective LuckPerms plugins. This abstract module reduces duplicated code throughout the project.
* **Bukkit, BungeeCord, Sponge, Nukkit & Velocity** - Each use the common module to implement plugins on the respective server platforms.
* **Bukkit, BungeeCord, Sponge, Nukkit, Velocity & Fabric** - Each use the common module to implement plugins on the respective server platforms.
+14 -11
View File
@@ -1,21 +1,24 @@
![alt text](https://i.imgur.com/ToguFkQ.png "Banner")
![](https://i.imgur.com/ToguFkQ.png "Banner")
# LuckPerms
[![Build Status](https://ci.lucko.me/job/LuckPerms/badge/icon)](https://ci.lucko.me/job/LuckPerms/)
[![javadoc](https://javadoc.io/badge2/net.luckperms/api/javadoc.svg)](https://javadoc.io/doc/net.luckperms/api)
[![Maven Central](https://img.shields.io/maven-metadata/v/https/repo1.maven.org/maven2/net/luckperms/api/maven-metadata.xml.svg?label=maven%20central&colorB=brightgreen)](https://search.maven.org/artifact/net.luckperms/api)
[![Discord](https://img.shields.io/discord/241667244927483904.svg?logo=discord&label=)](https://discord.gg/luckperms)
[![Discord](https://img.shields.io/discord/241667244927483904.svg?label=discord&logo=discord)](https://discord.gg/luckperms)
LuckPerms is an advanced permissions implementation aiming to be a fast, reliable and flexible alternative to existing permission plugins. The project's main goals are centered around high performance and a wide feature set, filling the gaps of functionality and building upon existing features found in other plugins.
LuckPerms is a permissions plugin for Minecraft servers. It allows server admins to control what features players can use by creating groups and assigning permissions.
LuckPerms also includes an extensive API for developers, and support for a variety of Minecraft server software & data storage options.
The latest downloads, wiki & other useful links can be found on the project homepage at [luckperms.net](https://luckperms.net/).
Still not convinced? More information can be found on the wiki, under: [Why LuckPerms?](https://github.com/lucko/LuckPerms/wiki/Why-LuckPerms)
It is:
## Useful Links
* **fast** - written with performance and scalability in mind.
* **reliable** - trusted by thousands of server admins, and the largest of server networks.
* **easy to use** - setup permissions using commands, directly in config files, or using the web editor.
* **flexible** - supports a variety of data storage options, and works on lots of different server types.
* **extensive** - a plethora of customization options and settings which can be changed to suit your server.
* **free** - available for download and usage at no cost, and permissively licensed so it can remain free forever.
The latest **downloads** can be found on the [project's homepage](https://luckperms.net/).
More information about the project & how to use the plugin can be found in the [wiki](https://github.com/lucko/LuckPerms/wiki).
For more information, see the wiki article on [Why LuckPerms?](https://luckperms.net/wiki/Why-LuckPerms)
## Building
LuckPerms uses Gradle to handle dependencies & building.
@@ -31,7 +34,7 @@ cd LuckPerms/
./gradlew build
```
You can find the output jars in the `build/libs` directories.
You can find the output jars in the `loader/build/libs` or `build/libs` directories.
## Contributing
#### Pull Requests
@@ -44,7 +47,7 @@ The project is split up into a few separate modules.
* **API** - The public, semantically versioned API used by other plugins wishing to integrate with and retrieve data from LuckPerms. This module (for the most part) does not contain any implementation itself, and is provided by the plugin.
* **Common** - The common module contains most of the code which implements the respective LuckPerms plugins. This abstract module reduces duplicated code throughout the project.
* **Bukkit, BungeeCord, Sponge, Nukkit & Velocity** - Each use the common module to implement plugins on the respective server platforms.
* **Bukkit, BungeeCord, Sponge, Fabric, Nukkit & Velocity** - Each use the common module to implement plugins on the respective server platforms.
## License
LuckPerms is licensed under the permissive MIT license. Please see [`LICENSE.txt`](https://github.com/lucko/LuckPerms/blob/master/LICENSE.txt) for more info.
+8 -4
View File
@@ -1,8 +1,9 @@
group = 'net.luckperms'
project.version = '5.1'
project.version = '5.3'
dependencies {
compileOnly 'org.checkerframework:checker-qual:2.5.5'
compileOnly 'org.checkerframework:checker-qual:3.8.0'
compileOnly 'org.jetbrains:annotations:20.1.0'
}
// Only used occasionally for deployment - not needed for normal builds.
@@ -12,10 +13,13 @@ if (project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePass
javadoc {
title = 'LuckPerms API (v' + project.ext.apiVersion + ')'
options.overview = 'javadoc/overview.html'
options.encoding = 'UTF-8'
options.charSet = 'UTF-8'
options.links(
'https://docs.oracle.com/javase/8/docs/api/'
'https://docs.oracle.com/javase/8/docs/api/',
'https://checkerframework.org/api/',
'https://javadoc.io/static/org.jetbrains/annotations/20.1.0/'
)
options.addStringOption('Xdoclint:none', '-quiet')
}
@@ -56,7 +60,7 @@ if (project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePass
pom {
project {
name 'LuckPerms API'
description 'An advanced permissions plugin for Bukkit/Spigot, BungeeCord, Sponge, Nukkit and Velocity.'
description 'A permissions plugin for Minecraft servers.'
url 'https://luckperms.net'
licenses {
+19
View File
@@ -0,0 +1,19 @@
<body>
<p>
LuckPerms is a permissions plugin for Minecraft servers. It allows server admins to control what
features players can use by creating groups and assigning permissions.
</p>
<h4>Useful Links</h4>
<ul>
<li><a target="_top" href="https://luckperms.net">Project Website</a></li>
<li><a target="_top" href="https://luckperms.net/wiki/Developer-API">Wiki - API Introduction</a></li>
<li><a target="_top" href="https://luckperms.net/wiki/Developer-API-Usage">Wiki - API Usage</a></li>
</ul>
<h4>Maven</h4>
<p>
The API artifact is deployed to Maven Central under
<a target="_top" href="https://search.maven.org/artifact/net.luckperms/api">
group id: <b><code>net.luckperms</code></b>, artifact id: <b><code>api</code></b>.
</a>
</p>
</body>
@@ -48,6 +48,7 @@ import net.luckperms.api.track.Track;
import net.luckperms.api.track.TrackManager;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.ApiStatus.Internal;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
@@ -131,6 +132,7 @@ public interface LuckPerms {
* <li>{@code org.bukkit.entity.Player}</li>
* <li>{@code net.md_5.bungee.api.connection.ProxiedPlayer}</li>
* <li>{@code org.spongepowered.api/entity.living.player.Player}</li>
* <li>{@code net.minecraft.server.network.ServerPlayerEntity} (Fabric)</li>
* <li>{@code cn.nukkit.Player}</li>
* <li>{@code com.velocitypowered.api.proxy.Player}</li>
* </ul>
@@ -194,21 +196,6 @@ public interface LuckPerms {
*/
@NonNull ContextManager getContextManager();
/**
* Gets the {@link NodeBuilderRegistry}.
*
* @return the node builder registry
*/
@NonNull NodeBuilderRegistry getNodeBuilderRegistry();
/**
* Gets the {@link QueryOptionsRegistry}.
*
* @return the query options registry
* @since 5.1
*/
@NonNull QueryOptionsRegistry getQueryOptionsRegistry();
/**
* Gets the {@link MetaStackFactory}.
*
@@ -220,14 +207,6 @@ public interface LuckPerms {
*/
@NonNull MetaStackFactory getMetaStackFactory();
/**
* Gets the {@link NodeMatcherFactory}.
*
* @return the node matcher factory
* @since 5.1
*/
@NonNull NodeMatcherFactory getNodeMatcherFactory();
/**
* Schedules the execution of an update task, and returns an encapsulation
* of the task as a {@link CompletableFuture}.
@@ -251,4 +230,30 @@ public interface LuckPerms {
*/
void registerMessengerProvider(@NonNull MessengerProvider messengerProvider);
/**
* Gets the {@link NodeBuilderRegistry}.
*
* @return the node builder registry
*/
@Internal
@NonNull NodeBuilderRegistry getNodeBuilderRegistry();
/**
* Gets the {@link QueryOptionsRegistry}.
*
* @return the query options registry
* @since 5.1
*/
@Internal
@NonNull QueryOptionsRegistry getQueryOptionsRegistry();
/**
* Gets the {@link NodeMatcherFactory}.
*
* @return the node matcher factory
* @since 5.1
*/
@Internal
@NonNull NodeMatcherFactory getNodeMatcherFactory();
}
@@ -27,41 +27,62 @@ package net.luckperms.api;
import org.checkerframework.checker.nullness.qual.NonNull;
import static org.jetbrains.annotations.ApiStatus.Internal;
/**
* Provides static access to the {@link LuckPerms} service.
* Provides static access to the {@link LuckPerms} API.
*
* <p>Ideally, the ServiceManager for the platform should be used to obtain an
* instance, however, this provider can be used if you need static access.</p>
* instance, however, this provider can be used if this is not viable.</p>
*/
public final class LuckPermsProvider {
private static LuckPerms instance = null;
/**
* Gets an instance of the {@link LuckPerms} service,
* throwing {@link IllegalStateException} if an instance is not yet loaded.
* Gets an instance of the {@link LuckPerms} API,
* throwing {@link IllegalStateException} if the API is not loaded yet.
*
* <p>Will never return null.</p>
* <p>This method will never return null.</p>
*
* @return an api instance
* @throws IllegalStateException if the api is not loaded
* @return an instance of the LuckPerms API
* @throws IllegalStateException if the API is not loaded yet
*/
public static @NonNull LuckPerms get() {
if (instance == null) {
throw new IllegalStateException("The LuckPerms API is not loaded.");
throw new NotLoadedException();
}
return instance;
}
@Internal
static void register(LuckPerms instance) {
LuckPermsProvider.instance = instance;
}
@Internal
static void unregister() {
LuckPermsProvider.instance = null;
}
@Internal
private LuckPermsProvider() {
throw new UnsupportedOperationException("This class cannot be instantiated.");
}
/**
* Exception thrown when the API is requested before it has been loaded.
*/
private static final class NotLoadedException extends IllegalStateException {
private static final String MESSAGE = "The LuckPerms API isn't loaded yet!\n" +
"This could be because:\n" +
" a) the LuckPerms plugin is not installed or it failed to enable\n" +
" b) your plugin does not declare a dependency on LuckPerms\n" +
" c) you are attempting to use the API before plugins reach the 'enable' phase\n" +
" (call the #get method in onEnable, not in your plugin constructor!)\n";
NotLoadedException() {
super(MESSAGE);
}
}
}
@@ -170,7 +170,7 @@ public interface Action extends Comparable<Action> {
* @param type the type
* @return the builder
*/
@NonNull Builder targetType(Action.Target.Type type);
@NonNull Builder targetType(Target.@NonNull Type type);
/**
* Sets the acted object for the entry.
@@ -26,6 +26,7 @@
package net.luckperms.api.actionlog;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.SortedSet;
import java.util.UUID;
@@ -47,7 +48,7 @@ public interface ActionLog {
*
* @return the content
*/
@NonNull SortedSet<Action> getContent();
@NonNull @Unmodifiable SortedSet<Action> getContent();
/**
* Gets the entries in the log performed by the given actor.
@@ -55,7 +56,7 @@ public interface ActionLog {
* @param actor the uuid of the actor to filter by
* @return the content for the given actor
*/
@NonNull SortedSet<Action> getContent(@NonNull UUID actor);
@NonNull @Unmodifiable SortedSet<Action> getContent(@NonNull UUID actor);
/**
* Gets the log content for a given user
@@ -63,7 +64,7 @@ public interface ActionLog {
* @param uniqueId the uuid to filter by
* @return all content in this log where the user = uuid
*/
@NonNull SortedSet<Action> getUserHistory(@NonNull UUID uniqueId);
@NonNull @Unmodifiable SortedSet<Action> getUserHistory(@NonNull UUID uniqueId);
/**
* Gets the log content for a given group
@@ -71,7 +72,7 @@ public interface ActionLog {
* @param name the name to filter by
* @return all content in this log where the group = name
*/
@NonNull SortedSet<Action> getGroupHistory(@NonNull String name);
@NonNull @Unmodifiable SortedSet<Action> getGroupHistory(@NonNull String name);
/**
* Gets the log content for a given track
@@ -79,6 +80,6 @@ public interface ActionLog {
* @param name the name to filter by
* @return all content in this log where the track = name
*/
@NonNull SortedSet<Action> getTrackHistory(@NonNull String name);
@NonNull @Unmodifiable SortedSet<Action> getTrackHistory(@NonNull String name);
}
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* {@link net.luckperms.api.actionlog.ActionLog} related functionality.
*/
package net.luckperms.api.actionlog;
@@ -29,10 +29,13 @@ import net.luckperms.api.metastacking.MetaStackDefinition;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.SortedMap;
import java.util.function.Function;
/**
* Holds cached meta lookup data for a specific set of contexts.
@@ -45,7 +48,37 @@ public interface CachedMetaData extends CachedData {
* @param key the key
* @return the value
*/
@Nullable String getMetaValue(String key);
@Nullable String getMetaValue(@NonNull String key);
/**
* Gets a value for the given meta key, and runs it through the given {@code transformer}.
*
* <p>If no such meta value exists, an {@link Optional#empty() empty optional} is returned.
* (the transformer will never be passed a null argument)</p>
*
* <p>The transformer is allowed to throw {@link IllegalArgumentException} or return null. This
* will also result in an {@link Optional#empty() empty optional} being returned.</p>
*
* <p>For example, to parse and return an integer meta value, use:</p>
* <p><blockquote><pre>
* getMetaValue("my-int-val", Integer::parseInt).orElse(0);
* </pre></blockquote>
*
* @param key the key
* @param valueTransformer the transformer used to transform the value
* @param <T> the type of the transformed result
* @return the meta value
* @since 5.3
*/
default <T> @NonNull Optional<T> getMetaValue(@NonNull String key, @NonNull Function<String, ? extends T> valueTransformer) {
return Optional.ofNullable(getMetaValue(key)).map(value -> {
try {
return valueTransformer.apply(value);
} catch (IllegalArgumentException e) {
return null;
}
});
}
/**
* Gets the holder's highest priority prefix, or null if the holder has no prefixes
@@ -66,7 +99,7 @@ public interface CachedMetaData extends CachedData {
*
* @return an immutable map of meta
*/
@NonNull Map<String, List<String>> getMeta();
@NonNull @Unmodifiable Map<String, List<String>> getMeta();
/**
* Gets an immutable sorted map of all of the prefixes the holder has, whereby the first
@@ -74,7 +107,7 @@ public interface CachedMetaData extends CachedData {
*
* @return a sorted map of prefixes
*/
@NonNull SortedMap<Integer, String> getPrefixes();
@NonNull @Unmodifiable SortedMap<Integer, String> getPrefixes();
/**
* Gets an immutable sorted map of all of the suffixes the holder has, whereby the first
@@ -82,7 +115,7 @@ public interface CachedMetaData extends CachedData {
*
* @return a sorted map of suffixes
*/
@NonNull SortedMap<Integer, String> getSuffixes();
@NonNull @Unmodifiable SortedMap<Integer, String> getSuffixes();
/**
* Gets the name of the holders primary group.
@@ -28,6 +28,7 @@ package net.luckperms.api.cacheddata;
import net.luckperms.api.util.Tristate;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.Map;
@@ -57,6 +58,6 @@ public interface CachedPermissionData extends CachedData {
*
* @return an immutable set of permissions
*/
@NonNull Map<String, Boolean> getPermissionMap();
@NonNull @Unmodifiable Map<String, Boolean> getPermissionMap();
}
@@ -0,0 +1,30 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* CachedData lookup API for {@link net.luckperms.api.model.user.User}s and
* {@link net.luckperms.api.model.group.Group}s.
*/
package net.luckperms.api.cacheddata;
@@ -34,6 +34,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* <p>Context keys and values may not be null or empty. A key/value will be
* deemed empty if it's length is zero, or if it consists of only space
* characters.</p>
*
* @see ContextSet
*/
public interface Context {
@@ -103,7 +103,7 @@ public interface ContextCalculator<T> {
*
* @return a set of potential contexts
*/
default ContextSet estimatePotentialContexts() {
default @NonNull ContextSet estimatePotentialContexts() {
return ImmutableContextSet.empty();
}
@@ -30,6 +30,7 @@ import net.luckperms.api.query.QueryMode;
import net.luckperms.api.query.QueryOptions;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.ApiStatus.Internal;
import java.util.Optional;
@@ -48,6 +49,7 @@ import java.util.Optional;
* <li>{@code org.bukkit.entity.Player}</li>
* <li>{@code net.md_5.bungee.api.connection.ProxiedPlayer}</li>
* <li>{@code org.spongepowered.api.service.permission.Subject}</li>
* <li>{@code net.minecraft.server.network.ServerPlayerEntity} (Fabric)</li>
* <li>{@code cn.nukkit.Player}</li>
* <li>{@code com.velocitypowered.api.proxy.Player}</li>
* </ul>
@@ -138,19 +140,36 @@ public interface ContextManager {
*/
void unregisterCalculator(@NonNull ContextCalculator<?> calculator);
/**
* Signal to the {@link ContextManager} that a {@code subject}s
* current contexts have changed.
*
* <p>It is not strictly necessary to make a call to this method every time a context
* changes.</p>
*
* @param subject the subject
* @since 5.2
*/
void signalContextUpdate(@NonNull Object subject);
/**
* Gets the {@link ContextSetFactory}, responsible for creating
* {@link ContextSet} instances.
*
* @return the context set factory
*/
@Internal
@NonNull ContextSetFactory getContextSetFactory();
/**
* Invalidates the lookup cache for a given subject
*
* @param subject the subject
* @deprecated Use {@link #signalContextUpdate(Object)} instead
*/
void invalidateCache(@NonNull Object subject);
@Deprecated
default void invalidateCache(@NonNull Object subject) {
signalContextUpdate(subject);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
package net.luckperms.api.context;
import net.luckperms.api.query.OptionKey;
/**
* Mode for determining whether a {@link ContextSet} satisfies another.
*
* @since 5.2
* @see ContextSet#isSatisfiedBy(ContextSet, ContextSatisfyMode)
*/
public enum ContextSatisfyMode {
/**
* Mode where a {@link ContextSet} A will be satisfied by another set B, if at least one of the
* key-value entries per key in A are also in B.
*
* <p>For example, given <code>A = {server=survival, world=overworld, world=nether}</code>,
* another set {@code X} will satisfy {@code A} if {@code X} contains
* <code>server=survival AND (world=overworld OR world=nether)</code>.</p>
*/
AT_LEAST_ONE_VALUE_PER_KEY,
/**
* Mode where a {@link ContextSet} A will be satisfied by another set B, if all key-value
* entries in A are also in B.
*
* <p>For example, given <code>A = {server=survival, world=overworld, world=nether}</code>,
* another set {@code X} will satisfy {@code A} if {@code X} contains
* <code>server=survival AND world=overworld AND world=nether</code>.</p>
*/
ALL_VALUES_PER_KEY;
/**
* The {@link OptionKey} for {@link ContextSatisfyMode}.
*/
public static final OptionKey<ContextSatisfyMode> KEY = OptionKey.of("contextsatisfymode", ContextSatisfyMode.class);
}
@@ -26,6 +26,7 @@
package net.luckperms.api.context;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.Iterator;
import java.util.Map;
@@ -40,19 +41,33 @@ import java.util.Set;
* something will apply.</p>
*
* <p>A single "context" consists of a key and a value, both strings. The key
* represents the type of context, and the value represents the setting of the
* context key.</p>
* describes the type of the context, and the value represents what the key is
* set to.</p>
*
* <p>For example, a context with {@code key=world} and {@code value=world_nether}
* describes that a subject is in the "world_nether" world.</p>
*
* <p>Contexts are exposed to end users and manipulated when managing permissions.
* For this reason, context keys should strike a balance between being descriptive
* and succinct.</p>
*
* <p>Context keys and values are case-insensitive, and will be automatically
* converted to {@link String#toLowerCase() lowercase} when added to a
* context set. Keys and values cannot be null or empty (len=0 or consisting of
* only whitespace).</p>
*
* <p>If a context key is formed of more than one word, the parts should be
* separated by the '{@code -}' character. (e.g. "{@code server-type}")</p>
*
* <p>If a context key is likely to conflict with another plugin, it should be
* appropriately namespaced using the name of the plugin providing the context.
* The namespace should be at the start of the context key, and separated using
* the '{@code :}' character. (e.g. "{@code worldguard:region}" for WorldGuard
* regions)</p>
*
* <p>Contexts can be combined with each other to form so called
* "context sets" - simply a collection of context pairs.</p>
*
* <p>Context keys and values are case-insensitive, and will be converted to
* {@link String#toLowerCase() lowercase} by all implementations.</p>
*
* <p>Context keys and values may not be null or empty. A key/value will be
* deemed empty if it's length is zero, or if it consists of only space
* characters.</p>
*
* <p>Two default ContextSet implementations are provided.
* {@link MutableContextSet} allows the addition and removal of context keys
* after construction, and {@link ImmutableContextSet} does not.</p>
@@ -97,7 +112,7 @@ public interface ContextSet extends Iterable<Context> {
*
* @return an immutable set
*/
@NonNull Set<Context> toSet();
@NonNull @Unmodifiable Set<Context> toSet();
/**
* Returns a {@link Map} representing the current state of this
@@ -108,7 +123,7 @@ public interface ContextSet extends Iterable<Context> {
*
* @return a map
*/
@NonNull Map<String, Set<String>> toMap();
@NonNull @Unmodifiable Map<String, Set<String>> toMap();
/**
* Returns a {@link Map} <b>loosely</b> representing the current state of
@@ -121,10 +136,10 @@ public interface ContextSet extends Iterable<Context> {
* may not be a true representation of the set.</p>
*
* @return an immutable map
* @deprecated because the resultant map may not contain all data in the ContextSet
* @deprecated Deprecated because the returned map may not contain all data in the ContextSet
*/
@Deprecated
@NonNull Map<String, String> toFlattenedMap();
@NonNull @Unmodifiable Map<String, String> toFlattenedMap();
/**
* Returns an {@link Iterator} over each of the context pairs in this set.
@@ -137,7 +152,7 @@ public interface ContextSet extends Iterable<Context> {
* @return an iterator
*/
@Override
@NonNull Iterator<Context> iterator();
@NonNull @Unmodifiable Iterator<Context> iterator();
/**
* Returns if the {@link ContextSet} contains at least one value for the
@@ -159,7 +174,7 @@ public interface ContextSet extends Iterable<Context> {
* @return a set of values
* @throws NullPointerException if the key is null
*/
@NonNull Set<String> getValues(@NonNull String key);
@NonNull @Unmodifiable Set<String> getValues(@NonNull String key);
/**
* Returns any value from this {@link ContextSet} matching the key, if present.
@@ -197,17 +212,47 @@ public interface ContextSet extends Iterable<Context> {
}
/**
* Returns if this {@link ContextSet} is fully "satisfied" by another set.
* Returns if the {@link ContextSet} contains any of the given context pairings.
*
* <p>For a context set to "satisfy" another, it must itself contain all of
* the context pairings in the other set.</p>
*
* <p>Mathematically, this method returns true if this set is a <b>subset</b> of the other.</p>
*
* @param other the other set to check
* @return true if all entries in this set are also in the other set
* @param key the key to look for
* @param values the values to look for
* @return true if the set contains any of the pairs
* @since 5.2
*/
boolean isSatisfiedBy(@NonNull ContextSet other);
default boolean containsAny(@NonNull String key, @NonNull Iterable<String> values) {
Objects.requireNonNull(key, "key");
Objects.requireNonNull(values, "values");
for (String value : values) {
if (contains(key, value)) {
return true;
}
}
return false;
}
/**
* Returns if this {@link ContextSet} is "satisfied" by another set.
*
* <p>{@link ContextSatisfyMode#AT_LEAST_ONE_VALUE_PER_KEY} is the mode used by this method.</p>
*
* @param other the other set
* @return true if this context set is satisfied by the other
*/
default boolean isSatisfiedBy(@NonNull ContextSet other) {
return isSatisfiedBy(other, ContextSatisfyMode.AT_LEAST_ONE_VALUE_PER_KEY);
}
/**
* Returns if this {@link ContextSet} is "satisfied" by another set, according to the given
* {@code mode}.
*
* @param other the other set
* @param mode the mode to use
* @return true if this context set is satisfied by the other
* @since 5.2
*/
boolean isSatisfiedBy(@NonNull ContextSet other, @NonNull ContextSatisfyMode mode);
/**
* Returns if the {@link ContextSet} is empty.
@@ -26,18 +26,49 @@
package net.luckperms.api.context;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.ApiStatus.Internal;
/**
* A factory for creating {@link ContextSet}s.
*
* <p>Prefer using the static methods on {@link ImmutableContextSet} or {@link MutableContextSet}
* instead of this interface.</p>
*/
@Internal
public interface ContextSetFactory {
/**
* Prefer using {@link ImmutableContextSet#builder()}.
*
* @return a immutable context set builder
* @see ImmutableContextSet#builder()
*/
ImmutableContextSet.@NonNull Builder immutableBuilder();
/**
* Prefer using {@link ImmutableContextSet#of(String, String)}.
*
* @param key the key
* @param value the value
* @return an immutable context set
* @see ImmutableContextSet#of(String, String)
*/
@NonNull ImmutableContextSet immutableOf(@NonNull String key, @NonNull String value);
/**
* Prefer using {@link ImmutableContextSet#empty()}.
*
* @return an empty immutable context set
* @see ImmutableContextSet#empty()
*/
@NonNull ImmutableContextSet immutableEmpty();
/**
* Prefer using {@link MutableContextSet#create()}.
*
* @return a new mutable context set
* @see MutableContextSet#create()
*/
@NonNull MutableContextSet mutable();
}
@@ -34,13 +34,31 @@ public final class DefaultContextKeys {
}
/**
* The context key used to denote the subjects server.
* The context key used to denote the name of the subjects server.
*/
public static final String SERVER_KEY = "server";
/**
* The context key used to denote the subjects world.
* The context key used to denote the name of the subjects world.
*/
public static final String WORLD_KEY = "world";
/**
* The context key used to denote the dimension type of the subjects world.
*
* <p>Possible values: overworld, the_nether, the_end</p>
*
* @since 5.3
*/
public static final String DIMENSION_TYPE_KEY = "dimension-type";
/**
* The context key used to denote the subjects gamemode.
*
* <p>Possible values: survival, creative, adventure, spectator</p>
*
* @since 5.3
*/
public static final String GAMEMODE_KEY = "gamemode";
}
@@ -67,7 +67,7 @@ public interface ImmutableContextSet extends ContextSet {
}
/**
* @deprecated Already immutable!
* @deprecated This context set is already immutable!
*/
@Override
@Deprecated
@@ -0,0 +1,30 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Context functionality, including {@link net.luckperms.api.context.ContextSet}s and
* {@link net.luckperms.api.context.ContextCalculator}s.
*/
package net.luckperms.api.context;
@@ -26,6 +26,7 @@
package net.luckperms.api.event;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.Set;
import java.util.function.Consumer;
@@ -49,7 +50,7 @@ public interface EventBus {
* @param <T> the event class
* @return an event handler instance representing this subscription
*/
@NonNull <T extends LuckPermsEvent> EventSubscription<T> subscribe(@NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler);
<T extends LuckPermsEvent> @NonNull EventSubscription<T> subscribe(@NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler);
/**
* Registers a new subscription to the given event.
@@ -69,7 +70,7 @@ public interface EventBus {
* @param handler the event handler
* @return an event handler instance representing this subscription
*/
@NonNull <T extends LuckPermsEvent> EventSubscription<T> subscribe(Object plugin, @NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler);
<T extends LuckPermsEvent> @NonNull EventSubscription<T> subscribe(Object plugin, @NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler);
/**
* Gets a set of all registered handlers for a given event.
@@ -78,6 +79,6 @@ public interface EventBus {
* @param <T> the event class
* @return an immutable set of event handlers
*/
@NonNull <T extends LuckPermsEvent> Set<EventSubscription<T>> getSubscriptions(@NonNull Class<T> eventClass);
<T extends LuckPermsEvent> @NonNull @Unmodifiable Set<EventSubscription<T>> getSubscriptions(@NonNull Class<T> eventClass);
}
@@ -35,6 +35,12 @@ public enum DeletionCause {
*/
COMMAND,
/**
* The deletion was caused by the web editor
* @since 5.3
*/
WEB_EDITOR,
/**
* The deletion was caused by an API call
*/
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Event causes.
*/
package net.luckperms.api.event.cause;
@@ -0,0 +1,76 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
package net.luckperms.api.event.context;
import net.luckperms.api.context.ContextManager;
import net.luckperms.api.event.LuckPermsEvent;
import net.luckperms.api.event.util.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Optional;
/**
* Called when a subject's current/active contexts are updated.
*
* <p>There are no guarantees that this event will be called for every update. It is merely to be
* used as a "hint" for plugins which depend on the current active contexts for a player.</p>
*
* <p>It will always be fired following a call to
* {@link ContextManager#signalContextUpdate(Object)}.</p>
*
* <p>The {@link #getSubject() subject} is always an instance of the platform's subject type. See
* {@link ContextManager} for details.</p>
*
* <p>Unlike most other LuckPerms events, this event is not fired asynchronously. Care should be
* taken to ensure listeners are lightweight. Additionally, listeners should ensure they do not
* cause further updates to player context, thus possibly causing a stack overflow.</p>
*
* @since 5.2
*/
public interface ContextUpdateEvent extends LuckPermsEvent {
/**
* Gets the subject whose contexts were updated.
*
* @return the subject
*/
@Param(0)
@NonNull Object getSubject();
/**
* Gets the subject whose contexts were updated, casted to a given type.
*
* @param subjectClass the type to cast to
* @param <T> the subject type
* @return the casted subject
*/
default <T> @NonNull Optional<T> getSubject(@NonNull Class<T> subjectClass) {
Object subject = getSubject();
return subjectClass.isInstance(subject) ? Optional.of(subjectClass.cast(subject)) : Optional.empty();
}
}
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Events relating to {@link net.luckperms.api.context.Context}s.
*/
package net.luckperms.api.event.context;
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Events relating to {@link net.luckperms.api.extension.Extension}s.
*/
package net.luckperms.api.event.extension;
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Events relating to {@link net.luckperms.api.model.group.Group}s.
*/
package net.luckperms.api.event.group;
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Events relating to the {@link net.luckperms.api.actionlog.ActionLog}.
*/
package net.luckperms.api.event.log;
@@ -29,6 +29,11 @@ import net.luckperms.api.event.util.Param;
import net.luckperms.api.node.Node;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* Called when a node is added to a holder
@@ -40,7 +45,14 @@ public interface NodeAddEvent extends NodeMutateEvent {
*
* @return the node that was added
*/
@Param(4)
@Param(3)
@NonNull Node getNode();
@Override
default @NonNull @Unmodifiable Set<Node> getDataBefore() {
// Get data after, then reverse the action
Set<Node> nodes = new HashSet<>(this.getDataAfter());
nodes.remove(this.getNode());
return Collections.unmodifiableSet(nodes);
}
}
@@ -25,9 +25,35 @@
package net.luckperms.api.event.node;
import net.luckperms.api.event.util.Param;
import net.luckperms.api.node.Node;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* Called when a holder has their nodes cleared
*/
public interface NodeClearEvent extends NodeMutateEvent {
/**
* Gets the nodes that were cleared
*
* @return the nodes that were removed
* @since 5.3
*/
@Param(3)
@NonNull @Unmodifiable Set<Node> getNodes();
@Override
default @NonNull @Unmodifiable Set<Node> getDataBefore() {
// Get data after, then reverse the action
Set<Node> nodes = new HashSet<>(this.getDataAfter());
nodes.addAll(this.getNodes());
return Collections.unmodifiableSet(nodes);
}
}
@@ -34,6 +34,7 @@ import net.luckperms.api.model.user.User;
import net.luckperms.api.node.Node;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.Set;
@@ -63,16 +64,15 @@ public interface NodeMutateEvent extends LuckPermsEvent {
*
* @return the data before the change
*/
@Param(2)
@NonNull Set<Node> getDataBefore();
@NonNull @Unmodifiable Set<Node> getDataBefore();
/**
* Gets an immutable copy of the holders data after the change
*
* @return the data after the change
*/
@Param(3)
@NonNull Set<Node> getDataAfter();
@Param(2)
@NonNull @Unmodifiable Set<Node> getDataAfter();
/**
* Gets whether the target of this event is a {@link User}
@@ -29,6 +29,11 @@ import net.luckperms.api.event.util.Param;
import net.luckperms.api.node.Node;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* Called when a node is removed from a holder
@@ -40,7 +45,15 @@ public interface NodeRemoveEvent extends NodeMutateEvent {
*
* @return the node that was removed
*/
@Param(4)
@Param(3)
@NonNull Node getNode();
@Override
default @NonNull @Unmodifiable Set<Node> getDataBefore() {
// Get data after, then reverse the action
Set<Node> nodes = new HashSet<>(this.getDataAfter());
nodes.add(this.getNode());
return Collections.unmodifiableSet(nodes);
}
}
@@ -0,0 +1,30 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Events relating to changes to a {@link net.luckperms.api.model.user.User} or
* {@link net.luckperms.api.model.group.Group}s {@link net.luckperms.api.model.data.NodeMap}.
*/
package net.luckperms.api.event.node;
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Main events package.
*/
package net.luckperms.api.event;
@@ -0,0 +1,86 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
package net.luckperms.api.event.player.lookup;
import net.luckperms.api.event.LuckPermsEvent;
import net.luckperms.api.event.type.ResultEvent;
import net.luckperms.api.event.util.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Objects;
import java.util.UUID;
/**
* Called when the platform needs to determine the type of a player's {@link UUID unique id}.
*
* @since 5.3
*/
public interface UniqueIdDetermineTypeEvent extends LuckPermsEvent, ResultEvent<String> {
/**
* The players UUID has been obtained by authenticating with the Mojang session servers.
*
* <p>Usually indicated by the UUID being {@link UUID#version() version} 4.</p>
*/
String TYPE_AUTHENTICATED = "authenticated";
/**
* The players UUID has not been obtained through authentication, and instead is likely based
* on the username they connected with.
*
* <p>Usually indicated by the UUID being {@link UUID#version() version} 3.</p>
*/
String TYPE_UNAUTHENTICATED = "unauthenticated";
/**
* Gets the {@link UUID unique id} being queried.
*
* @return the unique id
*/
@Param(0)
@NonNull UUID getUniqueId();
/**
* Gets the current result unique id type.
*
* @return the type
*/
default @NonNull String getType() {
return result().get();
}
/**
* Sets the result unique id type.
*
* @param type the type
*/
default void setType(@NonNull String type) {
Objects.requireNonNull(type, "type");
result().set(type);
}
}
@@ -23,36 +23,39 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.cache;
package net.luckperms.api.event.player.lookup;
import java.util.concurrent.atomic.AtomicInteger;
import net.luckperms.api.event.LuckPermsEvent;
import net.luckperms.api.event.type.ResultEvent;
import net.luckperms.api.event.util.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.UUID;
/**
* Implementation of a most-recently-used cache with a mod counter, to prevent race conditions
* occurring when the cache is cleared whilst a calculation is taking place.
* Called when the platform needs a unique id for a given username.
*
* @param <T> the cached type
* @since 5.3
*/
public abstract class MRUCache<T> {
private volatile T recent;
private final AtomicInteger modCount = new AtomicInteger();
public interface UniqueIdLookupEvent extends LuckPermsEvent, ResultEvent<UUID> {
protected int modCount() {
return this.modCount.get();
/**
* Gets the username being looked up.
*
* @return the username
*/
@Param(0)
@NonNull String getUsername();
/**
* Sets the result unique id.
*
* @param uniqueId the unique id
*/
default void setUniqueId(@Nullable UUID uniqueId) {
result().set(uniqueId);
}
protected T getRecent() {
return this.recent;
}
protected void offerRecent(int validAt, T offer) {
if (validAt == this.modCount.get()) {
this.recent = offer;
}
}
protected void clearRecent() {
this.recent = null;
this.modCount.incrementAndGet();
}
}
@@ -0,0 +1,61 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
package net.luckperms.api.event.player.lookup;
import net.luckperms.api.event.LuckPermsEvent;
import net.luckperms.api.event.type.ResultEvent;
import net.luckperms.api.event.util.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.UUID;
/**
* Called when the platform needs a username for a given unique id.
*
* @since 5.3
*/
public interface UsernameLookupEvent extends LuckPermsEvent, ResultEvent<String> {
/**
* Gets the {@link UUID unique id} being looked up.
*
* @return the unique id
*/
@Param(0)
@NonNull UUID getUniqueId();
/**
* Sets the result username.
*
* @param username the username
*/
default void setUsername(@Nullable String username) {
result().set(username);
}
}
@@ -23,48 +23,54 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.metastacking;
package net.luckperms.api.event.player.lookup;
import net.luckperms.api.metastacking.MetaStackDefinition;
import net.luckperms.api.node.ChatMetaType;
import net.luckperms.api.node.types.ChatMetaNode;
import net.luckperms.api.event.LuckPermsEvent;
import net.luckperms.api.event.util.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* A live stack of {@link MetaStackEntry} instances, formed from a
* {@link MetaStackDefinition}.
* Called when the validity of a username is being tested.
*
* This class is used to construct a formatted string, by accumulating
* nodes to each element.
* @since 5.3
*/
public interface MetaStack {
public interface UsernameValidityCheckEvent extends LuckPermsEvent {
/**
* Gets the definition this stack is based upon
* Gets the username being tested.
*
* @return the definition of the stack
* @return the username
*/
MetaStackDefinition getDefinition();
@Param(0)
@NonNull String getUsername();
/**
* Gets the target of this stack
* Gets the current validity state for the username.
*
* @return the stack target
* @return the validity state
*/
ChatMetaType getTargetType();
@Param(1)
@NonNull AtomicBoolean validityState();
/**
* Returns a formatted string, as defined by the {@link MetaStackDefinition},
* using the accumulated elements in the stack.
* Gets if the username is currently considered to be valid.
*
* @return the string output
* @return if the username is valid
*/
String toFormattedString();
default boolean isValid() {
return validityState().get();
}
/**
* Tries to accumulate the given node to all elements in the stack.
* Sets if the username should be considered valid or not.
*
* @param node the node to accumulate
* @param valid whether the username is valid
*/
void accumulateToAll(ChatMetaNode<?, ?> node);
default void setValid(boolean valid) {
validityState().set(valid);
}
}
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Events relating to a player {@link java.util.UUID unique id} or username lookup.
*/
package net.luckperms.api.event.player.lookup;
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Events relating to a player.
*/
package net.luckperms.api.event.player;
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Event sources.
*/
package net.luckperms.api.event.source;
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Events relating to {@link net.luckperms.api.LuckPerms#runUpdateTask() sync/update task}s.
*/
package net.luckperms.api.event.sync;
@@ -30,6 +30,7 @@ import net.luckperms.api.event.util.Param;
import net.luckperms.api.track.Track;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
@@ -52,7 +53,7 @@ public interface TrackMutateEvent extends LuckPermsEvent {
* @return the data before the change
*/
@Param(1)
@NonNull List<String> getStateBefore();
@NonNull @Unmodifiable List<String> getStateBefore();
/**
* Gets an immutable copy of the tracks data after the change
@@ -60,6 +61,6 @@ public interface TrackMutateEvent extends LuckPermsEvent {
* @return the data after the change
*/
@Param(2)
@NonNull List<String> getStateAfter();
@NonNull @Unmodifiable List<String> getStateAfter();
}
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Events relating to changes to a {@link net.luckperms.api.track.Track}s contents.
*/
package net.luckperms.api.event.track.mutate;
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Events relating to {@link net.luckperms.api.track.Track}s.
*/
package net.luckperms.api.event.track;
@@ -23,32 +23,37 @@
* SOFTWARE.
*/
package me.lucko.luckperms.bukkit.migration;
package net.luckperms.api.event.type;
import me.lucko.luckperms.common.util.ProgressLogger;
import me.lucko.luckperms.common.util.Uuids;
import net.luckperms.api.event.util.Param;
import org.bukkit.Bukkit;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
public final class BukkitUuids {
private BukkitUuids() {}
/**
* Represents an event that has a result.
*
* @param <T> the type of the result
* @since 5.3
*/
public interface ResultEvent<T> {
public static UUID lookupUuid(ProgressLogger log, String s) {
UUID uuid = Uuids.parse(s);
if (uuid == null) {
try {
//noinspection deprecation
uuid = Bukkit.getOfflinePlayer(s).getUniqueId();
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (uuid == null) {
log.logError("Unable to get a UUID for user identifier: " + s);
}
return uuid;
/**
* Gets an {@link AtomicReference} containing the result.
*
* @return the result
*/
@Param(-1)
@NonNull AtomicReference<T> result();
/**
* Gets if a result has been set for the event.
*
* @return if there is a result
*/
default boolean hasResult() {
return result().get() != null;
}
}
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Event abstract types.
*/
package net.luckperms.api.event.type;
@@ -0,0 +1,50 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
package net.luckperms.api.event.user;
import net.luckperms.api.event.LuckPermsEvent;
import net.luckperms.api.event.type.Cancellable;
import net.luckperms.api.event.util.Param;
import net.luckperms.api.model.user.User;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a user is about to be unloaded from memory.
*
* @since 5.3
*/
public interface UserUnloadEvent extends LuckPermsEvent, Cancellable {
/**
* Gets the user that is being unloaded
*
* @return the user that is being unloaded
*/
@Param(0)
@NonNull User getUser();
}
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Events relating to {@link net.luckperms.api.model.user.User}s.
*/
package net.luckperms.api.event.user;
@@ -0,0 +1,30 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Events relating to a {@link net.luckperms.api.model.user.User}s movement on a
* {@link net.luckperms.api.track.Track}.
*/
package net.luckperms.api.event.user.track;
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Event utilities.
*/
package net.luckperms.api.event.util;
@@ -26,6 +26,7 @@
package net.luckperms.api.extension;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.Unmodifiable;
import java.io.IOException;
import java.nio.file.Path;
@@ -57,6 +58,6 @@ public interface ExtensionManager {
*
* @return the loaded extensions
*/
@NonNull Collection<Extension> getLoadedExtensions();
@NonNull @Unmodifiable Collection<Extension> getLoadedExtensions();
}
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* {@link net.luckperms.api.extension.Extension}s functionality.
*/
package net.luckperms.api.extension;
@@ -40,7 +40,7 @@ public interface MessagingService {
*
* @return the name of this messaging service
*/
String getName();
@NonNull String getName();
/**
* Uses the messaging service to inform other servers about a general
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* {@link net.luckperms.api.messaging.MessagingService} functionality.
*/
package net.luckperms.api.messaging;
@@ -29,11 +29,13 @@ import net.luckperms.api.messenger.message.Message;
import net.luckperms.api.messenger.message.OutgoingMessage;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.ApiStatus.NonExtendable;
/**
* Encapsulates the LuckPerms system which accepts incoming {@link Message}s
* from implementations of {@link Messenger}.
*/
@NonExtendable
public interface IncomingMessageConsumer {
/**
@@ -29,10 +29,12 @@ import net.luckperms.api.messenger.message.Message;
import net.luckperms.api.messenger.message.OutgoingMessage;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.ApiStatus.OverrideOnly;
/**
* Represents an object which dispatches {@link OutgoingMessage}s.
*/
@OverrideOnly
public interface Messenger extends AutoCloseable {
/**
@@ -28,6 +28,7 @@ package net.luckperms.api.messenger;
import net.luckperms.api.LuckPerms;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.ApiStatus.OverrideOnly;
/**
* Represents a provider for {@link Messenger} instances.
@@ -37,6 +38,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @see LuckPerms#registerMessengerProvider(MessengerProvider)
*/
@OverrideOnly
public interface MessengerProvider {
/**
@@ -28,12 +28,14 @@ package net.luckperms.api.messenger.message;
import net.luckperms.api.messenger.Messenger;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.ApiStatus.NonExtendable;
import java.util.UUID;
/**
* Represents a message sent received via a {@link Messenger}.
*/
@NonExtendable
public interface Message {
/**
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* {@link net.luckperms.api.messenger.Messenger} message abstract types.
*/
package net.luckperms.api.messenger.message;
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* {@link net.luckperms.api.messenger.Messenger} message actual types.
*/
package net.luckperms.api.messenger.message.type;
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* {@link net.luckperms.api.messenger.Messenger} provider API.
*/
package net.luckperms.api.messenger;
@@ -28,6 +28,7 @@ package net.luckperms.api.metastacking;
import net.luckperms.api.query.OptionKey;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
@@ -57,7 +58,7 @@ public interface MetaStackDefinition {
*
* @return the elements in this stack
*/
@NonNull List<MetaStackElement> getElements();
@NonNull @Unmodifiable List<MetaStackElement> getElements();
/**
* Gets the duplicate removal function, applied to the entries before
@@ -26,6 +26,7 @@
package net.luckperms.api.metastacking;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.List;
import java.util.Optional;
@@ -51,7 +52,7 @@ public interface MetaStackFactory {
* @param definitions the definition strings
* @return a list of parsed elements
*/
@NonNull List<MetaStackElement> fromStrings(@NonNull List<String> definitions);
@NonNull @Unmodifiable List<MetaStackElement> fromStrings(@NonNull List<String> definitions);
/**
* Creates a new {@link MetaStackDefinition} with the given properties.
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* {@link net.luckperms.api.metastacking.MetaStackDefinition Meta stacking} functionality.
*/
package net.luckperms.api.metastacking;
@@ -33,9 +33,11 @@ import net.luckperms.api.model.group.Group;
import net.luckperms.api.model.user.User;
import net.luckperms.api.node.Node;
import net.luckperms.api.node.NodeType;
import net.luckperms.api.query.Flag;
import net.luckperms.api.query.QueryOptions;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.ArrayList;
import java.util.Collection;
@@ -185,7 +187,7 @@ public interface PermissionHolder {
*
* @return a collection of the holders own nodes.
*/
default @NonNull Collection<Node> getNodes() {
default @NonNull @Unmodifiable Collection<Node> getNodes() {
/* This default method is overridden in the implementation, and is just here
to demonstrate what this method does in the API sources. */
List<Node> nodes = new ArrayList<>();
@@ -203,7 +205,7 @@ public interface PermissionHolder {
* @see #getNodes()
* @since 5.1
*/
default <T extends Node> @NonNull Collection<T> getNodes(@NonNull NodeType<T> type) {
default <T extends Node> @NonNull @Unmodifiable Collection<T> getNodes(@NonNull NodeType<T> type) {
/* This default method is overridden in the implementation, and is just here
to demonstrate what this method does in the API sources. */
return getNodes().stream()
@@ -222,7 +224,7 @@ public interface PermissionHolder {
*
* @return a sorted set of the holders own distinct nodes
*/
@NonNull SortedSet<Node> getDistinctNodes();
@NonNull @Unmodifiable SortedSet<Node> getDistinctNodes();
/**
* Gets a resolved view of the holders own and inherited {@link Node}s.
@@ -239,7 +241,7 @@ public interface PermissionHolder {
* @param queryOptions the query options
* @return a list of the holders inherited nodes
*/
@NonNull Collection<Node> resolveInheritedNodes(@NonNull QueryOptions queryOptions);
@NonNull @Unmodifiable Collection<Node> resolveInheritedNodes(@NonNull QueryOptions queryOptions);
/**
* Gets a resolved view of the holders own and inherited {@link Node}s of a given {@code type}.
@@ -251,7 +253,7 @@ public interface PermissionHolder {
* @see #resolveInheritedNodes(QueryOptions)
* @since 5.1
*/
default <T extends Node> @NonNull Collection<T> resolveInheritedNodes(@NonNull NodeType<T> type, @NonNull QueryOptions queryOptions) {
default <T extends Node> @NonNull @Unmodifiable Collection<T> resolveInheritedNodes(@NonNull NodeType<T> type, @NonNull QueryOptions queryOptions) {
/* This default method is overridden in the implementation, and is just here
to demonstrate what this method does in the API sources. */
return resolveInheritedNodes(queryOptions).stream()
@@ -274,13 +276,17 @@ public interface PermissionHolder {
* @param queryOptions the query options
* @return a sorted set of the holders distinct inherited nodes
*/
@NonNull SortedSet<Node> resolveDistinctInheritedNodes(@NonNull QueryOptions queryOptions);
@NonNull @Unmodifiable SortedSet<Node> resolveDistinctInheritedNodes(@NonNull QueryOptions queryOptions);
/**
* Gets a collection of the {@link Group}s this holder inherits nodes from, both directly
* and indirectly (through directly inherited groups).
* Gets a collection of the {@link Group}s this holder inherits nodes from.
*
* <p>It effectively resolves the whole "inheritance tree".</p>
* <p>If {@link Flag#RESOLVE_INHERITANCE} is set, this will include holders inherited from both
* directly and indirectly (through directly inherited groups). It will effectively resolve the
* whole "inheritance tree".</p>
*
* <p>If {@link Flag#RESOLVE_INHERITANCE} is not set, then the traversal will only go one
* level up the inheritance tree, and return only directly inherited groups.</p>
*
* <p>The collection will be ordered according to the platforms inheritance rules. The groups
* which are inherited from first will appear earlier in the list.</p>
@@ -291,7 +297,7 @@ public interface PermissionHolder {
* @return a collection of the groups the holder inherits from
* @since 5.1
*/
@NonNull Collection<Group> getInheritedGroups(@NonNull QueryOptions queryOptions);
@NonNull @Unmodifiable Collection<Group> getInheritedGroups(@NonNull QueryOptions queryOptions);
/**
* Removes any temporary permissions that have expired.
@@ -29,6 +29,7 @@ import net.luckperms.api.model.user.UserManager;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.Unmodifiable;
import java.util.Objects;
import java.util.Set;
@@ -47,7 +48,7 @@ public interface PlayerSaveResult {
*
* @return the status
*/
@NonNull Set<Outcome> getOutcomes();
@NonNull @Unmodifiable Set<Outcome> getOutcomes();
/**
* Gets if the result includes a certain outcome.
@@ -80,7 +81,7 @@ public interface PlayerSaveResult {
* @return the other uuids
* @see Outcome#OTHER_UNIQUE_IDS_PRESENT_FOR_USERNAME
*/
@Nullable Set<UUID> getOtherUniqueIds();
@Nullable @Unmodifiable Set<UUID> getOtherUniqueIds();
/**
* The various states the result can take
@@ -37,6 +37,7 @@ import net.luckperms.api.node.NodeEqualityPredicate;
import net.luckperms.api.util.Tristate;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.Unmodifiable;
import java.util.Collection;
import java.util.Map;
@@ -65,7 +66,7 @@ public interface NodeMap {
*
* @return a map of nodes
*/
@NonNull Map<ImmutableContextSet, Collection<Node>> toMap();
@NonNull @Unmodifiable Map<ImmutableContextSet, Collection<Node>> toMap();
/**
* Gets a flattened view of {@link Node}s contained within this instance.
@@ -75,7 +76,7 @@ public interface NodeMap {
*
* @return a flattened collection of nodes
*/
@NonNull Collection<Node> toCollection();
@NonNull @Unmodifiable Collection<Node> toCollection();
/**
* Gets if this instance contains a given {@link Node}.
@@ -0,0 +1,30 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* {@link net.luckperms.api.model.PermissionHolder}
* ({@link net.luckperms.api.model.user.User}/{@link net.luckperms.api.model.group.Group}) data.
*/
package net.luckperms.api.model.data;
@@ -31,6 +31,7 @@ import net.luckperms.api.node.matcher.NodeMatcher;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.Unmodifiable;
import java.util.Collection;
import java.util.List;
@@ -138,7 +139,7 @@ public interface GroupManager {
* @return the entries which matched
* @since 5.1
*/
@NonNull <T extends Node> CompletableFuture<Map<String, Collection<T>>> searchAll(@NonNull NodeMatcher<? extends T> matcher);
<T extends Node> @NonNull CompletableFuture<@Unmodifiable Map<String, Collection<T>>> searchAll(@NonNull NodeMatcher<? extends T> matcher);
/**
* Searches for a list of groups with a given permission.
@@ -146,10 +147,10 @@ public interface GroupManager {
* @param permission the permission to search for
* @return a list of held permissions, or null if the operation failed
* @throws NullPointerException if the permission is null
* @deprecated use {@link #searchAll(NodeMatcher)}
* @deprecated Use {@link #searchAll(NodeMatcher)} instead
*/
@Deprecated
@NonNull CompletableFuture<List<HeldNode<String>>> getWithPermission(@NonNull String permission);
@NonNull CompletableFuture<@Unmodifiable List<HeldNode<String>>> getWithPermission(@NonNull String permission);
/**
* Gets a loaded group.
@@ -165,7 +166,7 @@ public interface GroupManager {
*
* @return a {@link Set} of {@link Group} objects
*/
@NonNull Set<Group> getLoadedGroups();
@NonNull @Unmodifiable Set<Group> getLoadedGroups();
/**
* Check if a group is loaded in memory
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* {@link net.luckperms.api.model.group.Group} data model and functionality.
*/
package net.luckperms.api.model.group;
@@ -0,0 +1,31 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Main package for {@link net.luckperms.api.model.PermissionHolder}s
* ({@link net.luckperms.api.model.user.User}s and {@link net.luckperms.api.model.group.Group}s) and
* their corresponding {@link net.luckperms.api.model.data.NodeMap data}.
*/
package net.luckperms.api.model;
@@ -32,6 +32,7 @@ import net.luckperms.api.node.matcher.NodeMatcher;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.Unmodifiable;
import java.util.Collection;
import java.util.List;
@@ -147,6 +148,17 @@ public interface UserManager {
*/
@NonNull CompletableFuture<PlayerSaveResult> savePlayerData(@NonNull UUID uniqueId, @NonNull String username);
/**
* Deletes any data about a given player from the uuid caching system.
*
* <p>Note that this method does not affect any saved user/permissions data.</p>
*
* @param uniqueId the users mojang unique id
* @return a future encapsulating the result of the operation
* @since 5.2
*/
@NonNull CompletableFuture<Void> deletePlayerData(@NonNull UUID uniqueId);
/**
* Gets a set all "unique" user UUIDs.
*
@@ -154,7 +166,7 @@ public interface UserManager {
*
* @return a set of uuids
*/
@NonNull CompletableFuture<Set<UUID>> getUniqueUsers();
@NonNull CompletableFuture<@Unmodifiable Set<UUID>> getUniqueUsers();
/**
* Searches the {@link User#data() normal node maps} of all known {@link User}s for {@link Node}
@@ -164,7 +176,7 @@ public interface UserManager {
* @return the entries which matched
* @since 5.1
*/
@NonNull <T extends Node> CompletableFuture<Map<UUID, Collection<T>>> searchAll(@NonNull NodeMatcher<? extends T> matcher);
<T extends Node> @NonNull CompletableFuture<@Unmodifiable Map<UUID, Collection<T>>> searchAll(@NonNull NodeMatcher<? extends T> matcher);
/**
* Searches for a list of users with a given permission.
@@ -172,10 +184,10 @@ public interface UserManager {
* @param permission the permission to search for
* @return a list of held permissions
* @throws NullPointerException if the permission is null
* @deprecated use {@link #searchAll(NodeMatcher)}
* @deprecated Use {@link #searchAll(NodeMatcher)} instead
*/
@Deprecated
@NonNull CompletableFuture<List<HeldNode<UUID>>> getWithPermission(@NonNull String permission);
@NonNull CompletableFuture<@Unmodifiable List<HeldNode<UUID>>> getWithPermission(@NonNull String permission);
/**
* Gets a loaded user.
@@ -200,7 +212,7 @@ public interface UserManager {
*
* @return a {@link Set} of {@link User} objects
*/
@NonNull Set<User> getLoadedUsers();
@NonNull @Unmodifiable Set<User> getLoadedUsers();
/**
* Check if a user is loaded in memory
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* {@link net.luckperms.api.model.user.User} data model and functionality.
*/
package net.luckperms.api.model.user;
@@ -33,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* A relationship between a {@link PermissionHolder} and a {@link Node}.
*
* @param <T> the identifier type of the holder
* @deprecated The only usages of this interface are also deprecated.
*/
@Deprecated
public interface HeldNode<T> {
@@ -39,6 +39,8 @@ import net.luckperms.api.node.types.WeightNode;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.ApiStatus.NonExtendable;
import org.jetbrains.annotations.Unmodifiable;
import java.time.Duration;
import java.time.Instant;
@@ -97,6 +99,7 @@ import java.util.stream.Stream;
*
* <p>The core node state must be immutable in all implementations.</p>
*/
@NonExtendable
public interface Node {
/**
@@ -151,7 +154,7 @@ public interface Node {
*
* @return a list of full nodes
*/
@NonNull Collection<String> resolveShorthand();
@NonNull @Unmodifiable Collection<String> resolveShorthand();
/**
* Gets if this node is assigned temporarily.
@@ -198,11 +201,11 @@ public interface Node {
/**
* Gets the metadata corresponding to the given <code>key</code>, if present.
*
* @param key the key
* @param <T> the metadata type
* @param key the key
* @return the data, if present
*/
<T> Optional<T> getMetadata(NodeMetadataKey<T> key);
<T> Optional<T> getMetadata(@NonNull NodeMetadataKey<T> key);
/**
* Gets the metadata corresponding to the given <code>key</code>, throwing an exception
@@ -213,7 +216,7 @@ public interface Node {
* @return the data
* @throws IllegalStateException if data isn't present
*/
default <T> T metadata(NodeMetadataKey<T> key) throws IllegalStateException {
default <T> T metadata(@NonNull NodeMetadataKey<T> key) throws IllegalStateException {
return getMetadata(key).orElseThrow(() -> new IllegalStateException("Node '" + getKey() + "' does not have '" + key.name() + "' attached."));
}
@@ -30,6 +30,7 @@ import net.luckperms.api.node.metadata.NodeMetadataKey;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.ApiStatus.NonExtendable;
import java.time.Duration;
import java.time.temporal.TemporalAccessor;
@@ -43,6 +44,7 @@ import java.util.concurrent.TimeUnit;
* @param <N> the node type
* @param <B> the node builder type
*/
@NonExtendable
public interface NodeBuilder<N extends ScopedNode<N, B>, B extends NodeBuilder<N, B>> {
/**
@@ -107,7 +109,7 @@ public interface NodeBuilder<N extends ScopedNode<N, B>, B extends NodeBuilder<N
* @param unit the unit <code>duration</code> is measured in
* @return the builder
*/
default @NonNull B expiry(long duration, TimeUnit unit) {
default @NonNull B expiry(long duration, @NonNull TimeUnit unit) {
if (duration <= 0) {
throw new IllegalArgumentException("duration must be positive");
}
@@ -161,7 +163,7 @@ public interface NodeBuilder<N extends ScopedNode<N, B>, B extends NodeBuilder<N
* @param <T> the metadata type
* @return the builder
*/
@NonNull <T> B withMetadata(@NonNull NodeMetadataKey<T> key, @Nullable T metadata);
<T> @NonNull B withMetadata(@NonNull NodeMetadataKey<T> key, @Nullable T metadata);
/**
* Creates a {@link Node} instance from the builder.
@@ -35,17 +35,19 @@ import net.luckperms.api.node.types.SuffixNode;
import net.luckperms.api.node.types.WeightNode;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.ApiStatus.Internal;
/**
* A registry of methods for obtaining {@link NodeBuilder}s for the various
* node types.
*/
@Internal
public interface NodeBuilderRegistry {
/**
* Gets a {@link NodeBuilder} applicable for the given key.
*
* <p>Prefer using the {@link Node#builder(String)} accessor.</p>
* <p>Prefer using the {@link Node#builder(String)} method.</p>
*
* @param key the key
* @return the node builder
@@ -56,7 +58,7 @@ public interface NodeBuilderRegistry {
/**
* Gets a {@link NodeBuilder} for {@link PermissionNode}s.
*
* <p>Prefer using the {@link PermissionNode#builder()} accessor.</p>
* <p>Prefer using the {@link PermissionNode#builder()} method.</p>
*
* @return the node builder
* @see PermissionNode#builder()
@@ -66,7 +68,7 @@ public interface NodeBuilderRegistry {
/**
* Gets a {@link NodeBuilder} for {@link RegexPermissionNode}s.
*
* <p>Prefer using the {@link RegexPermissionNode#builder()} accessor.</p>
* <p>Prefer using the {@link RegexPermissionNode#builder()} method.</p>
*
* @return the node builder
* @see RegexPermissionNode#builder()
@@ -76,7 +78,7 @@ public interface NodeBuilderRegistry {
/**
* Gets a {@link NodeBuilder} for {@link InheritanceNode}s.
*
* <p>Prefer using the {@link InheritanceNode#builder()} accessor.</p>
* <p>Prefer using the {@link InheritanceNode#builder()} method.</p>
*
* @return the node builder
* @see InheritanceNode#builder()
@@ -86,7 +88,7 @@ public interface NodeBuilderRegistry {
/**
* Gets a {@link NodeBuilder} for {@link PrefixNode}s.
*
* <p>Prefer using the {@link PrefixNode#builder()} accessor.</p>
* <p>Prefer using the {@link PrefixNode#builder()} method.</p>
*
* @return the node builder
* @see PrefixNode#builder()
@@ -96,7 +98,7 @@ public interface NodeBuilderRegistry {
/**
* Gets a {@link NodeBuilder} for {@link SuffixNode}s.
*
* <p>Prefer using the {@link SuffixNode#builder()} accessor.</p>
* <p>Prefer using the {@link SuffixNode#builder()} method.</p>
*
* @return the node builder
* @see SuffixNode#builder()
@@ -106,7 +108,7 @@ public interface NodeBuilderRegistry {
/**
* Gets a {@link NodeBuilder} for {@link MetaNode}s.
*
* <p>Prefer using the {@link MetaNode#builder()} accessor.</p>
* <p>Prefer using the {@link MetaNode#builder()} method.</p>
*
* @return the node builder
* @see MetaNode#builder()
@@ -116,7 +118,7 @@ public interface NodeBuilderRegistry {
/**
* Gets a {@link NodeBuilder} for {@link WeightNode}s.
*
* <p>Prefer using the {@link WeightNode#builder()} accessor.</p>
* <p>Prefer using the {@link WeightNode#builder()} method.</p>
*
* @return the node builder
* @see WeightNode#builder()
@@ -126,7 +128,7 @@ public interface NodeBuilderRegistry {
/**
* Gets a {@link NodeBuilder} for {@link DisplayNameNode}s.
*
* <p>Prefer using the {@link DisplayNameNode#builder()} accessor.</p>
* <p>Prefer using the {@link DisplayNameNode#builder()} method.</p>
*
* @return the node builder
* @see DisplayNameNode#builder()
@@ -35,6 +35,8 @@ import net.luckperms.api.node.types.RegexPermissionNode;
import net.luckperms.api.node.types.SuffixNode;
import net.luckperms.api.node.types.WeightNode;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
@@ -48,59 +50,105 @@ public interface NodeType<T extends Node> {
/**
* Node type for {@link PermissionNode}.
*/
NodeType<PermissionNode> PERMISSION = new SimpleNodeType<>("PERMISSION", n -> n instanceof PermissionNode, n -> ((PermissionNode) n));
NodeType<PermissionNode> PERMISSION = new SimpleNodeType<>(
"PERMISSION",
n -> n instanceof PermissionNode,
n -> (PermissionNode) n
);
/**
* Node type for {@link RegexPermissionNode}.
*/
NodeType<RegexPermissionNode> REGEX_PERMISSION = new SimpleNodeType<>("REGEX_PERMISSION", n -> n instanceof RegexPermissionNode, n -> ((RegexPermissionNode) n));
NodeType<RegexPermissionNode> REGEX_PERMISSION = new SimpleNodeType<>(
"REGEX_PERMISSION",
n -> n instanceof RegexPermissionNode,
n -> (RegexPermissionNode) n
);
/**
* Node type for {@link InheritanceNode}.
*/
NodeType<InheritanceNode> INHERITANCE = new SimpleNodeType<>("INHERITANCE", n -> n instanceof InheritanceNode, n -> ((InheritanceNode) n));
NodeType<InheritanceNode> INHERITANCE = new SimpleNodeType<>(
"INHERITANCE",
n -> n instanceof InheritanceNode,
n -> (InheritanceNode) n
);
/**
* Node type for {@link PrefixNode}.
*/
NodeType<PrefixNode> PREFIX = new SimpleNodeType<>("PREFIX", n -> n instanceof PrefixNode, n -> ((PrefixNode) n));
NodeType<PrefixNode> PREFIX = new SimpleNodeType<>(
"PREFIX",
n -> n instanceof PrefixNode,
n -> (PrefixNode) n
);
/**
* Node type for {@link SuffixNode}.
*/
NodeType<SuffixNode> SUFFIX = new SimpleNodeType<>("SUFFIX", n -> n instanceof SuffixNode, n -> ((SuffixNode) n));
NodeType<SuffixNode> SUFFIX = new SimpleNodeType<>(
"SUFFIX",
n -> n instanceof SuffixNode,
n -> (SuffixNode) n
);
/**
* Node type for {@link MetaNode}.
*/
NodeType<MetaNode> META = new SimpleNodeType<>("META", n -> n instanceof MetaNode, n -> ((MetaNode) n));
NodeType<MetaNode> META = new SimpleNodeType<>(
"META",
n -> n instanceof MetaNode,
n -> (MetaNode) n
);
/**
* Node type for {@link WeightNode}.
*/
NodeType<WeightNode> WEIGHT = new SimpleNodeType<>("WEIGHT", n -> n instanceof WeightNode, n -> ((WeightNode) n));
NodeType<WeightNode> WEIGHT = new SimpleNodeType<>(
"WEIGHT",
n -> n instanceof WeightNode,
n -> (WeightNode) n
);
/**
* Node type for {@link DisplayNameNode}.
*/
NodeType<DisplayNameNode> DISPLAY_NAME = new SimpleNodeType<>("DISPLAY_NAME", n -> n instanceof DisplayNameNode, n -> ((DisplayNameNode) n));
NodeType<DisplayNameNode> DISPLAY_NAME = new SimpleNodeType<>(
"DISPLAY_NAME",
n -> n instanceof DisplayNameNode,
n -> (DisplayNameNode) n
);
/**
* Node type for {@link ChatMetaNode}.
*
* <p>This is an abstract type, and therefore will never
* be returned from {@link Node#getType()}.</p>
*/
NodeType<ChatMetaNode<?, ?>> CHAT_META = new SimpleNodeType<>("CHAT_META", n -> n instanceof ChatMetaNode<?, ?>, n -> ((ChatMetaNode<?, ?>) n));
NodeType<ChatMetaNode<?, ?>> CHAT_META = new SimpleNodeType<>(
"CHAT_META",
n -> n instanceof ChatMetaNode<?, ?>,
n -> (ChatMetaNode<?, ?>) n
);
/**
* Node type for {@link ChatMetaNode} or {@link MetaNode}.
*
* <p>This is an abstract type, and therefore will never
* be returned from {@link Node#getType()}.</p>
*/
NodeType<Node> META_OR_CHAT_META = new SimpleNodeType<>("META_OR_CHAT_META", n -> META.matches(n) || CHAT_META.matches(n), Function.identity());
NodeType<Node> META_OR_CHAT_META = new SimpleNodeType<>(
"META_OR_CHAT_META",
n -> META.matches(n) || CHAT_META.matches(n),
Function.identity()
);
/**
* Gets a name for the node type.
*
* @return a name
*/
String name();
@NonNull String name();
/**
* Returns if the passed node matches the type
@@ -108,7 +156,7 @@ public interface NodeType<T extends Node> {
* @param node the node to test
* @return true if the node has the same type
*/
boolean matches(Node node);
boolean matches(@NonNull Node node);
/**
* Casts the given {@link Node} to the type defined by the {@link NodeType}.
@@ -120,7 +168,7 @@ public interface NodeType<T extends Node> {
* @return the casted node
* @throws IllegalArgumentException if the node to cast does not match the type
*/
T cast(Node node);
@NonNull T cast(@NonNull Node node);
/**
* Attempts to cast the given {@link Node} to the type defined by the
@@ -132,7 +180,7 @@ public interface NodeType<T extends Node> {
* @param node the node to cast
* @return an optional, possibly containing a casted node
*/
default Optional<T> tryCast(Node node) {
default @NonNull Optional<T> tryCast(@NonNull Node node) {
Objects.requireNonNull(node, "node");
if (!matches(node)) {
return Optional.empty();
@@ -147,7 +195,7 @@ public interface NodeType<T extends Node> {
*
* @return a predicate for the {@link #matches(Node)} method.
*/
default Predicate<Node> predicate() {
default @NonNull Predicate<Node> predicate() {
return this::matches;
}
@@ -159,7 +207,7 @@ public interface NodeType<T extends Node> {
* @param and a predicate to AND with the result of the type match check
* @return a matching predicate, ANDed with the given predicate parameter
*/
default Predicate<Node> predicate(Predicate<? super T> and) {
default @NonNull Predicate<Node> predicate(@NonNull Predicate<? super T> and) {
return node -> matches(node) && and.test(cast(node));
}
@@ -25,6 +25,9 @@
package net.luckperms.api.node;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Predicate;
@@ -41,18 +44,18 @@ final class SimpleNodeType<T extends Node> implements NodeType<T> {
}
@Override
public String name() {
public @NotNull String name() {
return this.name;
}
@Override
public boolean matches(Node node) {
public boolean matches(@NonNull Node node) {
Objects.requireNonNull(node, "node");
return this.matches.test(node);
}
@Override
public T cast(Node node) {
public @NotNull T cast(@NonNull Node node) {
if (!matches(node)) {
throw new IllegalArgumentException("Node " + node.getClass() + " does not match " + this.name);
}
@@ -32,15 +32,19 @@ import net.luckperms.api.node.NodeType;
import net.luckperms.api.node.types.MetaNode;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.ApiStatus.NonExtendable;
import java.util.function.Predicate;
/**
* A predicate which matches certain {@link Node}s.
*
* <p>API users should not implement this interface directly.</p>
*
* @param <T> the node type matched
* @since 5.1
*/
@NonExtendable
public interface NodeMatcher<T extends Node> extends Predicate<Node> {
/**
@@ -130,7 +134,7 @@ public interface NodeMatcher<T extends Node> extends Predicate<Node> {
* @param <T> the node type
* @return the matcher
*/
static <T extends Node> @NonNull NodeMatcher<T> type(NodeType<? extends T> type) {
static <T extends Node> @NonNull NodeMatcher<T> type(@NonNull NodeType<? extends T> type) {
return LuckPermsProvider.get().getNodeMatcherFactory().type(type);
}
@@ -31,12 +31,14 @@ import net.luckperms.api.node.NodeType;
import net.luckperms.api.node.types.MetaNode;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.ApiStatus.Internal;
/**
* A factory which creates {@link NodeMatcher}s.
*
* @since 5.1
*/
@Internal
public interface NodeMatcherFactory {
/**
@@ -87,7 +89,7 @@ public interface NodeMatcherFactory {
* @param <T> the node type
* @return the matcher
*/
@NonNull <T extends Node> NodeMatcher<T> equals(@NonNull T other, @NonNull NodeEqualityPredicate equalityPredicate);
<T extends Node> @NonNull NodeMatcher<T> equals(@NonNull T other, @NonNull NodeEqualityPredicate equalityPredicate);
/**
* Gets a {@link NodeMatcher} which matches {@link MetaNode}s with the same
@@ -115,6 +117,6 @@ public interface NodeMatcherFactory {
* @param <T> the node type
* @return the matcher
*/
<T extends Node> @NonNull NodeMatcher<T> type(NodeType<? extends T> type);
<T extends Node> @NonNull NodeMatcher<T> type(@NonNull NodeType<? extends T> type);
}
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* {@link net.luckperms.api.node.Node} matchers.
*/
package net.luckperms.api.node.matcher;
@@ -26,6 +26,7 @@
package net.luckperms.api.node.metadata;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.ApiStatus.NonExtendable;
import java.util.Objects;
@@ -40,6 +41,7 @@ import java.util.Objects;
*
* @param <T> the metadata type
*/
@NonExtendable
public interface NodeMetadataKey<T> {
/**
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* {@link net.luckperms.api.node.Node} metadata.
*/
package net.luckperms.api.node.metadata;
@@ -30,10 +30,12 @@ import net.luckperms.api.node.Node;
import net.luckperms.api.node.metadata.NodeMetadataKey;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.ApiStatus.NonExtendable;
/**
* Node metadata indicating where a node was inherited from.
*/
@NonExtendable
public interface InheritanceOriginMetadata {
/**
@@ -54,4 +56,17 @@ public interface InheritanceOriginMetadata {
*/
PermissionHolder.@NonNull Identifier getOrigin();
/**
* Gets whether the associated node was inherited from another holder.
*
* <p>In other terms, it returns whether the origin is not equal to the given holder.</p>
*
* @param holder the holder defining the node
* @return if true the node was inherited, false if it was defined by the same holder
* @since 5.3
*/
default boolean wasInherited(PermissionHolder.@NonNull Identifier holder) {
return !holder.equals(getOrigin());
}
}
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* {@link net.luckperms.api.node.Node} metadata types.
*/
package net.luckperms.api.node.metadata.types;
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* {@link net.luckperms.api.node.Node} functionality.
*/
package net.luckperms.api.node;
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* {@link net.luckperms.api.node.Node} types.
*/
package net.luckperms.api.node.types;
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* Main package for the {@link net.luckperms.api.LuckPerms} API interface.
*/
package net.luckperms.api;
@@ -26,6 +26,7 @@
package net.luckperms.api.platform;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.Unmodifiable;
import java.time.Instant;
import java.util.Collection;
@@ -49,14 +50,14 @@ public interface Platform {
*
* @return the unique connections
*/
@NonNull Set<UUID> getUniqueConnections();
@NonNull @Unmodifiable Set<UUID> getUniqueConnections();
/**
* Gets a {@link Collection} of all known permission strings.
*
* @return a collection of the known permissions
*/
@NonNull Collection<String> getKnownPermissions();
@NonNull @Unmodifiable Collection<String> getKnownPermissions();
/**
* Gets the time when the plugin first started.
@@ -73,7 +74,8 @@ public interface Platform {
BUNGEECORD("BungeeCord"),
SPONGE("Sponge"),
NUKKIT("Nukkit"),
VELOCITY("Velocity");
VELOCITY("Velocity"),
FABRIC("Fabric");
private final String friendlyName;
@@ -100,6 +100,7 @@ public interface PlayerAdapter<T> {
default @NonNull CachedPermissionData getPermissionData(@NonNull T player) {
return getUser(player).getCachedData().getPermissionData(getQueryOptions(player));
}
/**
* Gets the current {@link CachedMetaData} for the {@code player},
* using their {@link #getQueryOptions(Object) active query options}.
@@ -0,0 +1,29 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* 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:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* 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.
*/
/**
* {@link net.luckperms.api.platform.Platform} specific information and utilities.
*/
package net.luckperms.api.platform;
@@ -28,6 +28,7 @@ package net.luckperms.api.query;
import net.luckperms.api.node.metadata.NodeMetadataKey;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.ApiStatus.NonExtendable;
import java.util.Objects;
@@ -41,6 +42,7 @@ import java.util.Objects;
*
* @param <T> the option type
*/
@NonExtendable
public interface OptionKey<T> {
/**
@@ -26,11 +26,13 @@
package net.luckperms.api.query;
import net.luckperms.api.LuckPermsProvider;
import net.luckperms.api.context.ContextSatisfyMode;
import net.luckperms.api.context.ContextSet;
import net.luckperms.api.context.ImmutableContextSet;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.ApiStatus.NonExtendable;
import java.util.Map;
import java.util.Optional;
@@ -39,6 +41,7 @@ import java.util.Set;
/**
* Represents the parameters for a lookup query.
*/
@NonExtendable
public interface QueryOptions {
/**
@@ -166,10 +169,29 @@ public interface QueryOptions {
* Gets whether this {@link QueryOptions} satisfies the given required
* {@link ContextSet context}.
*
* <p>{@link ContextSatisfyMode#AT_LEAST_ONE_VALUE_PER_KEY} is used if this {@link QueryOptions}
* instance doesn't have the {@link ContextSatisfyMode#KEY option key} set.</p>
*
* @param contextSet the contexts
* @return the result
*/
boolean satisfies(@NonNull ContextSet contextSet);
default boolean satisfies(@NonNull ContextSet contextSet) {
return satisfies(contextSet, ContextSatisfyMode.AT_LEAST_ONE_VALUE_PER_KEY);
}
/**
* Gets whether this {@link QueryOptions} satisfies the given required
* {@link ContextSet context}.
*
* <p>The {@code defaultContextSatisfyMode} parameter is used if this {@link QueryOptions}
* instance doesn't have the {@link ContextSatisfyMode#KEY option key} set.</p>
*
* @param contextSet the contexts
* @param defaultContextSatisfyMode the default context satisfy mode to use
* @return the result
* @since 5.2
*/
boolean satisfies(@NonNull ContextSet contextSet, @NonNull ContextSatisfyMode defaultContextSatisfyMode);
/**
* Converts this {@link QueryOptions} to a mutable builder.
@@ -181,6 +203,7 @@ public interface QueryOptions {
/**
* Builder for {@link QueryOptions}.
*/
@NonExtendable
interface Builder {
/**
@@ -26,19 +26,21 @@
package net.luckperms.api.query;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.ApiStatus.Internal;
/**
* A registry providing useful {@link QueryOptions} instances.
*
* @since 5.1
*/
@Internal
public interface QueryOptionsRegistry {
/**
* Gets the default {@link QueryMode#CONTEXTUAL contextual}
* query options.
*
* <p>Prefer using the {@link QueryOptions#defaultContextualOptions()} accessor.</p>>
* <p>Prefer using the {@link QueryOptions#defaultContextualOptions()} accessor.</p>
*
* @return the default contextual query options
* @see QueryOptions#defaultContextualOptions()
@@ -49,7 +51,7 @@ public interface QueryOptionsRegistry {
* Gets the default {@link QueryMode#NON_CONTEXTUAL non contextual}
* query options.
*
* <p>Prefer using the {@link QueryOptions#nonContextual()} accessor.</p>>
* <p>Prefer using the {@link QueryOptions#nonContextual()} accessor.</p>
*
* @return the default non contextual query options
* @see QueryOptions#nonContextual()
Loaded 100 of 625 files, more files were not shown because too many files have changed in this diff. Show more