Compare commits

...
809 Commits
Author SHA1 Message Date
Luck 8eed4558f4 Release API v4.4 2019-04-02 16:36:22 +01:00
Luck 62ca2d9c79 Implement special handling in the LP Vault implementation for NPC players (#1470) 2019-04-01 15:09:58 +01:00
Luck c7a0d7026c Update API build script 2019-04-01 14:00:46 +01:00
Luck ce74813ce5 Fallback to node/context ordering in InheritanceComparator, refactor graph traverser classes 2019-03-14 15:23:26 +00:00
Luck d1511e43f2 Fix build 2019-03-10 19:19:46 +00:00
Luck 6ef749c76a Update some dependencies 2019-03-08 23:11:32 +00:00
Luck 8846932cb6 Refactor the HolderType enum 2019-03-08 20:19:08 +00:00
Luck 12b861db3f Update PermissionHolderSubjectData#save code 2019-03-08 19:56:07 +00:00
Luck 0a50df6557 Code style: move private constructors for singleton classes to the top of the file 2019-03-05 12:36:09 +00:00
Luck 3726f6de41 Use a separate fork join pool for cache loading operations 2019-03-05 12:35:29 +00:00
Luck d1ca7684d6 Refactor AbstractJavaScheduler to make use of a cached thread pool 2019-03-05 12:32:16 +00:00
Luck 512b621a7a Refactor Dependency class a bit 2019-03-03 16:46:20 +00:00
Luck 2cf919a17a Bump hikari version 2019-03-03 12:01:15 +00:00
Luck 46072eb465 Attempt to detect and warn about CraftBukkit + offline mode problems (#1439) 2019-02-21 14:14:00 +00:00
Luck ae63a42c2e Slightly optimize regex and wildcard processors 2019-02-21 12:37:23 +00:00
Luck 8773ec07ab Include processor & cause in verbose hover message 2019-02-19 23:30:11 +00:00
Luck 287cc308d6 Fix parsing log entry types (#1438) 2019-02-19 14:17:33 +00:00
Luck beeb4fa169 Fix DuplicateRemovalFunction javadocs 2019-02-19 14:09:26 +00:00
Luck 4ef3d50965 Properly implement ContextManager#unregisterCalculator (#1422) 2019-02-09 11:50:00 +00:00
Luck dae64fc8c4 Cleanup some of the Sponge permission holder implementation code 2019-02-07 15:35:09 +00:00
Luck 215031a1f3 Close messaging service before storage
Fixes https://www.spigotmc.org/threads/174259/page-129#post-3302827
2019-02-07 12:38:24 +00:00
Luck 85d2f0b51f Add method to unregister context calculators (#1422) 2019-02-07 12:24:23 +00:00
Luck d91355e4d6 Remove some unused code 2019-02-04 20:35:39 +00:00
Luck 1a690dabd7 Implement NodeMap without using Guava's Multimap util (#1416) 2019-02-04 20:35:20 +00:00
Luck 526448ce40 Don't try to set unicode connection properties for PostgreSQL (#1134) 2019-02-04 19:36:53 +00:00
Luck 43d04a97f5 Correctly implement Bukkit/Nukkit isPermissionSet method, inline with the behaviour in PermissibleBase (#1403) 2019-01-31 01:14:38 +00:00
Luck 307614e704 Cleanup import statements 2019-01-31 00:53:42 +00:00
Luck f6c0794691 Return more detailed information about exactly how a permission check result was determined 2019-01-31 00:45:56 +00:00
Luck 83db00aef8 Better null checking in HikariConnectionFactory (#1408) 2019-01-30 16:24:30 +00:00
untuned 22252fa46d Update MIT license text to allow GitHub detection (#1400) 2019-01-28 10:46:05 +00:00
Luck 7b8426977a Switch text dependency back to 1.11 (#1404) 2019-01-28 10:39:08 +00:00
Luck d9912cb93f Update some dependencies 2019-01-27 22:51:05 +00:00
Luck 5db999f995 Only form data buf once in Bukkit PluginMessage messenger 2019-01-23 12:12:33 +00:00
Luck b744e35ad8 Fix typo in Vault exception message 2019-01-18 23:21:23 +00:00
Andre_601 b6769811a2 Fix some small typos (#1389) 2019-01-18 09:47:03 +00:00
Luck 1d9fc568e4 Fix calling default methods on Event interfaces (#1386) 2019-01-16 14:43:55 +00:00
Luck 3c0d1ba7a1 Ensure caches are invalidated when Bukkit/Nukkit's Permission#getChildren map is modified (#1378) 2019-01-13 16:58:31 +00:00
Luck 78a74510cf Fix Sponge and Velocity build scripts 2019-01-12 13:39:07 +00:00
Luck d3ae3324fa Allow the bytebin url to be configured 2019-01-12 12:02:16 +00:00
Luck 4b97c9419e Finish updating commodore
woops
2019-01-07 21:29:28 +00:00
Luck db830a0bef Buildscript changes 2019-01-07 21:25:11 +00:00
Luck 797c195424 unInject -> uninject 2019-01-07 20:45:47 +00:00
Luck 4788290615 Rename Vault implementation classes 2019-01-07 20:44:52 +00:00
Luck d0c016f6b7 Cleanup with way permissibles are monitored on Bukkit/Nukkit
- The removal of the call to recalculatePermissions should fix CMEs on startup, in particular with Vault.
- Monitored permissibles are now uninjected when the plugin disables.
2019-01-07 20:21:36 +00:00
Luck 9b1c73ed23 Implement use of a Maven Central mirror for dependency downloads
People keep telling me that LP's use of Maven Central for downloading dependencies is not allowed / inappropriate / abusive. I disagree but I'm bored of hearing it. Using a mirror will mean that all of the load is taken off of Central, and is instead absorbed by my servers + (mostly) Cloudflare.

- The mirror is (currently) hosted at https://nexus.lucko.me/repository/maven-central/
- The prospect of the mirror becoming compromised is not a concern. LuckPerms compares the downloaded content against a checksum before saving it.
- The prospect of the mirror going offline is also not a concern. We will fallback to Maven Central if a connection cannot be made to the mirror.
2019-01-07 16:56:16 +00:00
Luck 048768007d Change the way static contexts are displayed in /lp info 2019-01-07 15:44:54 +00:00
Luck ec7a5321a6 Some misc refactoring / code cleanup 2019-01-07 15:08:13 +00:00
Luck c396323308 Log exceptions thrown by BufferedRequest tasks 2019-01-05 23:06:57 +00:00
Luck 6fc2321fad Refactor PlayerLoginProcessEvent
This is technically a breaking change, but I'm fairly sure I'm the only person using this event. It's quite obscure ;p
2019-01-02 13:54:55 +00:00
Luck a0d04790a5 Update text-adapter-bungeecord to 1.0.2 (#1362) 2019-01-01 15:33:18 +00:00
Luck c4154c09da Remove SQL indexes on the permission field 2018-12-23 21:56:51 +00:00
Luck 8eed3131f2 Fix sending component messages on older CB/S releases (#1344) 2018-12-23 16:52:00 +00:00
Luck e5c4b710f6 Fix CME in Bukkit refreshAutoOp
cc @Exloki
2018-12-22 17:04:32 +00:00
Luck 2ccffc6e6d Fix error message when event handlers throw an exception 2018-12-22 17:03:51 +00:00
Luck fc69002c86 Fix wrong checksum for text-adapter-bukkit 2018-12-19 14:36:20 +00:00
Luck e3a6db5f97 Refactor ProgressLogger slightly 2018-12-19 10:39:48 +00:00
Luck 6d8077ffd0 Use text-adapter-bukkit for sending Components to Bukkit objects 2018-12-19 10:29:22 +00:00
Luck 784161d66d Update okhttp and okio versions 2018-12-19 10:06:36 +00:00
Jonathan Frederick 115f793733 Make gradlew script executable by default (#1338) 2018-12-19 09:24:44 +00:00
Luck 2cb5e437fd Switch default MySQL/MariaDB charset from utf8 to utf8mb4
https://medium.com/@adamhooper/in-mysql-never-use-utf8-use-utf8mb4-11761243e434
Relates to #1337
2018-12-18 16:02:25 +00:00
Luck 8c57c2b46d Remove static imports 2018-12-18 12:51:26 +00:00
Luck 879a88a398 Account for 'allow-invalid-usernames' setting in API calls 2018-12-18 12:50:52 +00:00
Luck 7e50c3c777 Update Gradle to 5.0 2018-12-15 22:24:17 +00:00
Luck 4b1cf51530 replace LoadingCache with more simple LoadingMap alternative when no auto expiry is needed 2018-12-14 18:37:56 +00:00
Luck de24817d9c Some node equality changes 2018-12-14 17:27:34 +00:00
Luck 085e7af681 Small cleanup in Contexts class 2018-12-10 15:33:57 +00:00
Luck 1aabd7610e Tweak PlayerSaveResult javadoc 2018-12-10 15:33:38 +00:00
Luck ef31db1431 Improve /op and /deop command matching 2018-12-10 15:33:04 +00:00
Luck 757e9d6be6 Add API method to get known permissions & improve the way PermissionDescriptions are migrated from existing Sponge services when LP enables 2018-12-07 14:07:54 +00:00
Luck b3a028e3ca Refactor AbstractConnectionListener for the addition of Velocity support 2018-12-07 13:36:38 +00:00
Luck e222e4e98c Missing nullability annotations 2018-12-07 13:33:05 +00:00
Luck 1213e58240 Depend on a specific Velocity snapshot version
Fixes #1319
Fixes VelocityPowered/Velocity#159
2018-12-06 14:04:31 +00:00
Luck b7ff0824b9 Optimize context set manipulation 2018-12-06 14:02:41 +00:00
Luck 7b5917660c Implement LoadingMap using Guava's ForwardingMap utility 2018-11-28 12:35:38 +00:00
Luck 1544487e92 Convert permissions to lowercase inside the cache
Slight optimization, toLowerCase is a relatively expensive call in the scheme of permission checks.
2018-11-24 13:09:26 +00:00
Luck c19ef84116 Optimize ImmutableContextSet#equals by comparing the hashcodes (constant time lookup) 2018-11-24 01:25:02 +00:00
Luck e8c4a55dc3 Cache the most recent lookup for permission/meta data in AbstractCachedData.
This avoids a (somewhat) costly lookup operation involving Contexts comparison. It aims to be effective on the basis that lookup calls within the same period of time are likely to target the same context (and therefore have the same result).
2018-11-24 01:17:42 +00:00
Luck 97d6aaed5c Experiment with different cache implementation in PermissionCalculator
Caffeine seems to just fallback to a ConcurrentHashMap based implementation in this case anyway.
2018-11-24 00:15:56 +00:00
Luck fe77834cef Optimize LookupSetting storage/manipulation within Contexts
Fixes some performance issues resulting from bad use / implementation of ImmutableEnumSets
2018-11-23 23:58:49 +00:00
Luck 2da6298c53 Update references to the project website 2018-11-22 15:25:39 +00:00
Luck e111270aed Add api-version option to Bukkit plugin.yml file
This doesn't make any functional change, LP doesn't use any of the remapped Material APIs. It only saves on the amount of remapping CB tries to perform when loading the plugin.
2018-11-22 15:19:12 +00:00
Luck e07f8c0fbe Don't send 1.13 tab completions to players without access to any LP commands (#1310) 2018-11-22 15:07:55 +00:00
Luck 90246afd03 Some misc refactoring 2018-11-22 14:51:20 +00:00
Luck 9809e591ad Reorganise some packages 2018-11-10 23:16:28 +00:00
Luck 26973461e7 Don't show negated group membership permissions in the output to 'user info' and 'group listmembers' 2018-11-10 22:42:54 +00:00
Luck 759ec5d499 Attempt to parse uuid from username string in Vault hook 2018-11-10 20:23:40 +00:00
Luck 58ab3c325c misc tidying up 2018-11-10 20:21:08 +00:00
Luck 44c8c67803 Update README.md 2018-11-06 16:36:34 +00:00
Luck acb56d683a Add missing since tag to MetaStackFactory 2018-11-06 15:42:59 +00:00
Luck 5dda522a62 Add option to deduplicate prefix/suffix stacks (#1285) 2018-11-06 14:29:15 +00:00
Luck 79091c726b Update readme badges 2018-11-06 13:28:05 +00:00
Luck e5be06e07b Use the newly added API method to retrieve Velocity implementation name / version 2018-11-06 13:18:58 +00:00
Luck f63992e209 Return a more informative error for invalid verbose filters 2018-11-06 13:16:07 +00:00
Luck 9988011308 Improve the way meta lookups are caught & reported to the verbose handler 2018-11-06 13:15:30 +00:00
Luck 8584a9b72c Sponge Subject lookup methods without a contexts param should default to current contexts, not global (#1279) 2018-11-02 22:39:02 +00:00
Luck 42c8cb1354 Use the fragment identifier instead of query parameters to convey the editor/verbose/treeview data id
This fixes the issue Multicraft panels have with displaying ? characters in console. (absolute quality)
2018-10-28 22:32:02 +00:00
Luck aaeaf5cfa0 Nicer format for verbose meta logging 2018-10-28 21:56:42 +00:00
Luck 45b4e1463f Match the type in verbose filters 2018-10-28 15:18:02 +00:00
Luck be92a67544 Increase verbose stacktrace truncation length for web outputs 2018-10-28 12:40:56 +00:00
Luck 5e0b8ebdf6 Include meta lookup events in verbose output 2018-10-28 12:31:47 +00:00
Luck 9d4ccd33e1 Update commodore for tab complete fix (#1257) 2018-10-26 20:21:00 +01:00
Luck f5c42c70e5 Catch Throwable instead of Exception when calling context calculators
Related to:  lucko/ExtraContexts#4
2018-10-15 22:32:52 +01:00
Luck dcc4656e5e Update buildscripts for Sponge Ore deployment 2018-10-15 22:30:36 +01:00
MrMicky ee2de3cff1 Some minor code cleanup (#1262) 2018-10-09 18:00:53 +01:00
Luck f96518b8e4 misc tidying 2018-10-07 19:48:20 +01:00
Luck dac59966aa Setup gradle license format check 2018-09-24 13:52:59 +01:00
Luck 8115fbaa98 Refactor storage system 2018-09-23 21:49:49 +01:00
Luck 8b97439ffc Use the correct permission check method when forming tree views 2018-09-23 19:53:37 +01:00
Luck fa83986250 Refactor Constraint/Comparison impls for bulkupdate 2018-09-23 19:53:16 +01:00
Luck e1b16465f8 Fix race condition in BufferedRequest 2018-09-23 19:52:42 +01:00
Luck 57619dacb1 Update commodore to 1.1 2018-09-23 15:40:33 +01:00
Luck 64e54d89eb Refactor buildscript determinePatchVersion function 2018-09-23 15:20:22 +01:00
Luck aa4139f0b7 Release v4.3.0 2018-09-23 15:04:15 +01:00
Luck e2f1c1e16b Remove specific dependency on Sponge API 8 in the mod info file (#1221) 2018-09-23 15:02:02 +01:00
Luck 1e7ef15e54 Fix class cast exception in NodeTypeKey#getTypeName (#1230) 2018-09-23 14:38:27 +01:00
Luck 1cc156d6f6 Fix buildscript deployment config for Sonatype 2018-09-23 14:30:09 +01:00
Imortalshard 1445a3faec Fix typo in the description of /lp export (#1229) 2018-09-23 11:28:48 +01:00
Luck 1cf90692cf fix typo 2018-09-21 21:53:06 +01:00
Luck 5656bea3f9 Update for latest Velocity changes 2018-09-21 21:36:44 +01:00
Luck 8e344cea76 Cleanup imports 2018-09-20 21:17:28 +01:00
Luck 5b1229c882 Fix slf4j loading (#1224) 2018-09-20 21:17:00 +01:00
Luck 834649b390 Improve Uuids#parse
thanks @kashike
2018-09-20 15:30:22 +01:00
Luck d28170cc3f Operations to add new nodes with differing values should just override existing entries, instead of failing with the ALREADY_HAS result (#1198) 2018-09-20 11:25:31 +01:00
Luck 04e511026d Detach from permissible objects with a 1 tick delay after player quit to allow plugins listening on monitor to still access data (#1220) 2018-09-20 11:07:20 +01:00
Luck 11a3ecbba0 Fix NPE when loading subject data on Sponge (#1222) 2018-09-20 10:51:00 +01:00
Luck 51b7bb93e2 Don't trigger Vault primary thread checks whilst the server is starting up 2018-09-20 10:44:04 +01:00
Luck 9fd2028d9f Update for velocity API changes 2018-09-19 21:47:22 +01:00
Luck 75f0f40d70 NonNull annotations should be on the same line in interfaces 2018-09-19 21:12:54 +01:00
Luck 3941c77826 Move from findbugs jsr305 to checker-qual 2018-09-19 20:40:25 +01:00
Luck 4987ca3ba2 Update gradle wrapper and buildscript plugins 2018-09-19 19:41:47 +01:00
Jesse Boyd 5fa481337a Fix Nukkit permissible null handling - fixes #1191 (#1213) 2018-09-12 08:58:55 +01:00
Luck dd78e0e271 Separate formatted vs plain display name methods in User/Group
Continues from 3c773e6823 & #1210
2018-09-10 16:54:16 +01:00
Max Lee 3c773e6823 Use neutral color to display potentially colored names - fixes #1170 (#1210) 2018-09-10 16:41:14 +01:00
Luck 54a9ff9256 Fix compile 2018-09-09 11:31:17 +01:00
Luck eca6b09b18 Refactor config keys 2018-09-05 20:49:37 +01:00
Luck b7f8ca6658 Add 'require-sender-group-membership-to-modify' config option (#1140) 2018-09-05 15:49:29 +01:00
Luck ffdeadac8a Add flag to prevent users from being added/removed to/from the first group on a track (#1151) 2018-09-05 15:15:15 +01:00
Luck 9e769904bf Expose TemporaryMergeBehaviour in the API (#1189) 2018-09-05 11:11:45 +01:00
Luck 8d79ec6b07 Rename "update task" --> "sync task" 2018-09-04 21:11:03 +01:00
Luck 3a123f9fa1 Avoid running full "update tasks" unless they're absolutely needed. Process Vault API "set" requests immediately instead of in the background 2018-09-04 21:02:40 +01:00
Luck f0c0328919 Refactor MetaAccumulator to be a little more sane 2018-09-04 20:33:22 +01:00
Luck 274286032a Update banner in readme 2018-09-03 13:56:49 +01:00
Luck 76517374a2 Only allow import and export commands to interact with files in the data directory (#1193) 2018-09-02 22:20:29 +01:00
Luck 2da027f3b5 Revert MySQL driver update 2018-09-02 20:04:26 +01:00
Luck fd712f131f Update some dependency versions 2018-09-02 16:36:28 +01:00
Luck 38613e5f03 Update gitignore 2018-08-31 20:27:13 +01:00
Luck ec9060ba80 Update messenger log prefixes 2018-08-31 20:22:31 +01:00
Luck 502d57e744 Optimize event generation & other misc improvements 2018-08-27 22:11:03 +01:00
Luck c59f2ab37a Don't call NodeAddEvent when adding the default group (#1177) 2018-08-27 22:06:49 +01:00
Luck 066189b486 Send a more informative message when the bulkupdate command is used from in-game 2018-08-27 18:25:57 +01:00
Luck 37d4f92c33 Update README 2018-08-27 09:37:41 +01:00
Luck 55220e9d10 Add support for Velocity 2018-08-26 22:24:46 +01:00
Luck bd41286076 Fix build 2018-08-26 18:45:33 +01:00
Luck d84484c81c Optimize event generation and posting 2018-08-26 10:28:04 +01:00
Luck fec87d4c6a Update event to 3.0.0 2018-08-16 20:01:26 +01:00
Luck 68ec6e2a37 Include license file in the jar 2018-08-14 10:56:07 +01:00
Luck a784ad435f Fix applying group web editor changes (#1148) 2018-08-13 22:44:10 +01:00
Luck cc9bb34873 Update kyori/event dependency 2018-08-13 20:03:57 +01:00
Luck 2ddae5a96c Avoid UnsupportedEncodingException in LilyPad messenger 2018-08-12 10:40:26 +01:00
Luck 40ad489c56 Update build instructions in the README file 2018-08-12 10:27:21 +01:00
Luck 56c55d71fe Improve the way Vault lookups for offline players are handled (#1150)
1) The behaviour of online player lookups is unchanged - this only affects offline player data lookups.
2) If a 'offline player' request is made from an async task, it is executed normally. (the data is loaded)
3) If a 'offline player' request that cannot be immediately fulfilled is made from the main server thread, an exception is thrown.

The exception thrown as a result of 3) can be disabled in the config. In this case, the query is performed anyway. The main server thread will block until the request is complete.
2018-08-11 19:02:57 +01:00
Luck 56df15caf8 Add bukkit-legacy build back to the main project 2018-08-11 18:11:30 +01:00
Luck 03720665b3 Move to gradle 2018-08-10 20:39:29 +01:00
Luck 445429b510 Update text & asm dependencies (fixes #1142)
Updates for:
https://github.com/KyoriPowered/text/commit/6a7fda4e80c48884ba957ffaadd9219cead7962d
2018-08-10 00:09:34 +01:00
Luck c698587d53 Update text dependency 2018-08-09 22:43:41 +01:00
Luck b8466beee5 Completely rework event system
* Event instances are now generated dynamically at runtime. The performance hit of creating proxies at runtime is negligible in this case.

* A better EventBus implementation is now being used internally, API contracts are unaffected.
2018-08-09 22:39:33 +01:00
Luck efa666445f Initial support for Brigadier (1.13 commands) on Bukkit servers 2018-08-08 23:42:25 +01:00
Luck 59c7d77525 Load a up-to-date copy of group data before applying web editor changes 2018-08-08 09:00:35 +01:00
Luck 553da9baf6 Give some form of feedback when trying to applyedits no changes instead of no feedback at all (#1136) 2018-08-08 08:58:58 +01:00
Luck 486ddb3d42 Don't include any database properties by default (#1134) 2018-08-05 21:59:48 +01:00
Luck 381922fc02 Don't schedule a delayed load task on startup (#1130) 2018-08-05 21:51:53 +01:00
Luck 4c891f0819 Fix uppercase inconsistencies when saving users to SQL storage types (#1119)
This was causing issues when user data was saved, without UUID data being saved beforehand.

This commit fixes the way the inconsistency was introduced, and ensures that inconsistent data is made consistent in the future. (when players next login)
2018-07-30 11:22:50 -07:00
Luck 4b3d11ccab More SQL escaping (#1091 & #1126)
Follows from c16630c32b
2018-07-29 17:14:48 -07:00
Luck b1ab465991 Misc cleanup 2018-07-29 17:12:05 -07:00
Luck 952e41ad3d A few API javadoc improvements 2018-07-27 23:45:16 -07:00
Luck ae3adf23c8 Fail silently when plugins use reflection to add to dummy permissibles (#1117) 2018-07-24 21:21:05 -07:00
Luck c3cdf387c2 Fix NPE in GroupManager migration (#1118) 2018-07-24 21:03:14 -07:00
Luck 054f0c2c19 Don't add spaces when formatting 'concise' durations 2018-07-24 20:59:49 -07:00
Luck 2f7fce2109 Change name of Sql messenger table for compat with changes in the previous commit 2018-07-15 22:49:09 -07:00
Luck 07469599bc Rewrite MessagingService message encoding, conform to new plugin message channel requirements
* This change isn't backwards compatible with previous builds, this version (& onwards) won't be able to "communicate" with old versions, and vice versa.

* MC 1.13 requires plugin message channel names to be namespaced, so 'lpuc' has been changed to 'luckperms:update'

* The channel names for Redis/Lily types have also changed, I've been wanting to change the encoded format to something a bit saner for a while, and this seemed like a good time. Changing the channel names a) keeps things consistent and b) means I don't have to worry about old versions interpreting the new format.
2018-07-15 22:42:37 -07:00
Luck 08869da96e misc cleanup 2018-07-13 17:51:30 -07:00
Luck 7540a6eb70 Send more appropriate message when no users/groups match the editor type (#1096) 2018-07-13 17:51:21 -07:00
Luck fa2d9357b8 Allow FileWatcher locations to be registered after initial start 2018-07-12 17:10:07 -07:00
Luck 247a40b65f Fix /lp search for groups when using separated file storage (#1094) 2018-07-12 16:35:32 -07:00
Luck 01ffe6ad5a Use synchronized wrapper for NodeMap backings 2018-07-12 09:50:10 -07:00
Luck da3c2a073a cleanup build scripts a bit 2018-07-11 13:09:54 -07:00
Luck c16630c32b Escape groups keyword in SQL queries to (hopefully) fix compat with newer versions of MySQL (#1091) 2018-07-11 13:09:20 -07:00
Luck bf64f465a8 Re-implement Bukkit 1.7.10 support 2018-07-01 15:31:28 +01:00
Luck c1e0b874d8 Add helpful message for users on first startup 2018-07-01 15:07:25 +01:00
Luck c780266139 Add setprefix, setsuffix, settempprefix, settempsuffix commands (#840) 2018-06-27 17:31:30 +01:00
Luck 08454d58d0 Refactor the way contexts are cached on all platforms (#1071)
Should fix memory leak issues on BungeeCord
2018-06-27 00:17:53 +01:00
Luck ee13540d78 Specify explicit global context in generated LP commands when default contexts have been set (#1062) 2018-06-26 14:39:18 +01:00
Luck b4ff54ffc8 Apply Sponge implicit wildcards after Bukkit style .* wildcards 2018-06-24 21:44:12 +01:00
Luck 6f96d9c7d1 Fix NPE on Nukkit load (#1059) 2018-06-19 23:40:13 +01:00
Luck 5b66436519 Ensure the backing of LPSubscriptionValueMaps is a WeakHashMap (#1058) 2018-06-19 23:35:19 +01:00
Luck 379eb00b69 Cleanup various message localisations, limit the size of the PermissionRegistry 2018-06-19 22:27:47 +01:00
Luck 2036127612 Cleanup action log formatting and pagination
This is technically a breaking change to the API, but I'm fairly certain hardly anyone is using these methods (the pagination functionality in the API is pretty useless)

Can always add them back if it becomes an issue
2018-06-18 16:08:18 +01:00
Luck 957a918bd6 Fix loading on BungeeCord (#1054) 2018-06-17 09:49:38 +01:00
Luck 6b305972ac Fix sponge build script 2018-06-16 18:41:53 +01:00
Luck b8c06904ab Make logging messages a bit less obnoxious
* Removed the ascii text from the startup output
* Log messages (but not command output) is now sent through the standard server logger, and isn't colored
2018-06-16 16:59:59 +01:00
Luck 6baa472567 Fix context cache invalidation 2018-06-15 19:07:24 +01:00
Luck 9c449def57 Update some dependency versions 2018-06-13 20:29:00 +01:00
Luck e4acc133a9 remove some unnecessary interfaces 2018-06-12 18:18:38 +01:00
Luck 8b181b877b Nukkit stores attachments in a set, not a list (#1046) 2018-06-11 17:07:56 +01:00
Luck 194790110d Fix node comparison for identical nodes except the value 2018-06-07 19:58:55 +01:00
Luck c0cd197bd0 Don't allow players to be added to SubscriptionValueMaps 2018-06-07 17:01:25 +01:00
Luck 30ce269873 Disable hikari leak detection (#1033) 2018-06-05 20:33:23 +01:00
Luck 4d7be13c16 Don't reload Sponge persisted subjects when a save is pending 2018-06-03 20:46:50 +01:00
Luck 8cf0f7da5f Improve buffering code 2018-06-03 19:36:55 +01:00
Luck bcb4e5ca64 cleanup various comparators 2018-05-31 23:41:37 +01:00
Luck 07b003c77a Make the dummy attachment a bit more compatible
still MassiveCore lol
2018-05-31 01:01:29 +01:00
Luck f4e4f727dd More workarounds to support MassiveCore's modification of attachment permissions via reflection 2018-05-31 00:51:33 +01:00
Luck 644c53a074 Add workaround for plugins adding/removing/modifying permission attachments via reflection (#1024)
who knows why they're doing it, it's not even beneficial for performance...
2018-05-30 13:17:41 +01:00
Luck c66622bd09 Fix regex permissions not really working properly (#1021) 2018-05-29 14:45:21 +01:00
Luck adf0589184 Print a more informative error when the port is missing from the address arg (#1022) 2018-05-29 12:40:39 +01:00
Luck b7de0e6901 Provide an even more detailed warning message when other uuids are present for a username
We can use the data we have about the UUID and the platform LP is running on to infer more information about what the problem (potentially) is.
2018-05-25 17:05:26 +01:00
Luck a90e59ec97 Fix cache invalidation when group data changes (#1010) 2018-05-21 18:48:47 +01:00
Luck f4882c1c14 Cache the creation of Sponge proxy subject classes (#1005) 2018-05-17 18:19:45 +01:00
Luck ed3b5a3cf1 Lazily load contexts cache for Sponge subjects (#1005) 2018-05-17 18:12:20 +01:00
Luck 45e2b7b12f Fix saving node attributes on non-YAML file storage types (#999) 2018-05-16 19:30:05 +01:00
Luck 1e73986c60 Allow world rewrite options to apply in (some) Vault lookups (#990) 2018-05-16 19:04:09 +01:00
Luck 20f992110d Refactor meta stack element creation, add 'from_group' & 'not_from_group' elements 2018-05-16 18:46:25 +01:00
Luck 18f09f9862 Various performance optimizations 2018-05-15 00:08:23 +01:00
Luck a0be1c7c48 Fix issue with Bukkit attachment permissions never being removed (#991) 2018-05-13 14:06:23 +01:00
DoNotSpamPls 5d34661a15 Readme fixes (#993) 2018-05-12 16:40:54 +01:00
Luck 1639879106 Reduce the number of config lookups required when calculating contexts 2018-05-12 01:51:38 +01:00
Luck a927ca659f Reduce the throughput on the contexts cache in ContextManager (#929) 2018-05-12 01:34:34 +01:00
Luck 804c884d8b Update configurate to fix issues with legacy guava compat 2018-05-06 19:57:50 +01:00
Luck 51f215b8ac Add PlayerDataSaveEvent 2018-05-06 18:21:14 +01:00
Luck 64838708ab Release version 4.2.0
blaze it
2018-05-06 17:16:36 +01:00
Luck 91b7af52ac Use the servers uuid cache in the output to /lp search if LP doesn't have data (#974) 2018-05-06 16:20:08 +01:00
Luck d3dded8791 Fix jedis shading (#930) 2018-05-06 15:58:40 +01:00
Luck 022b385c0a Fix /lp search query (#972) 2018-05-05 18:39:13 +01:00
Luck 7ee9b93365 Convert bulkupdate & search functionality to use PreparedStatements (#972) 2018-05-05 18:17:48 +01:00
Luck c4c98aaabf Improve the behaviour of the APIs (now somewhat redundant) holder refresh method 2018-05-04 23:17:06 +01:00
Luck 10c0efaa5d Fix bad caching logic resulting in super high CPU usage 2018-05-04 23:12:46 +01:00
Luck d8a7d8de4a Throw a more detailed error when database connection info is missing 2018-05-04 21:27:57 +01:00
Luck ab8b675bae Add flag to exclude users from an export (#961) 2018-05-04 18:19:52 +01:00
Luck 194b602fd6 Implement different comparison methods for /lp search (#917) 2018-05-04 18:11:11 +01:00
Luck 7da0c58b76 Improve consistency of contextual primary group caching 2018-05-04 17:24:40 +01:00
Luck 2dbbea4993 Remove the locks in NodeMap to ease thread contention when lots of processes are resolving inheritance & refactor the way LocalizedNodes are created (#734) 2018-05-04 16:16:12 +01:00
Luck 55d59bb1c4 Make auto-op changes take effect (almost) immediately (#943)
"almost immediately" is better than "after a relog" ;)
2018-05-03 20:21:52 +01:00
Luck a6facf7492 Refactor the way holder caches are invalidated in order to improve consistency (#734) 2018-05-03 19:36:10 +01:00
Luck b8a1871cf1 Fix guava being accidentally shaded 2018-05-03 13:46:17 +01:00
Luck f556c75d94 Allow display names to be set in specific contexts (#963) 2018-05-02 21:27:21 +01:00
Luck 58bd7de66a Implement equals, hashcode and toString for NodeTypes 2018-05-02 20:35:20 +01:00
Luck 4547b52748 Refactor extended node types, general cleanup 2018-05-02 20:18:57 +01:00
Luck b9acb84119 Optimize WildcardProcessor 2018-05-01 00:20:39 +01:00
Luck e3a783c546 Maybe fix problems with symlinks (#956) 2018-04-30 14:44:09 +01:00
Luck 2e136666be Remove storage buffers 2018-04-29 11:33:51 +01:00
Luck 7d089cb5f0 Refactor configurate deo serialization of permission data, add support for the TOML format 2018-04-28 21:26:59 +01:00
Luck 3784d904fb Some small fixes and changes for ContextSet implementations 2018-04-27 18:50:36 +01:00
Luck fef6ebf793 Context set values should be lowercase'd too 2018-04-26 19:51:05 +01:00
Luck 316e177c1d Exclude temporary file changes from FileWatcher (#945) 2018-04-26 18:44:53 +01:00
Luck 4cdff14c7c Apply improvements to the caches in AbstractContextManager (#929) 2018-04-25 21:14:16 +01:00
Luck 97121bc719 Add some missing null check annotations 2018-04-25 21:02:17 +01:00
Luck 1312aac349 Add promote and demote methods to the API (#938) 2018-04-25 19:58:56 +01:00
Bogdan 8a5c9ddef2 Added explicit column names in INSERT queries. (#939) 2018-04-25 18:27:28 +01:00
Luck 55382519a1 Fix sponge split-storage config section being in the wrong section of the config (#928) 2018-04-25 17:30:56 +01:00
Luck cbb562b603 Fix sponge subject storage 2018-04-25 17:30:02 +01:00
Luck ba51f803ba add more logging to the importer 2018-04-25 17:15:30 +01:00
Luck d73543408e Fix misplaced sponge config options 2018-04-23 21:31:04 +01:00
Luck 7d90dba08b Update some dependency versions 2018-04-21 23:26:34 +01:00
Luck f11ebe6166 Replace file logger with json based system 2018-04-21 18:16:35 +01:00
Luck 1b917f0901 Fix init error in SeparatedConfigurateDao (#924 & #925) 2018-04-21 17:03:59 +01:00
Luck 328353d053 Implement the option to combine yaml/json/hocon storage files into one 2018-04-20 21:59:32 +01:00
Luck 4e87489dc1 Output meta in inheritance order in the 'meta info' command (#908) 2018-04-20 15:04:29 +01:00
Luck 8e5bcdd5ea Move schema files to a namespaced package (#899) 2018-04-20 14:59:06 +01:00
Luck 882a29029e Account for Sponge permission defaults in SpongeSenderFactory#getPermissionValue (fixes #920) 2018-04-20 14:17:29 +01:00
Luck 4704c5c975 Add full diff to the log when webeditor data is applied (#922) 2018-04-20 14:06:35 +01:00
Luck 957365ab91 refactor inheritance graphs slightly 2018-04-20 14:00:50 +01:00
Luck f8d34d7f46 Fix compile 2018-04-09 20:58:52 +01:00
Luck cb185e4827 Minor misc changes 2018-04-08 22:58:15 +01:00
Luck f5c6b9e3d4 Add 'permission clear' command (#893) 2018-04-04 18:46:01 +01:00
Luck 96f0f46b3e Update readme 2018-04-04 17:10:33 +01:00
Luck 6a5b7ce3a1 derp 2018-04-04 15:29:45 +01:00
Luck f33c540efb Register Sponge PermDescriptions to the LP permission registry 2018-04-03 21:56:15 +01:00
Luck 7684ac5d3a Add extra parameter to EventBus#subscribe which allows a handler to be bound to a plugin 2018-04-02 17:26:02 +01:00
Luck c13b01da01 misc cleanup 2018-04-02 16:02:55 +01:00
Luck 3453f05aca Copy usernames in the GroupManager migration (#883) 2018-04-02 13:34:30 +01:00
Luck c8bb85a06b Don't intern strings in permission checking process 2018-03-31 22:13:10 +01:00
Luck 2aabc9902f Rename verbose paste to verbose upload 2018-03-31 22:09:58 +01:00
Luck 6dba778e60 Catch exceptions thrown in repeating tasks to avoid subsequent executions from being cancelled 2018-03-31 11:13:27 +01:00
Luck cbeaaca7af Fix shutdown hang (#881) 2018-03-31 11:11:42 +01:00
Luck 0e69c8902d Revert f63d6cf 2018-03-31 10:26:22 +01:00
Luck f63d6cfced Properly escape sql query for loadTrack (#877) 2018-03-30 21:50:03 +01:00
Luck 72f9de6cc7 Fix resolving data directory on Sponge servers with a custom config dir location (#875) 2018-03-30 21:37:33 +01:00
Luck 509e89b9cf Clarify the showtracks output (#862) 2018-03-30 11:58:32 +01:00
Luck 90cce19baf Make the world-rewrite map case insensitive (#863) 2018-03-30 11:54:17 +01:00
Luck e4e93b1af1 Improve the way player uuid data is saved/stored. Add a warning message to catch ip forwarding issues 2018-03-29 21:46:55 +01:00
funniray 8f30176edd Fixed command arguments for Nukkit (#871) 2018-03-27 16:43:49 +01:00
Luck 4923d10b86 Encode editor payload using UTF-8 (#841) 2018-03-18 20:58:33 +00:00
Luck bd3a4e1ad7 Fix Sql messenger table name & bug which meant entries were only received after a 1 min delay 2018-03-18 18:58:53 +00:00
Luck 0f99a6c5ca Fix recursive proxying in PhasedStorage
ugh
2018-03-18 18:31:30 +00:00
Luck 0150da94a8 Apply table prefix to the SQL messenger 2018-03-18 17:38:52 +00:00
Luck b8da286f64 Replace huge forwarding classes with java Proxy instances 2018-03-18 17:36:07 +00:00
Luck da797f154d Implement Messaging Service using SQL (#534) 2018-03-18 16:02:04 +00:00
Luck 926195efc4 Fix Sponge persisted subject parent serialisation 2018-03-18 11:41:13 +00:00
Luck 8c1c5c820c Fix Sponge subject inheritance 2018-03-18 10:41:27 +00:00
Luck f63f652edb Fix parentadd and parentremove sponge commands 2018-03-18 10:09:21 +00:00
Luck 174ef187e8 Rename role parameter in PermissionDescription.Builder#assign 2018-03-18 10:02:16 +00:00
Luck d1e76f401a Reorganise the default configuration 2018-03-17 21:03:50 +00:00
Luck d52983c5af Fix tristate check event on BungeeCord for console senders 2018-03-17 15:03:40 +00:00
Luck 4773934481 Fix race condition in the import process (#833) 2018-03-14 22:01:52 +00:00
Luck dbfc524180 Fix NPE in Message#asString (fixes #822, #823, #824) 2018-03-13 15:30:35 +00:00
Luck 60aa7c6104 Fix compile 2018-03-12 21:27:23 +00:00
Luck 907d716929 Reorganise commands 2018-03-12 21:25:39 +00:00
Luck 1689a8abe2 Fix adding null json values (#818) 2018-03-12 19:01:38 +00:00
Luck 5db3820df4 A few minor API javadoc changes 2018-03-12 18:58:11 +00:00
Luck f969e2e52b Strip color when sending messages to the fallback logger 2018-03-09 16:43:29 +00:00
Luck cde2306079 Compress editor/verbose/treeview data using gzip before uploading 2018-03-09 16:21:45 +00:00
Luck f6c440c172 Further improvements to the Sponge service design 2018-03-08 21:51:25 +00:00
Luck 1b98667365 Fix IsolatedClassLoader on Java 9 (#815) 2018-03-08 18:36:41 +00:00
Luck bf69d5314e Implement Sponge subject lookup queries using CachedData from LP common 2018-03-07 23:50:23 +00:00
Luck 6d2ea659a4 Fix errors relating to sponge plugin parameter being an illegal argument (#810) 2018-03-03 20:43:41 +00:00
Luck 0d89840179 Reduce the number of entries sent to the verbose viewer, cleanup old hikari try..catches 2018-03-03 20:41:46 +00:00
Luck f93e8fdccd Always fire SubjectDataUpdateEvent async 2018-03-03 16:27:43 +00:00
Luck 68e4d36f40 Extract common plugin behaviour into an abstract class 2018-03-03 16:26:37 +00:00
Luck cd5447de38 Submit users/groups to the editor in weight order 2018-03-01 18:26:32 +00:00
Luck 6c0bb61cb1 Remove sponge migration commands 2018-03-01 11:03:22 +00:00
Luck d9a45b1090 Implement SubjectDataUpdateEvent (#753) 2018-03-01 10:58:08 +00:00
Luck 7549b3eb9e Return a dummy value instead of throwing an exception when an offline player is queried via Vault (#806) 2018-03-01 10:08:09 +00:00
Luck 8f82ef7eb4 Add copyFrom method to Node.Builder 2018-03-01 09:19:26 +00:00
Luck fbe84322b5 Cleanup parts of the sponge service implementation 2018-03-01 08:48:39 +00:00
Luck 98fb9946e4 Refactor Contexts class 2018-02-28 19:13:21 +00:00
Luck 984bc5860f Set allow-invalid-usernames to true by default for Nukkit (#798) 2018-02-26 17:35:34 +00:00
Luck a42d27f056 Don't intern strings in ContextSets (#797) 2018-02-26 17:27:28 +00:00
Luck aa4833ed74 Fix NPEs caused in LPPermissionMap (#794) 2018-02-24 22:59:18 +00:00
Luck 6704ac4b46 Fully relocate the jedis driver 2018-02-24 18:20:56 +00:00
Luck 4e4ec8e608 Bump caffeine & hikari version 2018-02-24 14:15:51 +00:00
Luck 4f4a387f04 Run the permissible monitoring injector twice 2018-02-24 14:08:36 +00:00
Luck d0143f9e54 Fix issue with loading on old CraftBukkit versions 2018-02-24 14:04:22 +00:00
Luck b2175e885f Fix compat with older Gson versions (#791) 2018-02-24 13:50:38 +00:00
Luck 68dd96e563 Properly bump version 2018-02-23 22:16:52 +00:00
Luck 168e712324 Update API to 4.1 2018-02-23 22:13:41 +00:00
Luck 2889c28815 Separate prefix/suffix/meta nodes into their own section within yaml/json/hocon storage files 2018-02-23 15:59:12 +00:00
Luck 966bf8bf51 Replace deprecated method usage in NodeTools 2018-02-23 14:20:30 +00:00
Luck 63ff3c34b3 Fix default assignment expressions checking temporary permissions (#783) 2018-02-22 23:38:26 +00:00
Luck 736105cc12 Add node equality predicates, and provide way to determine hasPermission behaviour using them (#782) 2018-02-22 23:34:35 +00:00
Luck b1fa4263ed Fix illegal argument exception when a proxied Sponge calculator adds an empty context (#780) 2018-02-22 22:24:21 +00:00
Luck 31d435dc2b Update web related functionality to point to new locations and APIs (#770) (#784) 2018-02-22 22:09:37 +00:00
Luck da9977a30f Fix compile and some minor formatting errors 2018-02-20 20:15:48 +00:00
Andrew 9c92522564 MongoDB Replica Set connections cannot resolve (#776 & #777) 2018-02-20 19:59:29 +00:00
Luck 31e436868d Nukkit support (#764) 2018-02-18 15:10:35 +00:00
Luck 794455d728 Refactor bulkupdate comparisons 2018-02-16 22:25:19 +00:00
Luck 0adf85746d Abstract out the process of traversing the inheritance tree, add configurable option to choose which algorithm to use (#719) 2018-02-16 17:46:17 +00:00
Luck f1047df98e Log checks made against non Player command senders in LP bungee 2018-02-16 13:41:21 +00:00
Luck 765f9d2545 Remove old schema migration code, cleanup a bit 2018-02-16 13:19:43 +00:00
Luck 0b5588a7dd Cleanup temporary permission auditing process 2018-02-16 12:35:25 +00:00
Luck 4fda89d5c8 Wrap unimportant sql migrations in try..catch (#755) 2018-02-16 12:13:15 +00:00
Luck b8c5c60ece try to fix null proxySelector issue with okhttp 2018-02-15 22:20:11 +00:00
Luck a3730aceeb i'm a dummy 2018-02-15 22:08:42 +00:00
Luck df5240a67c Lazily initialise Http client 2018-02-15 22:03:53 +00:00
Luck 620b0c898c Add ability to edit multiple users/groups in the same editor session 2018-02-12 22:04:39 +00:00
Luck 02ac4bc48b Allow temporary-add-behaviour to be defined as an argument to the add/set commands (#747) 2018-02-10 22:04:53 +00:00
Luck d14310768c Allow bulkupdates without constraints (#746) 2018-02-10 21:51:57 +00:00
Luck 63f8e8849f extract WeightCache out of PermissionHolder 2018-02-10 21:27:02 +00:00
Luck 7e7268bb5a Filter expired entries from user/group bulk permission search results (#736) 2018-02-07 18:03:25 +00:00
Luck 173286d404 Rebuild default and child permission lookup maps live instead of only once when the plugin first enables 2018-02-04 20:50:35 +00:00
Luck fd937e3209 Refactor permission processors, misc cleanup 2018-02-04 18:39:34 +00:00
Luck 31df29194b Add source to UserPromote & UserDemote events (#722) 2018-02-01 21:33:32 +00:00
Luck a1a2e189b6 Refactor PEX primary group detection to exclude temporary parents 2018-02-01 20:31:54 +00:00
Luck 5799a26cb7 Migrate temporary permissions / parents in PEX migration 2018-02-01 20:03:20 +00:00
Luck fe200ca1ec Add API methods to load users/groups/tracks and return a future encapsulating the resultant object instead of a success flag 2018-01-30 15:55:36 +00:00
Luck 7f7116e1c7 Use OkHttp for web requests 2018-01-30 00:08:00 +00:00
Luck 0cc1c4e5a7 fix build, refactor Bukkit model classes 2018-01-28 14:18:53 +00:00
Luck 2bc56de1c3 Don't store API delegate instances for all users 2018-01-28 00:26:58 +00:00
Luck e28d15456c Update some dependencies 2018-01-25 23:31:31 +00:00
Luck 54dbede130 Add /lp debug command 2018-01-24 19:13:29 +00:00
Luck 982254ff5e Reduce the amount of unnecessary data in info command outputs a bit 2018-01-23 19:55:21 +00:00
Luck e1c60fa70f Only query online players when upgrading usernames --> uuids in Vault hooks 2018-01-23 17:07:26 +00:00
Luck 6923c4e247 Log the name of the calculator when an exception is thrown 2018-01-23 16:52:50 +00:00
Luck 0eba5f1cbc Add a means to provide a custom Storage dao implementation (#590) 2018-01-22 23:21:47 +00:00
Luck 4858e59b70 Don't relocate H2 or SQLite depends in favour of loading into isolated classloaders (fixes #704) 2018-01-22 21:32:31 +00:00
Luck 1f70ad978f Cleanup usages of loadUser/loadGroup/loadTrack - eliminate possibility for unloading race condition (#706) 2018-01-22 17:34:15 +00:00
Luck 40294b10f5 ensure that we always use the shaded JDBC driver 2018-01-21 22:20:00 +00:00
Luck 8d045be0b0 misc cleanup 2018-01-21 21:35:25 +00:00
Luck e24a482deb Don't call events for changes to transient nodes 2018-01-21 20:31:48 +00:00
Luck f18d230ff6 Force a clear of transient nodes when a User quits, don't just rely on their instance being unloaded 2018-01-21 20:25:00 +00:00
Luck 72d4e5cf7a Remove the 'use-server-uuids' option and internal UuidCache system
The feature has stuck around since the early days - and solves a problem which really should never occur.
2018-01-21 20:18:13 +00:00
Luck 4c3e28ba85 Only show enduring nodes in command output, encapsulate the Node multimaps in PermissionHolder into separate class 2018-01-21 19:53:20 +00:00
Luck 821dc4ef56 Expose a means to implement the plugin's MessagingService via the API 2018-01-19 23:35:41 +00:00
Luck 612712f015 fix accidentally marking guava as compile in the previous commit 2018-01-19 19:29:34 +00:00
Luck 03a93b1186 Apply dependency remapping using an isolated classloader
* Fixes the issue which prevented LP from loading on Java 9
* Should also fix #697
2018-01-19 19:27:08 +00:00
Luck 04ffd00c0e fix typo in /lp <u/g> editor message 2018-01-19 16:31:15 +00:00
Luck a74475d4cd serialise -> serialize 2018-01-18 19:21:02 +00:00
Luck 05ac7e6041 refactor the way verbose filters are parsed - tokenize on first init as opposed to on each check 2018-01-17 19:30:05 +00:00
Luck 5ae90f2a4b Log verbose checks for the console, commandblocks & entities when running on Bukkit 2018-01-16 19:20:06 +00:00
Luck b800db03fc Nest the 'switchprimarygroup' command under the 'parent' subcommand 2018-01-15 21:09:42 +00:00
Spanner_Man 662b958a7f Update Jenkins URL for the LuckPermsLegacy build (#686) 2018-01-15 20:48:09 +00:00
Luck 7cd5eea6d3 Display tracks relating to the group itself when the showtracks command is performed on a group 2018-01-15 20:39:18 +00:00
Luck ed223f0e4e Don't allow empty context keys/values (#688) 2018-01-15 20:06:20 +00:00
Luck 8a374aed04 add javadocs to Command class 2018-01-15 19:55:21 +00:00
Luck 9ceacdb739 Refactor some Sponge service details 2018-01-15 18:07:27 +00:00
Luck 39daed23c4 fix ~~minor~~ typo 2018-01-13 23:53:44 +00:00
Luck 19e6d4e4c8 Relocate dependency packages to prevent conflicts with other plugins 2018-01-13 23:27:55 +00:00
Luck 22006617d0 misc refactor for PermissionHolder & DummySender 2018-01-12 23:51:59 +00:00
Luck 3201d10bdd Rewrite the way user instances are cleaned up and unloaded - towards #674 2018-01-10 21:28:33 +00:00
Luck ea94bd8696 move bukkit-legacy module to a separate project, cleanup poms 2018-01-08 20:01:02 +00:00
Luck f646c04d09 Remove lombok from the project 2018-01-07 18:40:23 +00:00
Luck 17ff9ac328 Allow shorthand nodes with single element lists (#665) 2018-01-03 19:25:47 +00:00
Luck 283516614b Create CONTRIBUTING.md 2018-01-02 15:02:25 +00:00
Luck 6c8f04f829 Implement PermissionsBukkit migration 2018-01-01 21:11:50 +00:00
Luck 505a10a8b1 misc refactoring 2018-01-01 19:48:20 +00:00
Luck 4fd89e6a34 fix compile 2017-12-30 19:38:58 +00:00
Luck 7bf666b062 fix abuse of static in SubjectReferenceFactory 2017-12-30 16:11:41 +00:00
Luck 764665cf15 Populate Subject cache when obtaining SubjectReferences for instances which already exist 2017-12-30 15:23:31 +00:00
Luck b9dfd7db54 Execute commands sequentially on a single thread executor 2017-12-30 12:16:34 +00:00
Luck e09c5622f7 Recompile against new powerfulperms namespace (#651) 2017-12-29 22:44:42 +00:00
Luck 717347273d Revert Spigot PluginClassLoader workaround 2017-12-29 20:40:43 +00:00
Luck 9bb1ba12b2 Fix issue with slf4j loading 2017-12-29 16:52:11 +00:00
Luck bff9715e7f Implement nasty workaround for Spigot's changes to the PluginClassLoader (#648) 2017-12-29 15:25:49 +00:00
Luck cfcd896c59 Fix broadcasting log entries 2017-12-29 00:41:45 +00:00
Luck aaa50cacda Allow spaces in world names 2017-12-29 00:39:54 +00:00
Luck 3413adf16f Send a different type of update ping for user changes, and only apply the change if the user is loaded 2017-12-28 13:37:55 +00:00
Luck 3d6aa69ca1 Improve various javadocs, add LogNotifyEvent 2017-12-27 17:00:54 +00:00
Luck ab115c4a6b Fix NodeFactory#nodeAsCommand (closes #639) 2017-12-27 10:30:13 +00:00
Luck e1e7bc8e0d Return empty string instead of null in VaultChatHook 2017-12-24 11:42:40 +00:00
Luck 6602b23f09 misc cleanup 2017-12-23 23:51:42 +00:00
Luck 862fe6e2e3 fix compile 2017-12-23 20:45:28 +00:00
Luck 5a34fa182a rewrite Vault implementation to upgrade requests to uuids instead of downgrade to usernames 2017-12-23 18:25:23 +00:00
Luck 0b72507e2d Correctly close flatfile database connections on disable, catch all exceptions when performing initial data load 2017-12-22 22:35:13 +00:00
Luck cc3ddd51fd fix copyright headers 2017-12-21 11:09:42 +00:00
Luck f793fd5010 pass and account for the holder type when building PermissionCalculators 2017-12-19 22:48:53 +00:00
Luck fb92fd9357 Extract out common constants & magic values into factory classes 2017-12-18 22:19:25 +00:00
Luck a415a2705f Return the loaded objects from storage methods as opposed to success flags 2017-12-18 17:03:59 +00:00
Luck 765f140121 Various fixes for log commands 2017-12-17 21:20:22 +00:00
Luck cb47f9f94b Change log output format, refactor log pagination 2017-12-17 17:47:10 +00:00
Luck d0fb9f6aee Update text version 2017-12-17 17:14:43 +00:00
Luck 9d424f5122 Fix more broken message coloring 2017-12-17 13:41:37 +00:00
Luck f71237ea95 Send more helpful message when /lp is executed without any arguments 2017-12-17 13:31:45 +00:00
Luck fb5925e1e8 Add user clone command (#530) 2017-12-17 12:59:36 +00:00
Luck f86bdb7619 Misc cleanup 2017-12-17 12:17:46 +00:00
Luck ad5299d0cd Send a message when an editor upload begins 2017-12-16 23:29:50 +00:00
Luck 904bb90385 Refactor paginated command output, add flags for ordering 'permission info' entries, fix crashes caused by long messages (#591) 2017-12-16 21:05:43 +00:00
Luck 2e7a08c006 Fix promote / demote command inconsistencies (#609) 2017-12-14 21:43:44 +00:00
Luck 38e75da92f Fix user demote command success message (#609) 2017-12-14 18:31:52 +00:00
Luck 97708c2c80 Update locale files (#604, #601, #602)
#601 by @DarkFort
#602 by @EuropeJing
2017-12-13 16:42:30 +00:00
Luck e5ce64266f Add option to pull server setting from the server.properties file 2017-12-11 19:42:24 +00:00
Luck a765be0a6f Fix compat with older hikari versions (#600) 2017-12-11 19:26:17 +00:00
Luck 0bec93ab1c refactor context sets 2017-12-11 19:02:02 +00:00
Luck dfb1b8f841 Work around message bug when parsing two consecutive color codes 2017-12-11 17:39:35 +00:00
Luck 322b522a52 propagate i/o errors to the futures returned by the dao 2017-12-10 01:47:00 +00:00
Luck 9dd4f71526 Remove the isAcceptingLogins storage state in favour of just throwing exceptions on usage 2017-12-09 19:02:23 +00:00
Luck 94b4e3d366 Validate checksums of downloaded dependencies 2017-12-09 18:36:08 +00:00
Luck bbb2897d20 Fix compatibility with older Gson versions 2017-12-09 11:26:12 +00:00
Luck a5e41e479a Use static empty context set where appropriate, cache reversed comparator instances 2017-12-07 19:49:04 +00:00
Luck 2baea0ce13 Fix MongoDao issue causing unnecessary writes each time a user is loaded (#589) 2017-12-07 16:52:21 +00:00
Foorack 90cbff885f Migrate PermissionsEx ladders (#588) 2017-12-04 23:24:06 +00:00
Luck 0d9034504e Run a sync task after completing a bulk update (#579) 2017-12-01 17:44:57 +00:00
Luck 800749c5ed Update README.md 2017-12-01 00:02:35 +00:00
Luck 30f27f29b4 Update readme 2017-12-01 00:01:50 +00:00
Luck 2985cf7237 Don't run schema migrations for Postgre (#568) 2017-11-30 20:33:15 +00:00
Luck 003ddc51de Rewrite the MongoDB storage impl to use the modern node serialisation format 2017-11-30 20:25:48 +00:00
Luck c369ac6b90 Fix mongodb bulkupdate (#572) 2017-11-29 23:10:32 +00:00
Luck e2b9e37867 Change poms to conform to Sonatype's OSSRH requirements 2017-11-28 22:22:52 +00:00
Luck 1e105b4135 Cleanup sponge service impl 2017-11-25 15:56:02 +00:00
Luck c5c253af4e Fix bug when loading maps from the BungeeConfigAdapter (#563) 2017-11-25 12:45:57 +00:00
Luck 717835e5c1 Add config option for defining extra SQL connection properties (#563) 2017-11-25 11:37:30 +00:00
Mat't e9ba62dbd9 Update pl_PL locale (#556) 2017-11-24 21:12:16 +00:00
montlikadani ad5c22ecdb Update hu_HU locale (#558) 2017-11-24 21:11:50 +00:00
Luck 2e92b97f01 Update ru_RU locale (#560 - thanks @DarkFort) 2017-11-24 21:10:44 +00:00
Luck ae8fe0fe1e Refactor configurate dao 2017-11-23 22:51:05 +00:00
Luck d992d7f77c Fix race condition when saving null config nodes to non-existent files 2017-11-23 20:15:29 +00:00
Luck a7cb7ec1af Remove character constraints on group names, cleanup legacy node (de)serialization system 2017-11-23 20:05:38 +00:00
Luck 3afeb30795 Implement system for shorter editor urls & display diff when changes are applied 2017-11-22 20:54:58 +00:00
Luck 26feeb125e Don't allow user names to be set if the length exceeds 16 characters 2017-11-22 17:17:49 +00:00
Luck 211fb219a7 Catch and ignore exceptions thrown when migrating a specific entity 2017-11-22 16:59:19 +00:00
Luck e71ef834c0 fix issue with the LP Vault impl and servers with more than one server context 2017-11-21 16:44:20 +00:00
Luck 29eba93ee3 Fix zero length prefixes from locale files 2017-11-21 15:44:22 +00:00
Luck 52ebfe9309 Bump SQLite version 2017-11-20 15:16:00 +00:00
Luck b3e78c6dc1 Fix issue with loading tracks with configurate 2017-11-20 15:14:44 +00:00
Luck cd0184970a Don't try to run schema migrations for SQLite 2017-11-19 22:24:39 +00:00
Luck 6401480874 Fix compiling null AssignmentExpressions 2017-11-19 19:09:21 +00:00
Luck 6ca9eb13dd General tidy up 2017-11-18 23:20:48 +00:00
Luck 987ea51264 Expose more connection pool settings in the config file 2017-11-14 19:39:46 +00:00
Luck df37491199 maybe fix some bukkit migration issues when plugins use strange identifier formats, cleanup legacy message conversion on Bungee 2017-11-12 15:05:06 +00:00
Luck 9a420403de Attach extra data to the editor payload object to allow for tab completion 2017-11-11 22:57:25 +00:00
Luck 17da2807cf Bump dependency versions 2017-11-10 20:16:44 +00:00
Luck 22fba0c172 Fix broken usage of LogEntry#getActed 2017-11-09 21:05:06 +00:00
Luck 14005563a3 Move #refreshCachedData up the type hierarchy into PermissionHolder 2017-11-08 22:59:22 +00:00
Luck a115ff8ce2 Final bits of API refactoring, add group data caches, fix issue with LPPermissionAttachment fake map injection 2017-11-08 22:55:05 +00:00
Luck d75b29f51d Move a couple more methods around in the API 2017-11-08 15:48:55 +00:00
Luck 3e8f7911af Fix tab completions not being returned for empty strings (#538) 2017-11-07 22:16:48 +00:00
Luck 175a21c0e4 API 4.0 - this is a breaking change 2017-11-07 22:05:49 +00:00
Luck a2801bff7c Inject a fake map into the super PermissionAttachment instance to fix compat with plugins using reflection to change attachment data (#528) 2017-11-07 17:05:16 +00:00
Luck f1a50f433f Throw exception earlier if an invalid permission is added/removed via Vault (#526) 2017-11-07 15:22:31 +00:00
Luck 76bfde4d77 Don't prevent modification of group.<group name> nodes with permission subcommands 2017-11-04 19:12:46 +00:00
Luck d393a4c9ca Alias /lp player --> /lp user 2017-11-03 16:26:54 +00:00
Luck 9ea6b0b8bb Use "None" instead of "global" when no server name is specified 2017-11-02 19:32:13 +00:00
Luck c20b91d5ea Increase actor_name field length to account for changes to logging 2017-11-02 19:28:49 +00:00
Luck fad8a38bdf Use a string version of the full static context, as opposed to the server name 2017-11-02 19:25:35 +00:00
Luck 2440a38e82 add RedisBungee context calculator for the BungeeCord platform 2017-11-02 19:01:53 +00:00
Luck b7541c43c8 Add Sender#getNameWithLocation 2017-11-02 18:51:59 +00:00
Luck 0f10bb0bc9 Deprecate some unused methods in ImmutableNode, refactor #shouldApplyWithContext 2017-11-02 18:22:42 +00:00
Luck 357717886e Refactor the log creation process 2017-10-30 21:06:45 +00:00
Luck 94a4051d29 Add extra catch for null primary group in powerfulperms migration 2017-10-30 20:03:59 +00:00
Luck 0e581cbcf3 Increase actions actor_name column length (#525) 2017-10-30 20:03:03 +00:00
Luck 230d9725e8 cleanup & fix build 2017-10-29 20:37:29 +00:00
Luck dee41b315f Inject our own subscription map into the plugin manager instead of registering permissions individually for each player 2017-10-29 15:16:48 +00:00
Luck 72e6c75433 Cleanup / tidy up a number of classes 2017-10-29 12:58:49 +00:00
Luck ebe12f838c Fix user exports 2017-10-28 00:15:34 +01:00
Luck 7279fdc25f Fix changes not being saved for flatfile bulkupdate operations 2017-10-27 23:17:57 +01:00
Luck af5c859385 Fix temporary group display format in parent info command (#518) 2017-10-24 13:17:27 +01:00
Luck e8896fbdf7 Fix NPE on startup (#520) 2017-10-24 13:05:06 +01:00
Luck 54695b8046 Form more descriptive console & import usernames 2017-10-23 23:37:55 +01:00
Luck c573c755d2 Add option to cancel failed logins on BungeeCord variant 2017-10-23 16:59:07 +01:00
Luck b299301b69 Cleanup 2017-10-22 21:02:48 +01:00
Luck a3a7198777 More storage refactoring 2017-10-22 20:09:53 +01:00
Luck ca8cc91f37 Add group setdisplayname command (#493) 2017-10-22 16:58:53 +01:00
Luck 26c813c07b Mode storage refactoring - write group nodes into their own section in flatfile types (#502) 2017-10-22 14:22:52 +01:00
Luck f109cb684a Apply PermissionAttachment permissions at a higher priority than normal nodes using the transient system (#515) 2017-10-22 10:24:04 +01:00
Luck 1baefaade4 Try to find the most appropriate primary group before just adding a user to default - closes #506 2017-10-22 09:16:04 +01:00
Luck 5ac0f93214 Fix migrating null / non-existent usernames - reverts parts of 6bfeec6, fixes #514 2017-10-22 09:07:08 +01:00
Luck ecfbed00b1 Add config option to allow invalid usernames (#516) 2017-10-22 09:00:10 +01:00
Luck 6e429d6c78 Throw exception if directories cannot be created 2017-10-22 08:48:00 +01:00
Luck fa4bb0447a Rewrite flatfile storage (YAML & JSON) to use configurate, add HOCON storage method 2017-10-21 23:20:45 +01:00
Luck aa0be40124 Cleanup verbose handler & only send sponge OP command notification if the sender has permission 2017-10-16 18:55:17 +01:00
Luck 04d5310c04 Ensure users are a member of their primary group (#506) 2017-10-16 18:53:02 +01:00
Luck 74069af309 Throw an exception if we're unable to create the lib dir 2017-10-16 15:28:02 +01:00
Luck 6bfeec6d16 Fix updating primary groups for players who've never joined the server with SQL storage types (#500) 2017-10-16 14:43:58 +01:00
Luck 0f4c057395 Add highest_inherited and lowest_inherited meta stack elements 2017-10-15 15:13:23 +01:00
Luck 2fd74f3b7e fix MetaStackElement equality checks 2017-10-15 14:51:42 +01:00
Luck fb171a57c2 Ensure stored primary groups are always lowercase'd 2017-10-15 14:32:57 +01:00
Luck b26fc69e73 Remove usage of the now-redundant ExtractedContexts class, other misc cleanup 2017-10-15 14:23:51 +01:00
Luck 28961b1cfa Primary groups should come first, not last, when ordering groups for inheritance (#500) 2017-10-15 11:22:38 +01:00
Luck 597f2f7b1b Make parents-by-weight the default primary group calculation method 2017-10-14 22:54:54 +01:00
Luck 00cd8bb3f3 Prioritise primary groups when two inherited groups have the same weight (#500) 2017-10-14 22:50:50 +01:00
Luck 5732e60510 Remove cleanupUsers functionality
It was pretty useless (and wasn't implemented on SQL/Mongo storage types.) Data is naturally cleaned up over time as users are loaded/saved.
2017-10-12 20:38:08 +01:00
Luck 7b271e21e3 Update readme 2017-10-12 20:25:51 +01:00
Luck 1a5f9683c2 Fix build (whoops) 2017-10-12 20:21:49 +01:00
Luck 3b74d55442 Remove sponge comparison chart from readme 2017-10-12 20:19:53 +01:00
Luck 8920396360 Remove context pre-processing (mostly)
This approach isn't very effective when contexts are frequently changing, and it is hard to guess in advance which contexts are going to be in-use.

The Sponge version has proven that this whole system isn't really necessary.

Contexts for 'allow all' and 'global' are still pre-processed, however this should be significantly less work for the server. (even if it is being done async)
2017-10-12 20:17:52 +01:00
Luck 9c505e4402 Move Track methods away from checked exceptions, refactor ContextManager & primary group holders 2017-10-12 19:43:42 +01:00
Luck de4c6b384c Export using the /lp alias 2017-10-12 18:47:35 +01:00
Luck 6dec1ba8af Add hu_HU locale - thanks @montlikadani 2017-10-03 19:04:47 +01:00
Luck 9e6788de2f Refactor context manager 2017-10-03 19:02:14 +01:00
Luck 1bd7e5c9c4 Refactor sponge cache invalidation 2017-09-29 23:21:12 +01:00
Luck ec75fdddb5 Make verbose output more readable when a check is made against a lot of contexts 2017-09-27 20:11:17 +01:00
Luck f98aafb97c Fix world content on BungeeCord not being lowercase'd 2017-09-24 23:43:39 +01:00
Luck f4d2a0daf9 Bump dependency versions 2017-09-23 23:36:13 +01:00
Luck de8fb8de90 Only load slf4j if it's not already present on the server 2017-09-23 21:15:45 +01:00
Luck 44d137b8f9 Add project Code of Conduct 2017-09-22 16:09:50 +01:00
Luck 777c972bdc Cache SubjectReference instances, general cleanup 2017-09-21 21:59:27 +01:00
Luck f9efa15781 Re-add 'list' as an alias of 'permission info' - reverts #461, closes #473 2017-09-20 20:31:24 +01:00
Luck 1d1cd679dd Fix tab completion inconsistencies caused by argument rewrites - closes #481 2017-09-20 20:27:46 +01:00
Luck a9ed4686dd Avoid loading slf4j when running on Sponge 2017-09-19 22:13:02 +01:00
Luck 5b742eb5b2 Only schedule a user cleanup when LuckPermsApi#cleanupUser is called 2017-09-18 20:50:50 +01:00
Luck a3d78f4d0e Always load dependencies into the plugin classloader, and not it's parent - fixes #479 2017-09-17 19:30:43 +01:00
Luck 214929e5e5 Fix group expiry time not being exported (#474) 2017-09-14 19:10:18 +01:00
Luck 67602b8d85 Fix startup deadlock 2017-09-13 21:24:35 +01:00
Luck 2412edaa3a Cleanup subscription updates & UserManager#loadAllUsers 2017-09-13 20:18:48 +01:00
EuropeJing b1584aa2c3 Update zh-CN locale (#466) 2017-09-12 08:47:37 +01:00
Luck a14a416193 Make some ingame messages more consistent with the LP theme, general cleanup 2017-09-11 22:21:57 +01:00
Luck f3251e9407 Fix missing depend 2017-09-10 21:45:47 +01:00
Luck 096885d91f Add tracing to /lp verbose, API updates/cleanup, add login process event, and utilise string interning for faster context/node comparisons 2017-09-10 21:25:00 +01:00
Frank Zhang 368700156c Added uranium server support to DependencyManager (#464) 2017-09-08 14:25:49 +01:00
Luck 81cf50520b Fix NodeFactory#nodeAsCommand when unsetting meta nodes, fix meta unset command 2017-09-06 21:56:41 +01:00
Luck 649748c2d3 Bump caffeine and hikari versions (#462) 2017-09-05 23:56:45 +01:00
Luck bf7a708440 Send some extra data to the editor data object 2017-09-05 14:54:22 +01:00
Luck 8faa4d137b Fix some issues with the recent import/export changes 2017-09-04 23:20:21 +01:00
Luck 479bd91b74 Fix build 2017-09-04 22:32:02 +01:00
Luck 6bc7f1fca2 Refactor Importer/Exporter to use multiple threads (#317) 2017-09-04 22:24:07 +01:00
Luck dadd8e2c50 Don't publish/broadcast log entries from the import process - towards #317 2017-09-04 20:47:45 +01:00
Luck 03f342a21c Refactor command execution to use Locks per target instead of (effectively) one for all commands - towards #317 2017-09-04 20:42:21 +01:00
Luck 7fe5397e21 Fix incorrect usage of CompletableFuture#thenCombineAsync 2017-09-04 17:56:01 +01:00
Luck b6e1fd179e Add type argument to 'meta clear' command (#457) 2017-09-04 17:25:59 +01:00
Luck 754c7d8e3b Add config option to prevent primary group removal (#405) 2017-09-04 17:03:17 +01:00
Luck 925d3ccd1b Remove "list" alias for holder info (#461) 2017-09-04 16:55:10 +01:00
Luck d60d0ac9c5 Reduce buffer times, refactor MessagingService init 2017-09-04 16:49:43 +01:00
Luck e1b51dd6af Catch Throwable instead of Exception when setting up BukkitJsonMessageHandler 2017-09-04 13:03:09 +01:00
Luck fbe9d9f128 Run user cleanup task async and not on Storage init 2017-09-03 16:16:21 +01:00
Luck 509826949d Add login debug option 2017-08-27 13:54:26 +01:00
Luck 39aaa8a292 Update for latest Text version 2017-08-22 22:51:49 +01:00
Luck 069c76c53a Fix time test for node expiry times 2017-08-22 16:30:46 +01:00
Luck f45c0caa45 Refactor metastacks & primary group calculation 2017-08-21 15:45:29 +02:00
EuropeJing 41b0e10709 Update zh-CN locale (#450) 2017-08-21 10:38:30 +02:00
EuropeJing 8e8da20c13 Update zh-CN locale (#449) 2017-08-20 19:43:58 +02:00
Luck 269aa39378 Fix comparator and ensure @Nonnull annotated methods never return null in LogEntry 2017-08-20 14:51:46 +02:00
Luck ae8be97db7 Dispatch log entries via the messaging service 2017-08-20 13:32:52 +02:00
Luck f0ad40825b Refactor and cleanup Log classes 2017-08-20 01:35:03 +02:00
Luck 36d292747a Format times in /lp log into a shorter form 2017-08-19 11:38:08 +02:00
Luck b65d2262bf Remove "... data was saved to storage" messages 2017-08-19 11:08:28 +02:00
Luck a7ab0c6b36 Send a more helpful message when the non legacy version of LP is installed on Bukkit 1.7 (#437) 2017-08-18 13:58:41 +02:00
Luck c02fcb6508 Refactor weight lookups 2017-08-18 11:14:03 +02:00
Luck 07c38de44b Allow permission info command to be filtered by context (#442) 2017-08-18 10:44:54 +02:00
Luck 188d62c99b Fix issue with casting UUIDs in MongoDB backing (#443) 2017-08-18 10:35:56 +02:00
Luck 76b203ad10 Fix text dependencies being shaded 2017-08-17 10:12:08 +02:00
Luck 909844aef5 Update KyoriPowered/text dependency 2017-08-16 10:56:35 +02:00
Luck 046202719a Correctly export meta/prefix/suffix nodes to command strings 2017-08-14 18:58:12 +02:00
Luck ed15e2838d Fix checkinherits command not returning the inheritance data 2017-08-14 09:38:08 +02:00
Luck 82466c2e5d Properly implement Contexts#allowAll - bump API to 3.3 2017-08-13 22:21:04 +02:00
Luck c598daf350 Fix negating group permissions to cancel inheritance 2017-08-13 19:40:59 +02:00
Luck a40421fa1f Optimizations to the core PermissionHolder class
- Remove usage of Java 8 streams from frequently called methods
- Use LinkedLists where appropriate to improve Iterator#remove speed
- Cache immutable multimap conversion
- Rename some methods to make the intended use/behaviour clearer
2017-08-13 19:24:00 +02:00
Luck d98b464ce9 Cleanup verbose & treeview packages. Return known permissions from the PermissionVault as Sponge PermissionDescriptions 2017-08-13 12:07:05 +02:00
Luck 1d5e3205ac Refactoring & misc cleanup 2017-08-12 19:34:14 +02:00
Luck 07eb17f5d5 Fix Sponge PermissionDescription lookups (#425) 2017-08-08 10:37:54 +02:00
Luck 3951725852 Fix 'meta settemp' command using duration as the server context (#421) 2017-08-05 23:46:19 +02:00
Luck 77956d69ad Fix NPE with Vault #getPlayerGroups 2017-08-05 17:30:40 +02:00
Luck 5784458d03 Make Sponge's #getFriendlyIdentifier return usernames of Users and display names of Groups (#412) 2017-08-03 18:39:39 +01:00
Luck 3d2115ff3c Remove unnecessary extra cache in ContextManager 2017-08-02 21:48:22 +01:00
Luck 8618a67e2e Fix sponge config loading - closes #407 2017-07-31 22:26:59 +01:00
Luck 234b9cafd7 Give default group if needed after "parent remove" (#405) 2017-07-30 21:08:05 +01:00
Luck 4ecd899bac Fix IndexOutOfBoundsException with 'permission settemp' command (#403) 2017-07-30 15:23:42 +01:00
Luck ce2c943397 Inject bukkit permissible at lowest priority instead of low 2017-07-27 12:58:31 +01:00
Luck 51898abb71 Don't load contexts file twice 2017-07-26 10:31:14 +01:00
Luck e2f800dd63 Throw an NPE if a null delegate sender is passed to SenderFactory#wrap 2017-07-26 10:10:25 +01:00
Luck d9e5bc9345 fix error with null subject in ContextManager removal listener - closes #392 2017-07-24 19:42:35 +01:00
Luck e42cc101cc Cleanup & document a number of Bukkit impl classes 2017-07-24 14:32:10 +01:00
Luck 845367e847 Flush storage buffer more frequently 2017-07-22 20:42:53 +01:00
Luck 90afd3c3ed Cleanup handling of empty permissions when migrating data (closes #387) 2017-07-22 20:04:55 +01:00
Luck b4aeb04d1b Fix possible NPEs when calling API storage events - fixes #384 2017-07-22 00:06:37 +01:00
Luck 65b0d45738 Fix IllegalStateException in meta info command - closes #385 2017-07-22 00:00:58 +01:00
Luck 3c44388883 Update /lp info output 2017-07-19 22:15:12 +01:00
Luck 400f3a9156 Add option to disable colored logging (#382) 2017-07-18 17:58:40 +01:00
creator3 ad6e837aa5 Use single quotes in escapeStringForSql (#379) 2017-07-16 23:53:15 +02:00
Luck cadd7545c5 Use saner class naming 2017-07-16 21:16:08 +01:00
Luck b41dea9ee1 Implement support for futures & other changes in the Sponge Permissions API 2017-07-16 14:12:36 +01:00
Luck 7a6c0ab154 Improve /lp listgroups output - closes #368 2017-07-10 10:09:29 +01:00
Luck 1bb1f5ebb3 Fail silently when the Sponge Server is not available - closes #367 2017-07-10 09:18:58 +01:00
Luck fce5b8430d Use GA MySQL version 2017-07-09 18:05:08 +01:00
Luck 0befa6a491 Fix generating unset commands for temporary nodes 2017-07-07 19:39:31 +01:00
Luck b12ce943f7 Make 'meta info' and 'parent info' clickable (#311) 2017-07-07 19:28:26 +01:00
Luck d23b29aeb1 Update dependency versions 2017-07-07 14:48:42 +01:00
Luck 42d48c8da2 Implement argument based permissions for LP commands - closes #52, #170, #174 2017-07-07 12:43:13 +01:00
Luck 9e83a5e4d9 Add RedisBungee messaging service option for BungeeCord 2017-07-03 16:24:00 +01:00
Luck d2bf940105 Add option to use the servers uuid cache/lookup facility (#354) 2017-07-03 16:07:33 +01:00
Luck 7d4aca68cc Fix jsr being shaded & tweak javadoc generation to link to guava docs correctly 2017-07-02 22:04:37 +01:00
Luck d7094909c0 Change verbose output slightly 2017-07-02 21:29:48 +01:00
Luck 7083d55a9b Fix vault lookups with a specified world 2017-07-02 10:49:07 +01:00
Luck 770db2fee0 Export groups in order of weight, then alphabetically 2017-06-30 19:43:45 +01:00
Luck b8e65c4f26 Fix bukkit defaults still being applied to subscriptions when disabled 2017-06-30 19:32:12 +01:00
Luck 5cd5186092 Don't cancel re-allowed connections unless the cancel was made by LP 2017-06-26 21:39:59 +01:00
Luck fa0b66c2dc Fix lp tree max recursion property 2017-06-26 16:31:30 +01:00
Luck 1b199fd2c7 Fix NPE when loading locale file - closes #338 2017-06-24 17:26:52 +01:00
Luck 2ffbeeef8e Add jsr305 annotations to the API 2017-06-24 17:25:13 +01:00
Chris N 26ce8b8ab7 YAML/JSON batch permission defining (#337) 2017-06-22 10:41:29 +01:00
Luck 8e224c4a27 Don't force cancel Sponge ClientConnection.Join if the cancellation state changes, shuffle event orders slightly - fixes #335 2017-06-20 21:37:38 +01:00
Luck cf5318b92b Make command defintion/usage messages translatable 2017-06-20 20:20:41 +01:00
Luck e50fa17f7c Store all accumulated meta values in MetaCache 2017-06-19 21:48:52 +01:00
Luck 8766e3b408 Add jar signing to build scripts 2017-06-19 20:09:18 +01:00
Luck c4c7f06d83 Fix BungeePerms migration - closes #333 2017-06-19 16:43:00 +01:00
Luck 413e304845 Fix NPE with null context in FileWatcher 2017-06-14 17:32:02 +01:00
Luck 046daf23d0 Deploy source & javadoc jar with the API 2017-06-13 20:17:41 +01:00
Luck c57947949c Don't send messages to command blocks async 2017-06-13 17:30:01 +01:00
Luck 0acefde805 Tidy up configuration file layouts 2017-06-12 21:41:23 +01:00
Luck a9e751b4b8 Replace fanciful with KyoriPowered/text 2017-06-11 14:46:56 +01:00
Luck 3df1ae8ded Fix argument validation for parent settrack command - closes #321 2017-06-11 10:27:26 +01:00
Luck b4a2da0ea8 Add some missing tab completions, remove /lp log export command 2017-06-09 22:19:07 +01:00
Luck 5c5d1e8d0a Fixes some issues with username storage and handling
- Fix the yaml/json UUID cache corrupting username data when performing uuid --> username checks
- Fix handling of usernames when users are loaded

Closes #301
2017-06-09 18:20:12 +01:00
Luck ff0c988a1d Don't store attributes for permissions with only 'value: true' in YAML/JSON storage files 2017-06-07 21:04:14 +01:00
Luck b9fc8f4b5f Add MongoDB collection prefix option 2017-06-05 16:09:02 +01:00
Luck 2ecaa39cb6 Only resolve inheritances for groups which exist already 2017-06-04 16:41:20 +01:00
Luck 7b8654339c Maybe fix usernames not being updated in storage after name changes (#301) 2017-06-03 16:40:16 +01:00
dzegarek 306e252c31 Add pl_PL locale (#306) 2017-06-03 14:47:34 +01:00
Luck 87c3bd6293 Update README.md 2017-05-26 20:48:41 +01:00
Luck 307beebb58 Cleanup Bukkit PEX migration, fix user parents being transferred incorrectly 2017-05-25 22:24:55 +01:00
Luck 4109863aa9 Fix -s flag (#132) 2017-05-25 21:35:47 +01:00
Luck 0febdbe3a4 Update copyright headers in the API module 2017-05-21 09:47:08 +01:00
Luck 139dd5302b Cleanup login handling & reduce the amount of unnecessary logging output on startup 2017-05-18 22:30:01 +01:00
Luck cc907b6530 Don't catch exceptions thrown inside i/o (#291) 2017-05-18 21:16:31 +01:00
Luck ca1dacf2b6 Invalidate active context cache when a player changes world - closes #288 2017-05-16 21:52:46 +01:00
Luck abc1c164cf Expose MetaStacks in the API, general cleanup, release 3.2 2017-05-16 21:41:20 +01:00
Luck dc801464ef Refactor meta stacking to be mapped in MetaCache - towards lucko/LuckPermsPlaceholders#1 2017-05-16 19:13:08 +01:00
Luck 99c6fe20c2 Catch exceptions thrown by context calculators 2017-05-16 13:50:28 +01:00
Luck 9d780ae24a Fix misleading Vault debug message 2017-05-15 21:26:43 +01:00
Luck a44dec0402 Fix typo 2017-05-15 12:07:59 +01:00
Luck a081152baa Fix web editor url 2017-05-15 12:05:54 +01:00
Luck 9b50d48f46 fix compile 2017-05-14 22:41:25 +01:00
Luck 5121fc6b1f Cleanup 2017-05-14 22:15:25 +01:00
Luck d4ac261e85 Cleanup config keys, make editor URL configurable 2017-05-14 21:36:02 +01:00
Luck 2e9561371d Implement initial web editor support 2017-05-13 20:36:05 +01:00
Luck 942fd3c4ce Fix vault lookups with static context 2017-05-11 20:04:11 +01:00
Luck 8cf32752e9 Fix meta info only showing values in global context 2017-05-11 19:46:28 +01:00
Luck b240ca9939 Add parent cleartrack command, cleanup Messages enum 2017-05-09 16:26:55 +01:00
Luck e25d99129c Implement parent settrack command - closes #112 2017-05-09 14:06:16 +01:00
Luck 1fee47e087 Implement default contexts - closes #241 2017-05-09 13:36:43 +01:00
Luck e835b31277 Apply world rewrites on-top of the real world name, and apply recursively (#255) 2017-05-09 13:07:39 +01:00
Luck 6817945e12 Bump sponge API version, cleanup 2017-05-09 12:55:45 +01:00
Luck 030fb1262e Fix being able to negate permissions/parents/meta in specific contexts 2017-05-08 22:27:46 +01:00
Luck fae49096f3 Fix retrieving meta keys from Vault which contain delimited characters - closes #270 2017-05-08 21:43:20 +01:00
EuropeJing afd491ecea Update zh-CN locale (#281) 2017-05-08 20:17:51 +01:00
EuropeJing 09bc100ad9 Add zh-CN locale (#279) 2017-05-08 18:11:29 +01:00
Luck 037f18ac56 Fix zPerms parent group migration for users, and fix migration of temporary memberships 2017-05-08 17:45:17 +01:00
Luck a5746dfa21 Support sponge selector resolution - closes #275 2017-05-07 22:52:45 +01:00
Luck cedc5108fc Refactor Patterns to PatternCache 2017-05-07 13:56:42 +01:00
Luck 65af3d0f54 Add data constraints - closes #256 2017-05-07 13:44:29 +01:00
Luck 6c4fa65f91 Fix migrating weight with zPerms 2017-05-06 23:35:58 +01:00
Luck 4731ad8061 Fix migrating false zPerms nodes 2017-05-06 21:06:22 +01:00
Luck 7dc41e15d3 Fix users being cleaned up too early and then logging back into the server - closes #271 2017-05-06 18:24:44 +01:00
Luck 8326539d40 Refactor LP PermissionService to implement a modified API & add proxied classes 2017-05-03 20:14:31 +01:00
Luck 163e6e0f2a Always load user data caches alongside user instances 2017-05-02 16:55:08 +01:00
Luck f56bb251e9 Cleanup some stuff 2017-05-02 16:36:46 +01:00
Luck 152ca99276 Fix issue with bulk removing suffixes 2017-04-25 16:51:21 +01:00
Luck 7c398d2c67 Split up chat messages sent to console containing new lines 2017-04-23 20:51:24 +01:00
Luck a526c942ca Add config options to allow for finer control over how permissions are calculated, and set include-global to true on BungeeCord by default 2017-04-23 20:30:58 +01:00
Luck af8fd15929 improve speed of NodeTools#removeSamePermission 2017-04-23 11:51:56 +01:00
Luck 7bfd5d4bc8 implement atomic group insertion 2017-04-22 22:53:29 +01:00
Luck 4382d5c56d show uuid in log messages if username is null 2017-04-21 21:28:50 +01:00
Luck f43b9c96de cleanup login handling & add CountdownLatch to ensure the plugin has started before logins are handled 2017-04-21 19:10:25 +01:00
Luck c64f72e394 Fix issue with loading usernames on MongoDB - closes #257 2017-04-21 16:58:07 +01:00
Luck 3d54f832c5 cleanup duplicated method 2017-04-20 19:26:47 +01:00
Luck 867ba24c6c support glowstone (maybe) 2017-04-20 19:15:37 +01:00
Luck 9715c5394c Fix NPE caused by AllParentsByWeight primary group selector - closes #252 2017-04-18 17:11:07 +01:00
Luck 67b5c72520 Cleanup handling of unknown/null usernames for users 2017-04-17 19:31:52 +01:00
Articuno 43450f6cc7 Update RU locale (#250) 2017-04-17 10:12:37 +01:00
Luck a3737d4f35 fix typo 2017-04-16 11:08:54 +01:00
Luck 3314e94a9a Add not_on_track meta stack criteria 2017-04-16 11:06:05 +01:00
Luck a27436b086 Fix getting primary groups for offline users 2017-04-15 20:32:03 +01:00
Luck fe5554ffb1 fix build 2017-04-15 19:53:12 +01:00
Luck f305f8d822 Determine dynamic primary groups using current context 2017-04-15 19:08:04 +01:00
Luck 1f54bc41cc Cleanup poms, update copyright header 2017-04-15 19:01:52 +01:00
Luck c82d028429 fix yaml/json schema migration 2017-04-12 21:33:59 +01:00
Luck be2a8b7b07 Fix incorrect chat meta command usage 2017-04-12 17:59:51 +01:00
Luck 261fc82016 Remove getuuid command
why did that ever exist anyways
2017-04-12 17:25:22 +01:00
Luck 37b940f3a5 Convert promote / demote commands to use new context system, update en locale with latest changes 2017-04-12 17:11:01 +01:00
Luck 0504e904a2 Only perform flatfile schema migration if the new dir doesn't exist 2017-04-12 14:28:39 +01:00
Luck 71bfdd9bfd log the file name when exceptions are thrown during i/o 2017-04-12 14:09:51 +01:00
Articuno c7305f6b06 Update ru_RU locale (#238) 2017-04-11 10:47:43 +01:00
Luck 4fb07ff181 API changes for 3.1 2017-04-10 22:26:20 +01:00
Luck 4631dcf857 Ensure expired permissions are removed when users/groups are loaded for commands 2017-04-10 20:57:59 +01:00
Luck f6f9840eb7 Re-implement bulk updates 2017-04-10 19:33:23 +01:00
Luck 4de8165c95 fix issue with /reloading and permission registration 2017-04-10 18:17:09 +01:00
Luck 242672f49d Remove old bulk edit commands 2017-04-10 14:56:46 +01:00
creator3 c32c975a71 Fix accumulation of temporary perms with a world or server context (#235) 2017-04-08 20:49:10 +01:00
Luck 82e759d708 Make sure world names are lowercase'd 2017-04-08 17:00:36 +01:00
Luck 9de44d2605 Don't attempt to migrate empty permissions 2017-04-07 21:03:27 +01:00
Luck 132d0cf578 Fix export command switchprimarygroup output, and log player uuid if their username isn't included 2017-04-07 19:59:53 +01:00
Luck 029dc9f8d9 Make the standard MySQL driver the default again 2017-04-06 11:30:17 +01:00
Luck 5567b1dad8 Use the mariadb driver by default 2017-04-05 21:23:18 +01:00
Luck ea00ec64af Refactor NodeModel into a more useful class, remove duplicate context serialization methods 2017-04-04 19:19:31 +01:00
Luck 7259e6be0a Fixes for the verbose uploader 2017-04-04 17:17:57 +01:00
Luck 2e40557b39 Add '/lp group <group> listmembers' command - closes #203 2017-04-04 16:07:41 +01:00
Luck e68fc7c558 Improve performance of resolve methods in PermissionHolder, other cleanup 2017-04-04 15:22:25 +01:00
Luck 055dfb000d Only allow one server and one world in context sets parsed from command args 2017-04-04 13:47:50 +01:00
Luck b997ab6e3f Properly sort storage files - closes #227 2017-04-03 10:57:29 +01:00
Luck 25f31d0bb8 Cleanup sponge delegate classes 2017-04-03 10:27:31 +01:00
Luck 4cfd8a7e2c Fix broken command parameter & update default locale file 2017-04-03 09:53:26 +01:00
Luck 0ec19a8fee Implement accumulation of static contexts from a file 2017-04-03 01:42:49 +01:00
Luck 2749563f5d Replace guava caches with caffeine 2017-04-03 00:53:04 +01:00
Luck e7e2e3f7e0 Allow context pairs to be specified in commands, fix misuse of exceptions in the permission holder class 2017-04-02 18:44:05 +01:00
Luck 0a33c0aac5 Fix compatibility with older gson versions - closes #222 2017-04-01 07:26:05 +01:00
Articuno 24e09fd2d9 Add ru_RU.yml (#224) 2017-03-30 18:45:50 +01:00
Luck 4d0499a61e Avoid parsing UUID in sponge world calculator 2017-03-30 18:40:36 +01:00
Luck ae82807139 Add "use-vault-server" config option, depreciate vault primary group override feature 2017-03-27 17:35:28 +01:00
Luck 65147e1935 Remove missing permission nodes before adding new ones when saving users/groups with SQL storage 2017-03-27 16:54:59 +01:00
Luck 8e557d122b Fix some concurrency issues with login handling 2017-03-26 18:40:09 +01:00
Luck 486b19aa90 Cleanup some misc stuff 2017-03-26 16:10:49 +01:00
Luck 14cb34ac95 Force some config options to be read as lower case 2017-03-25 23:23:20 +00:00
Luck abfc23b04d Provide tab completion for rewritten arguments & add some more rules 2017-03-25 20:27:33 +00:00
Luck ebb24aefa1 Fix parent set command also adding default 2017-03-25 20:06:30 +00:00
Luck 2573f46f40 Fix removing temporary permissions/parents/meta in global context 2017-03-25 19:58:56 +00:00
Luck 5dcb8cd73a Output group/track lists in alphabetical order 2017-03-25 19:48:17 +00:00
Luck e4bfe09882 Don't bother loading test classes (#217) 2017-03-25 11:38:02 +00:00
Luck eecbfe04db Add es_ES locale 2017-03-25 11:13:45 +00:00
Luck 671e2adc32 Cleanup remaining (un)setPermission methods 2017-03-25 11:04:25 +00:00
Luck 1137e476dd Rewrite inheritance resolution implementation 2017-03-24 22:18:18 +00:00
Luck cb63b321d0 correct zPermissions migration logging tag 2017-03-23 23:18:03 +00:00
Luck c36b0d2975 Automatically push updates to other servers via the messaging service when commands are ran 2017-03-21 21:58:45 +00:00
Luck f8ad562b95 Rename "debug" classes to "verbose" 2017-03-20 17:22:18 +00:00
Luck c35ab38f36 Slight speed improvement for import processes 2017-03-19 20:52:35 +00:00
Luck 073b775566 Implement nicer json format for Sponge local data 2017-03-19 17:54:12 +00:00
Luck 85c7a7db8d Implement new file layout for YAML / JSON storage files (#211) 2017-03-19 15:37:30 +00:00
Luck 1e134df27d Clarify the file names of H2 and SQLite databases 2017-03-18 23:00:12 +00:00
Luck bdff84885a Enforce that ContextSets use the HashMultimap variant - closes #208 2017-03-18 20:18:18 +00:00
Luck f1a9c3722c Fix PM migration command not being registered 2017-03-18 17:26:44 +00:00
Luck 8b402f6423 Fix NoSuchMethodError being thrown for older Bukkit config classes 2017-03-18 15:34:29 +00:00
Luck a0aec52661 Correct the case of group names when retrieved from Node instances 2017-03-18 14:43:34 +00:00
Luck 407ab43dd1 Update PM migration to support latest version 2017-03-17 23:21:57 +00:00
Luck c2165e0196 Fix primary groups being selected in reverse order 2017-03-17 23:00:37 +00:00
Luck 2e75bc3f3b Add some alternate options for primary group calculation 2017-03-17 22:54:18 +00:00
Luck e91c2ca427 Add method to export Message enum and update language file 2017-03-17 21:17:59 +00:00
Luck 965ff04bcc Fix ClassCastException with MongoDB user search 2017-03-17 20:54:40 +00:00
Luck ac4bd418f3 Rename online-mode config option to use-server-uuids to better reflect/clarify its purpose 2017-03-17 20:51:06 +00:00
Luck e9e844c1f7 Include internal weight value in meta output if not already present 2017-03-13 20:17:54 +00:00
Luck aa2941fcdb Refactor and cleanup commands 2017-03-13 20:03:03 +00:00
Luck dbc909a317 Cleanup migration commands 2017-03-13 19:10:36 +00:00
Luck 11465a4ce9 Fix BungeePerms migration to account for group weights and negated permissions 2017-03-12 20:00:02 +00:00
Luck f5007f94dc Add server version info to the startup banner 2017-03-12 14:59:27 +00:00
Luck d18ac2e6eb Cleanup pom files, maybe improve build speed a bit 2017-03-12 14:28:35 +00:00
Luck b9fc5c39ae Listen for changes in data files and automatically update 2017-03-11 23:05:03 +00:00
Luck 9dc2278083 Cleanup a bit 2017-03-11 21:10:27 +00:00
Luck 281060a972 Make the clone commands work for existing tracks/groups too 2017-03-11 18:30:27 +00:00
Luck 91626f079d Fix mistake in removeprefix/removesuffix command descriptions 2017-03-11 18:26:29 +00:00
Luck 7305c6c54b Migrate group weightings onto the group itself as well as to the chat meta held by it 2017-03-11 18:24:25 +00:00
Luck bce7fa871d Fix getAllNodes cache not working properly, remove pre-process contexts on Bungee & cleanup some unused methods 2017-03-11 17:55:50 +00:00
Luck a35fd80763 remove placeholder expansion from main project 2017-03-11 14:02:17 +00:00
Luck b383f9dfbc Add some more placeholders to the expansion 2017-03-11 13:30:08 +00:00
Luck 680ad3c145 Update hikari version 2017-03-11 10:32:10 +00:00
Luck 7b712e7f90 Update readme 2017-03-10 23:30:08 +00:00
Luck 2462eac497 Run exporter in own thread and process user exports concurrently 2017-03-10 20:44:19 +00:00
Luck bb818c8942 Cleanup powerfulperms migration & remove support for older PP versions 2017-03-09 19:10:48 +00:00
Luck ddc881af11 Add new argument util method for reading context pairs 2017-03-09 17:56:15 +00:00
Luck 838fba9173 Switch all usages of file reader/writers to use java nio methods - closes #204 2017-03-09 17:55:33 +00:00
Luck 0b6f326c18 Fallback to uuid in the search command if the username is unknown 2017-03-07 22:17:49 +00:00
Luck 00895fc7ab Don't send json text on MC 1.7 2017-03-06 18:22:11 +00:00
Luck 07f38aa283 Fix possible issue with context conversion 2017-03-05 22:56:00 +00:00
Luck ecf1d3790c Fix issue where group nodes could be unset using the permission commands, and where users with per-server groups wouldn't be assigned to the default group globally 2017-03-05 19:05:05 +00:00
Luck 53c9e5bb4a Fix race condition with Bukkit join handling where players are denied entry but subsequently login slightly later 2017-03-05 00:59:44 +00:00
Luck b20b03113a Fix groupmanager global group migration on windows systems 2017-03-01 21:26:20 +00:00
Luck ec8273aa9f Change bungeecord leave event priority to wait longer before unloading data 2017-02-26 21:53:03 +00:00
Luck 2862f0dfae Fix creating delimiter patterns 2017-02-26 21:28:40 +00:00
Luck fd4963c74b Fix getUuid and getName API methods returning null for User, Group and Track instances 2017-02-26 20:46:37 +00:00
Luck df99ef4481 misc cleanup 2017-02-26 12:43:35 +00:00
Luck 35d1057673 Refactor sponge commands to use the proxied interfaces (closes #197) 2017-02-26 11:55:59 +00:00
Luck e6a90a18c4 Sort subjects properly 2017-02-26 01:16:54 +00:00
Luck 26afb69a14 Cleanup LuckPermsSubjectData (fixes #194) 2017-02-26 01:00:02 +00:00
Luck e8c0c43e9d misc cleanup 2017-02-24 19:31:45 +00:00
Luck 1707f333bf update javadocs link in readme 2017-02-23 21:59:43 +00:00
893 changed files with 76011 additions and 39524 deletions

No files matched your search

+22 -107
View File
@@ -1,40 +1,12 @@
# Created by https://www.gitignore.io/
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/
*.iws
/out/
*.iml
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
### Eclipse ###
.metadata
bin/
tmp/
@@ -46,73 +18,27 @@ local.properties
.settings/
.loadpath
.recommenders
# Eclipse Core
.project
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# JDT-specific (Eclipse Java Development Tools)
.classpath
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
.apt_generated/
.project
.classpath
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
*.DS_Store
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
@@ -120,45 +46,34 @@ Icon
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/
### Windows ###
# Windows image file caches
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
ehthumbs_vista.db
*.stackdump
[Dd]esktop.ini
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
### Java ###
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Gradle ###
.gradle
/build/
/out/
gradle-app.setting
!gradle-wrapper.jar
.gradletasknamecache
+26
View File
@@ -0,0 +1,26 @@
### :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).
### :bug: Reporting bugs?
Before reporting a bug or issue, please make sure that the issue is actually being caused by or related to LuckPerms. We get a lot of reports which are caused by other software - please double check!
If you're unsure, feel free to ask using the above resources BEFORE making a report.
Bugs or issues should be reported using the [GitHub Issues tab](https://github.com/lucko/LuckPerms/issues).
### :pencil: Want to contribute code?
#### Pull Requests
If you make any changes or improvements to the plugin which you think would be beneficial to others, please consider making a pull request to merge your changes back into the upstream project. (especially if your changes are bug fixes!)
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.
#### Project Layout
The project is split up into a few seperate 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.
+22
View File
@@ -0,0 +1,22 @@
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.
+3 -2
View File
@@ -1,6 +1,7 @@
MIT License
Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
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
@@ -18,4 +19,4 @@ 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.
SOFTWARE.
+32 -26
View File
@@ -1,44 +1,50 @@
![alt text](https://i.imgur.com/7TwJZ5e.png "Banner")
# LuckPerms [![Build Status](https://ci.lucko.me/job/LuckPerms/badge/icon)](https://ci.lucko.me/job/LuckPerms/)
![alt text](https://i.imgur.com/ToguFkQ.png "Banner")
# LuckPerms
[![Build Status](https://ci.lucko.me/job/LuckPerms/badge/icon)](https://ci.lucko.me/job/LuckPerms/)
[![Javadocs](https://javadoc.io/badge/me.lucko.luckperms/luckperms-api.svg)](https://javadoc.io/doc/me.lucko.luckperms/luckperms-api)
[![Maven Central](https://img.shields.io/maven-metadata/v/https/repo1.maven.org/maven2/me/lucko/luckperms/luckperms-api/maven-metadata.xml.svg?label=maven%20central&colorB=brightgreen)](https://search.maven.org/artifact/me.lucko.luckperms/luckperms-api)
[![Discord](https://img.shields.io/discord/241667244927483904.svg?logo=discord&label=)](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 also includes an extensive API for developers, and support for a variety of Minecraft server software & data storage options.
[See the charts below](https://github.com/lucko/LuckPerms#luckperms-vs-other-plugins) for a partial list of features & comparison with other providers.
* [Spigot Plugin Release Page](https://www.spigotmc.org/resources/luckperms-an-advanced-permissions-system.28140/ "Spigot Plugin Page")
* [Sponge Plugin Release Page](https://forums.spongepowered.org/t/luckperms-an-advanced-permissions-system/14274 "Sponge Plugin Page")
Still not convinced? More information can be found on the wiki, under: [Why LuckPerms?](https://github.com/lucko/LuckPerms/wiki/Why-LuckPerms)
## Useful Links
* **Development Builds** - <https://ci.lucko.me/job/LuckPerms>
* **Javadocs** - <https://jd.lucko.me/LuckPerms>
* **Wiki** - <https://github.com/lucko/LuckPerms/wiki>
The latest **downloads** can be found on the [project's homepage](https://luckperms.github.io/).
More information about the project & how to use the plugin can be found in the [wiki](https://github.com/lucko/LuckPerms/wiki).
## Building
LuckPerms uses Maven to handle dependencies.
LuckPerms uses Gradle to handle dependencies & building.
#### Requirements
* Maven 3.3.x (the older versions will not work.)
* Java 8 JDK or newer
* Git
#### Then run
#### Compiling from source
```sh
git clone https://github.com/lucko/LuckPerms.git
mvn clean package
cd LuckPerms/
./gradlew build
```
You can find the output jars in the `build/libs` directories.
## Contributing
#### Pull Requests
If you make any changes or improvements to the plugin which you think would be beneficial to others, please consider making a pull request to merge your changes back into the upstream project. (especially if your changes are bug fixes!)
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.
#### Project Layout
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.
## 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.
## LuckPerms vs Other Plugins
### Bukkit
![alt text](https://static.lucko.me/luckperms-compare-copy.png "Feature comparison")
###### _Features checked on 23rd Aug 2016. If you find any inaccuracies, please let me know._
### Sponge
![alt text](https://static.lucko.me/luckperms-compare-sponge.png "Feature comparison")
###### _Features checked on 8th Oct 2016. If you find any inaccuracies, please let me know._
## Thanks
[![JProfiler](https://www.ej-technologies.com/images/product_banners/jprofiler_large.png)](http://www.ej-technologies.com/products/jprofiler/overview.html)
Thanks to ej-technologies for granting LuckPerms an open source licence to their [Java Profiling Software](http://www.ej-technologies.com/products/jprofiler/overview.html "Java Profiler").
+98
View File
@@ -0,0 +1,98 @@
project.version = '4.4'
dependencies {
compileOnly 'com.google.guava:guava:19.0'
compileOnly 'org.checkerframework:checker-qual:2.5.5'
}
// Only used occasionally for deployment - not needed for normal builds.
/*
if (project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')) {
apply plugin: 'signing'
javadoc {
options.encoding = 'UTF-8'
options.charSet = 'UTF-8'
options.links(
'https://google.github.io/guava/releases/21.0/api/docs/',
'https://docs.oracle.com/javase/8/docs/api/'
)
options.addStringOption('Xdoclint:none', '-quiet')
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar) {
classifier 'sources'
from sourceSets.main.allSource
}
artifacts {
archives javadocJar
archives sourcesJar
}
signing {
useGpgCmd()
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
pom {
project {
name 'LuckPerms API'
description 'An advanced permissions plugin for Bukkit/Spigot, BungeeCord, Sponge, Nukkit and Velocity.'
url 'https://luckperms.github.io'
licenses {
license {
name 'MIT'
url 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
name 'Luck'
email 'git@lucko.me'
url 'https://github.com/lucko'
}
}
scm {
connection 'scm:git:https://github.com/lucko/LuckPerms.git'
developerConnection 'scm:git:git@github.com:lucko/LuckPerms.git'
url 'https://github.com/lucko/LuckPerms'
}
ciManagement {
system 'Jenkins'
url 'https://ci.lucko.me/job/LuckPerms'
}
issueManagement {
system 'GitHub'
url 'https://github.com/lucko/LuckPerms/issues'
}
}
}
}
}
}
}
*/
-37
View File
@@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>luckperms</artifactId>
<groupId>me.lucko.luckperms</groupId>
<version>3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>luckperms-api</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -24,48 +27,62 @@ package me.lucko.luckperms;
import me.lucko.luckperms.api.LuckPermsApi;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Optional;
/**
* Singleton for the {@link LuckPermsApi}.
* Provides static access to the {@link LuckPermsApi}.
*
* <p> Ideally, the ServiceManager for the platform should be used to obtain and cache an instance, however, this can be
* used if you need static access.
* <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>
*/
public final class LuckPerms {
private static LuckPermsApi api = null;
private static LuckPermsApi instance = null;
/**
* Gets an instance of {@link LuckPermsApi}, throwing {@link IllegalStateException} if the API is not loaded.
* Gets an instance of the {@link LuckPermsApi},
* throwing {@link IllegalStateException} if an instance is not yet loaded.
*
* <p>Will never return null.</p>
*
* @return an api instance
* @throws IllegalStateException if the api is not loaded
*/
public static LuckPermsApi getApi() {
if (api == null) {
public static @NonNull LuckPermsApi getApi() {
if (instance == null) {
throw new IllegalStateException("API is not loaded.");
}
return api;
return instance;
}
/**
* Gets an instance of {@link LuckPermsApi} safely.
* Gets an instance of {@link LuckPermsApi}, if it is loaded.
*
* <p> Unlike {@link LuckPerms#getApi}, this method will not throw an {@link IllegalStateException} if the API is
* not loaded, rather return an empty {@link Optional}.
* <p>Unlike {@link LuckPerms#getApi}, this method will not throw an
* {@link IllegalStateException} if an instance is not yet loaded, rather return
* an empty {@link Optional}.
*
* @return an optional api instance
*/
public static Optional<LuckPermsApi> getApiSafe() {
return Optional.ofNullable(api);
public static @NonNull Optional<LuckPermsApi> getApiSafe() {
return Optional.ofNullable(instance);
}
static void registerProvider(LuckPermsApi luckPermsApi) {
api = luckPermsApi;
/**
* Registers an instance of the {@link LuckPermsApi} with this provider.
*
* @param instance the instance
*/
static void registerProvider(LuckPermsApi instance) {
LuckPerms.instance = instance;
}
/**
* Removes the current instance from this provider.
*/
static void unregisterProvider() {
api = null;
LuckPerms.instance = null;
}
private LuckPerms() {
@@ -0,0 +1,93 @@
/*
* 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 me.lucko.luckperms.api;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.concurrent.CompletableFuture;
/**
* Represents the object responsible for handling action logging.
*
* @since 4.1
*/
public interface ActionLogger {
/**
* Returns a new {@link LogEntry.Builder} instance
*
* @return a new builder
*/
LogEntry.@NonNull Builder newEntryBuilder();
/**
* Gets a {@link Log} instance from the plugin storage.
*
* @return a log instance
* @see Storage#getLog()
*/
@NonNull CompletableFuture<Log> getLog();
/**
* Submits a log entry to the plugin to be handled.
*
* <p>This method submits the log to the storage provider and broadcasts
* it.</p>
*
* <p>It is therefore roughly equivalent to calling
* {@link #submitToStorage(LogEntry)} and {@link #broadcastAction(LogEntry)},
* however, using this method is preferred to making the calls individually.</p>
*
* <p>If you want to submit a log entry but don't know which method to pick,
* use this one.</p>
*
* @param entry the entry to submit
* @return a future which will complete when the action is done
*/
@NonNull CompletableFuture<Void> submit(@NonNull LogEntry entry);
/**
* Submits a log entry to the plugins storage handler.
*
* <p>Performs the same action as {@link Storage#logAction(LogEntry)}.</p>
*
* @param entry the entry to submit
* @return a future which will complete when the action is done
*/
@NonNull CompletableFuture<Void> submitToStorage(@NonNull LogEntry entry);
/**
* Submits a log entry to the plugins log broadcasting handler.
*
* <p>If enabled, this method will also dispatch the log entry via the
* plugins {@link MessagingService}.</p>
*
* @param entry the entry to submit
* @return a future which will complete when the action is done
*/
@NonNull CompletableFuture<Void> broadcastAction(@NonNull LogEntry entry);
}
@@ -0,0 +1,126 @@
/*
* 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 me.lucko.luckperms.api;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
/**
* Represents a type of chat meta
*
* @since 3.2
*/
public enum ChatMetaType {
/**
* Represents a prefix
*/
PREFIX("prefix") {
@Override
public boolean matches(@NonNull Node node) {
return Objects.requireNonNull(node, "node").isPrefix();
}
@Override
public Map.@NonNull Entry<Integer, String> getEntry(@NonNull Node node) {
return Objects.requireNonNull(node, "node").getPrefix();
}
},
/**
* Represents a suffix
*/
SUFFIX("suffix") {
@Override
public boolean matches(@NonNull Node node) {
return Objects.requireNonNull(node, "node").isSuffix();
}
@Override
public Map.@NonNull Entry<Integer, String> getEntry(@NonNull Node node) {
return Objects.requireNonNull(node, "node").getSuffix();
}
};
private final String str;
ChatMetaType(String str) {
this.str = str;
}
/**
* Returns if the passed node matches the type
*
* @param node the node to test
* @return true if the node has the same type
*/
public abstract boolean matches(@NonNull Node node);
/**
* Returns if the passed node should be ignored when searching for meta of this type
*
* @param node the node to test
* @return true if the node does not share the same type
*/
public boolean shouldIgnore(@NonNull Node node) {
return !matches(node);
}
/**
* Maps the corresponding entry from the given node
*
* @param node the node to retrieve the entry from
* @return the entry
* @throws IllegalStateException if the node does not share the same type
*/
public abstract Map.@NonNull Entry<Integer, String> getEntry(@NonNull Node node);
@Override
public String toString() {
return this.str;
}
/**
* Parses a ChatMetaType from the given node.
*
* @param node the node
* @return the parsed chat meta type
* @since 3.4
*/
public static @NonNull Optional<ChatMetaType> ofNode(@NonNull Node node) {
if (node.isPrefix()) {
return Optional.of(PREFIX);
} else if (node.isSuffix()) {
return Optional.of(SUFFIX);
} else {
return Optional.empty();
}
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -23,205 +26,332 @@
package me.lucko.luckperms.api;
import me.lucko.luckperms.api.context.ContextSet;
import me.lucko.luckperms.api.context.ImmutableContextSet;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Objects;
import java.util.Set;
/**
* Context and options for a permission lookup.
* Encapsulates the {@link ContextSet contexts} and {@link LookupSetting settings} for
* a permission or meta lookup.
*
* <p> All values are immutable.
* <p>This class is immutable.</p>
*
* @since 2.11
*/
public class Contexts {
public static final String SERVER_KEY = "server";
public static final String WORLD_KEY = "world";
private static final Contexts ALLOW_ALL = new Contexts(ContextSet.empty(), true, true, true, true, true, true);
/**
* Gets a context that will allow all nodes
*
* @return a context that will not apply any filters
* The context key used to denote the subjects server
*/
public static Contexts allowAll() {
return ALLOW_ALL;
public static final String SERVER_KEY = "server";
/**
* The context key used to denote the subjects world
*/
public static final String WORLD_KEY = "world";
/**
* The default {@link LookupSetting}s as a flag.
*/
private static final byte DEFAULT_SETTINGS_FLAG = LookupSetting.createFlag(
LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER,
LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD,
LookupSetting.RESOLVE_INHERITANCE,
LookupSetting.APPLY_PARENTS_SET_WITHOUT_SERVER,
LookupSetting.APPLY_PARENTS_SET_WITHOUT_WORLD
);
/**
* A 'global' or default contexts instance.
*
* <p>Formed of an empty {@link ContextSet} and all inclusion and
* inheritance {@link LookupSetting}s applied.</p>
*/
private static final Contexts GLOBAL = new Contexts(ImmutableContextSet.empty(), DEFAULT_SETTINGS_FLAG);
/**
* Gets the {@link FullySatisfiedContexts} instance.
*
* @return a context that will satisfy all contextual requirements.
*/
public static @NonNull Contexts allowAll() {
return FullySatisfiedContexts.getInstance();
}
public static Contexts of(ContextSet context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups, boolean op) {
return new Contexts(context, includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups, op);
/**
* Returns a 'global' or default contexts instance.
*
* <p>Formed of an empty {@link ContextSet} and all inclusion and
* inheritance {@link LookupSetting}s applied.</p>
*
* @return the global contexts
* @since 3.3
*/
public static @NonNull Contexts global() {
return GLOBAL;
}
/**
* Creates a new {@link Contexts} instance.
*
* @param contextSet the context set
* @param includeNodesSetWithoutServer the value of {@link LookupSetting#INCLUDE_NODES_SET_WITHOUT_SERVER}
* @param includeNodesSetWithoutWorld the value of {@link LookupSetting#INCLUDE_NODES_SET_WITHOUT_WORLD}
* @param resolveInheritance the value of {@link LookupSetting#RESOLVE_INHERITANCE}
* @param applyParentsWithoutServer the value of {@link LookupSetting#APPLY_PARENTS_SET_WITHOUT_SERVER}
* @param applyParentsWithoutWorld the value of {@link LookupSetting#APPLY_PARENTS_SET_WITHOUT_WORLD}
* @param isOp the value of {@link LookupSetting#IS_OP}
* @return a new instance
*/
public static @NonNull Contexts of(@NonNull ContextSet contextSet, boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) {
Objects.requireNonNull(contextSet, "contextSet");
byte settingsFlag = LookupSetting.createFlag(
includeNodesSetWithoutServer,
includeNodesSetWithoutWorld,
resolveInheritance,
applyParentsWithoutServer,
applyParentsWithoutWorld,
isOp
);
if (contextSet.isEmpty() && DEFAULT_SETTINGS_FLAG == settingsFlag) {
return GLOBAL;
}
return new Contexts(contextSet.makeImmutable(), settingsFlag);
}
/**
* Creates a new {@link Contexts} instance.
*
* @param contextSet the context set
* @param settings the settings
* @return a new instance
*/
public static Contexts of(@NonNull ContextSet contextSet, @NonNull Set<LookupSetting> settings) {
Objects.requireNonNull(contextSet, "contextSet");
Objects.requireNonNull(settings, "settings");
byte settingsFlag = LookupSetting.createFlag(settings);
if (contextSet.isEmpty() && DEFAULT_SETTINGS_FLAG == settingsFlag) {
return GLOBAL;
}
return new Contexts(contextSet.makeImmutable(), settingsFlag);
}
/**
* The contexts that apply for this lookup
* The keys for servers and worlds are defined as static values.
*/
private final ContextSet context;
private final ImmutableContextSet contextSet;
/**
* The mode to parse defaults on Bukkit
* The settings for this lookup
*/
private final byte settingsFlag;
// cache hashcode - this class is immutable, and is used as an index in the permission cache.
private final int hashCode;
/**
* Creates a new {@link Contexts} instance.
*
* @since 2.12
* @param contextSet the context set
* @param includeNodesSetWithoutServer the value of {@link LookupSetting#INCLUDE_NODES_SET_WITHOUT_SERVER}
* @param includeNodesSetWithoutWorld the value of {@link LookupSetting#INCLUDE_NODES_SET_WITHOUT_WORLD}
* @param resolveInheritance the value of {@link LookupSetting#RESOLVE_INHERITANCE}
* @param applyParentsWithoutServer the value of {@link LookupSetting#APPLY_PARENTS_SET_WITHOUT_SERVER}
* @param applyParentsWithoutWorld the value of {@link LookupSetting#APPLY_PARENTS_SET_WITHOUT_WORLD}
* @param isOp the value of {@link LookupSetting#IS_OP}
* @deprecated in favour of {@link #of(ContextSet, boolean, boolean, boolean, boolean, boolean, boolean)}
*/
private final boolean op;
@Deprecated
public Contexts(@NonNull ContextSet contextSet, boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) {
this.contextSet = Objects.requireNonNull(contextSet, "contextSet").makeImmutable();
this.settingsFlag = LookupSetting.createFlag(
includeNodesSetWithoutServer,
includeNodesSetWithoutWorld,
resolveInheritance,
applyParentsWithoutServer,
applyParentsWithoutWorld,
isOp
);
this.hashCode = calculateHashCode();
}
/**
* If global or non server specific nodes should be applied
*/
private final boolean includeGlobal;
/**
* If global or non world specific nodes should be applied
*/
private final boolean includeGlobalWorld;
/**
* If parent groups should be applied
*/
private final boolean applyGroups;
/**
* If global or non server specific group memberships should be applied
*/
private final boolean applyGlobalGroups;
/**
* If global or non world specific group memberships should be applied
*/
private final boolean applyGlobalWorldGroups;
public Contexts(ContextSet context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups, boolean op) {
if (context == null) {
throw new NullPointerException("context");
}
this.context = context.makeImmutable();
this.includeGlobal = includeGlobal;
this.includeGlobalWorld = includeGlobalWorld;
this.applyGroups = applyGroups;
this.applyGlobalGroups = applyGlobalGroups;
this.applyGlobalWorldGroups = applyGlobalWorldGroups;
this.op = op;
protected Contexts(@NonNull ImmutableContextSet contextSet, byte settingsFlag) {
this.contextSet = contextSet;
this.settingsFlag = settingsFlag;
this.hashCode = calculateHashCode();
}
/**
* Gets the contexts that apply for this lookup
* Gets the {@link ContextSet set of context pairs} for this {@link Contexts} instance.
*
* @return an immutable set of context key value pairs
* @return an immutable context from this instance
* @since 2.13
*/
public ContextSet getContexts() {
return this.context;
public @NonNull ContextSet getContexts() {
return this.contextSet;
}
/**
* Gets if OP defaults should be included
* Gets the set of {@link LookupSetting}s for this {@link Contexts} instance.
*
* @return true if op defaults should be included
* @return the settings
* @since 4.2
*/
public @NonNull Set<LookupSetting> getSettings() {
return LookupSetting.createSetFromFlag(this.settingsFlag);
}
/**
* Creates a copy of this {@link Contexts} instance, but with the
* {@link ContextSet set of context pairs} replaced by the given set.
*
* @param contextSet the context set
* @return a new contexts instance representing the new settings
* @since 4.4
*/
public @NonNull Contexts setContexts(@NonNull ContextSet contextSet) {
ImmutableContextSet cs = Objects.requireNonNull(contextSet, "contextSet").makeImmutable();
if (this.contextSet.equals(cs)) {
return this;
}
return new Contexts(cs, this.settingsFlag);
}
/**
* Creates a copy of this {@link Contexts} instance, but with the
* {@link LookupSetting}s replaced by the given settings.
*
* @param settings the lookup settings
* @return a new contexts instance representing the new settings
* @since 4.4
*/
public @NonNull Contexts setSettings(@NonNull Set<LookupSetting> settings) {
Objects.requireNonNull(settings, "settings");
byte settingsFlag = LookupSetting.createFlag(settings);
if (this.settingsFlag == settingsFlag) {
return this;
}
if (DEFAULT_SETTINGS_FLAG == settingsFlag && this.contextSet.isEmpty()) {
return GLOBAL;
}
return new Contexts(this.contextSet, settingsFlag);
}
/**
* Gets if the given {@link LookupSetting} is set.
*
* @param setting the setting
* @return the value
* @since 4.2
*/
public boolean hasSetting(@NonNull LookupSetting setting) {
return LookupSetting.isSet(this.settingsFlag, setting);
}
/**
* Gets the value of {@link LookupSetting#IS_OP}.
*
* @return the value
* @see LookupSetting#IS_OP
* @deprecated in favour of {@link #hasSetting(LookupSetting)}
*/
@Deprecated
public boolean isOp() {
return this.op;
return hasSetting(LookupSetting.IS_OP);
}
/**
* Gets if global or non server specific nodes should be applied
* Gets the value of {@link LookupSetting#INCLUDE_NODES_SET_WITHOUT_SERVER}.
*
* @return true if global or non server specific nodes should be applied
* @return the value
* @see LookupSetting#INCLUDE_NODES_SET_WITHOUT_SERVER
* @deprecated in favour of {@link #hasSetting(LookupSetting)}
*/
@Deprecated
public boolean isIncludeGlobal() {
return this.includeGlobal;
return hasSetting(LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER);
}
/**
* Gets if global or non world specific nodes should be applied
* Gets the value of {@link LookupSetting#INCLUDE_NODES_SET_WITHOUT_WORLD}.
*
* @return true if global or non world specific nodes should be applied
* @return the value
* @see LookupSetting#INCLUDE_NODES_SET_WITHOUT_WORLD
* @deprecated in favour of {@link #hasSetting(LookupSetting)}
*/
@Deprecated
public boolean isIncludeGlobalWorld() {
return this.includeGlobalWorld;
return hasSetting(LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD);
}
/**
* Gets if parent groups should be applied
* Gets the value of {@link LookupSetting#RESOLVE_INHERITANCE}.
*
* @return true if parent groups should be applied
* @return the value
* @see LookupSetting#RESOLVE_INHERITANCE
* @deprecated in favour of {@link #hasSetting(LookupSetting)}
*/
@Deprecated
public boolean isApplyGroups() {
return this.applyGroups;
return hasSetting(LookupSetting.RESOLVE_INHERITANCE);
}
/**
* Gets if global or non server specific group memberships should be applied
* Gets the value of {@link LookupSetting#APPLY_PARENTS_SET_WITHOUT_SERVER}.
*
* @return true if global or non server specific group memberships should be applied
* @return the value
* @see LookupSetting#APPLY_PARENTS_SET_WITHOUT_SERVER
* @deprecated in favour of {@link #hasSetting(LookupSetting)}
*/
@Deprecated
public boolean isApplyGlobalGroups() {
return this.applyGlobalGroups;
return hasSetting(LookupSetting.APPLY_PARENTS_SET_WITHOUT_SERVER);
}
/**
* Gets if global or non world specific group memberships should be applied
* Gets the value of {@link LookupSetting#APPLY_PARENTS_SET_WITHOUT_WORLD}.
*
* @return true if global or non world specific group memberships should be applied
* @return the value
* @see LookupSetting#APPLY_PARENTS_SET_WITHOUT_WORLD
* @deprecated in favour of {@link #hasSetting(LookupSetting)}
*/
@Deprecated
public boolean isApplyGlobalWorldGroups() {
return this.applyGlobalWorldGroups;
return hasSetting(LookupSetting.APPLY_PARENTS_SET_WITHOUT_WORLD);
}
public String toString() {
return "Contexts(" +
"context=" + this.getContexts() + ", " +
"op=" + this.isOp() + ", " +
"includeGlobal=" + this.isIncludeGlobal() + ", " +
"includeGlobalWorld=" + this.isIncludeGlobalWorld() + ", " +
"applyGroups=" + this.isApplyGroups() + ", " +
"applyGlobalGroups=" + this.isApplyGlobalGroups() + ", " +
"applyGlobalWorldGroups=" + this.isApplyGlobalWorldGroups() +
")";
@Override
public @NonNull String toString() {
return "Contexts(contextSet=" + this.contextSet + ", settings=" + LookupSetting.createSetFromFlag(this.settingsFlag) + ")";
}
/*
* Ugly auto-generated lombok code
*/
/**
* Check for equality
*
* @param o the other
* @return true if equal
* @since 2.12
*/
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (o == allowAll()) return false;
if (!(o instanceof Contexts)) return false;
final Contexts other = (Contexts) o;
final Object this$context = this.getContexts();
final Object other$context = other.getContexts();
if (this$context == null ? other$context != null : !this$context.equals(other$context)) return false;
if (this.isOp() != other.isOp()) return false;
if (this.isIncludeGlobal() != other.isIncludeGlobal()) return false;
if (this.isIncludeGlobalWorld() != other.isIncludeGlobalWorld()) return false;
if (this.isApplyGroups() != other.isApplyGroups()) return false;
if (this.isApplyGlobalGroups() != other.isApplyGlobalGroups()) return false;
if (this.isApplyGlobalWorldGroups() != other.isApplyGlobalWorldGroups()) return false;
return true;
final Contexts that = (Contexts) o;
return this.contextSet.equals(that.contextSet) && this.settingsFlag == that.settingsFlag;
}
/**
* Gets the hashcode
*
* @return the hashcode
* @since 2.12
*/
public int hashCode() {
private int calculateHashCode() {
final int PRIME = 59;
int result = 1;
final Object $context = this.getContexts();
result = result * PRIME + ($context == null ? 43 : $context.hashCode());
result = result * PRIME + (this.isOp() ? 79 : 97);
result = result * PRIME + (this.isIncludeGlobal() ? 79 : 97);
result = result * PRIME + (this.isIncludeGlobalWorld() ? 79 : 97);
result = result * PRIME + (this.isApplyGroups() ? 79 : 97);
result = result * PRIME + (this.isApplyGlobalGroups() ? 79 : 97);
result = result * PRIME + (this.isApplyGlobalWorldGroups() ? 79 : 97);
result = result * PRIME + this.contextSet.hashCode();
result = result * PRIME + this.settingsFlag;
return result;
}
@Override
public int hashCode() {
return this.hashCode;
}
}
@@ -0,0 +1,65 @@
/*
* 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 me.lucko.luckperms.api;
/**
* Represents the result of a data mutation call on a LuckPerms object.
*
* <p>Usually as the result to a call on a {@link PermissionHolder} or {@link Track}.</p>
*/
public enum DataMutateResult implements MutateResult {
/**
* Indicates the mutation was a success
*/
SUCCESS(true),
/**
* Indicates the mutation failed because the subject of the action already has something
*/
ALREADY_HAS(false),
/**
* Indicates the mutation failed because the subject of the action lacks something
*/
LACKS(false),
/**
* Indicates the mutation failed
*/
FAIL(false);
private final boolean success;
DataMutateResult(boolean success) {
this.success = success;
}
@Override
public boolean wasSuccess() {
return this.success;
}
}
@@ -0,0 +1,127 @@
/*
* 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 me.lucko.luckperms.api;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Optional;
/**
* Encapsulates the result of {@link User}s demotion along a {@link Track}.
*
* @since 4.2
*/
public interface DemotionResult extends MutateResult {
/**
* Gets the status of the result.
*
* @return the status
*/
@NonNull Status getStatus();
@Override
default boolean wasSuccess() {
return getStatus().wasSuccess();
}
/**
* Gets the name of the group the user was demoted from, if applicable.
*
* <p>Will only be present for results with a {@link #getStatus() status} of
* {@link Status#SUCCESS} or {@link Status#REMOVED_FROM_FIRST_GROUP}.</p>
*
* <p>The value will also be set for results with the {@link Status#MALFORMED_TRACK} status,
* with this value marking the group which no longer exists.</p>
*
* @return the group the user was demoted from.
*/
@NonNull Optional<String> getGroupFrom();
/**
* Gets the name of the group the user was demoted from, if applicable.
*
* <p>Will only be present for results with a {@link #getStatus() status} of
* {@link Status#SUCCESS}.</p>
*
* @return the group the user was demoted to.
*/
@NonNull Optional<String> getGroupTo();
/**
* The result status
*/
enum Status implements MutateResult {
/**
* Indicates that the user was demoted normally.
*/
SUCCESS(true),
/**
* Indicates that the user was removed from the first group in the track.
*
* <p>This usually occurs when the user is currently on the first group, and was demoted
* "over the start" of the track.</p>
*/
REMOVED_FROM_FIRST_GROUP(true),
/**
* Indicates that the previous group in the track no longer exists.
*/
MALFORMED_TRACK(false),
/**
* Indicates that the user isn't a member of any of the groups on this track.
*/
NOT_ON_TRACK(false),
/**
* Indicates that the implementation was unable to determine the users current position on
* this track.
*
* <p>This usually occurs when the user is on more than one group on the track.</p>
*/
AMBIGUOUS_CALL(false),
/**
* An undefined failure occurred.
*/
UNDEFINED_FAILURE(false);
private final boolean success;
Status(boolean success) {
this.success = success;
}
@Override
public boolean wasSuccess() {
return this.success;
}
}
}
@@ -0,0 +1,84 @@
/*
* 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 me.lucko.luckperms.api;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.UUID;
/**
* Represents an entity on the server.
*
* <p>This does not relate directly to a "Minecraft Entity". The closest
* comparison is to a "CommandSender" or "CommandSource" in Bukkit/Sponge.</p>
*
* <p>The various types of {@link Entity} are detailed in {@link Type}.</p>
*
* @since 4.1
*/
public interface Entity {
/**
* Gets the unique id of the entity, if it has one.
*
* <p>For players, this returns their uuid assigned by the server.</p>
*
* @return the uuid of the object, if available
*/
@Nullable UUID getUniqueId();
/**
* Gets the name of the object
*
* @return the object name
*/
@NonNull String getName();
/**
* Gets the entities type.
*
* @return the type
*/
@NonNull Type getType();
/**
* The different types of {@link Entity}
*/
enum Type {
/**
* Represents a player connected to the server
*/
PLAYER,
/**
* Represents the server console
*/
CONSOLE
}
}
@@ -0,0 +1,79 @@
/*
* 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 me.lucko.luckperms.api;
import me.lucko.luckperms.api.caching.CachedData;
import me.lucko.luckperms.api.caching.MetaContexts;
import me.lucko.luckperms.api.context.ImmutableContextSet;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* A special instance of {@link Contexts}, which when passed to:
*
* <p></p>
* <ul>
* <li>{@link CachedData#getPermissionData(Contexts)}</li>
* <li>{@link CachedData#getMetaData(Contexts)}</li>
* <li>{@link CachedData#getMetaData(MetaContexts)}</li>
* </ul>
*
* <p>... will always satisfy all contextual requirements.</p>
*
* <p>This effectively allows you to do lookups which ignore context.</p>
*
* @since 3.3
*/
public final class FullySatisfiedContexts extends Contexts {
// singleton
private static final FullySatisfiedContexts INSTANCE = new FullySatisfiedContexts();
public static @NonNull Contexts getInstance() {
return INSTANCE;
}
private FullySatisfiedContexts() {
super(ImmutableContextSet.empty(), LookupSetting.createFlag(Contexts.global().getSettings()));
}
@Override
public @NonNull String toString() {
return "FullySatisfiedContexts()";
}
@Override
public boolean equals(Object o) {
// this class is a singleton, so we can use object comparison to check equality.
return o == this;
}
@Override
public int hashCode() {
// just use the system hashcode - we need to override the hashcode impl in super
return System.identityHashCode(this);
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,14 +25,16 @@
package me.lucko.luckperms.api;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException;
import me.lucko.luckperms.api.caching.GroupData;
import me.lucko.luckperms.api.context.ContextSet;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.List;
import java.util.OptionalInt;
/**
* A group which holds permission data.
* An inheritable holder of permission data.
*/
public interface Group extends PermissionHolder {
@@ -38,225 +43,48 @@ public interface Group extends PermissionHolder {
*
* @return the name of the group
*/
String getName();
@NonNull String getName();
/**
* Check to see if a group inherits a group
* Gets the groups "display name", if it has one that differs from it's actual name.
*
* @param group The group to check membership of
* @return true if the group inherits the other group
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
boolean inheritsGroup(Group group);
/**
* Check to see if the group inherits a group on a specific server
* <p>The lookup is made using the current servers active context.</p>
*
* @param group The group to check membership of
* @param server The server to check on
* @return true if the group inherits the group on the server
* @throws NullPointerException if the group or server is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the server is invalid
*/
boolean inheritsGroup(Group group, String server);
/**
* Check to see if the group inherits a group on a specific server and world
* <p>Will return <code>null</code> if the groups display name is equal to it's
* {@link #getName() actual name}.</p>
*
* @param group The group to check membership of
* @param server The server to check on
* @param world The world to check on
* @return true if the group inherits the group on the server and world
* @throws NullPointerException if the group, server or world is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the server or world is invalid
* @return the display name
* @since 4.3
*/
boolean inheritsGroup(Group group, String server, String world);
@Nullable String getDisplayName();
/**
* Make this group inherit another group
* Gets the groups "display name", if it has one that differs from it's actual name.
*
* @param group the group to be inherited
* @throws ObjectAlreadyHasException if the group already inherits the group
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
void setInheritGroup(Group group) throws ObjectAlreadyHasException;
/**
* Make this group inherit another group on a specific server
* <p>Will return <code>null</code> if the groups display name is equal to it's
* {@link #getName() actual name}.</p>
*
* @param group the group to be inherited
* @param server The server to inherit the group on
* @throws ObjectAlreadyHasException if the group already inherits the group on that server
* @throws NullPointerException if the group or server is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the server is invalid
* @param contextSet the contexts to lookup in
* @return the display name
* @since 4.3
*/
void setInheritGroup(Group group, String server) throws ObjectAlreadyHasException;
@Nullable String getDisplayName(@NonNull ContextSet contextSet);
/**
* Make this group inherit another group on a specific server and world
*
* @param group the group to be inherited
* @param server The server to inherit the group on
* @param world The world to inherit the group on
* @throws ObjectAlreadyHasException if the group already inherits the group on that server and world
* @throws NullPointerException if the group, server or world is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the server or world is invalid
*/
void setInheritGroup(Group group, String server, String world) throws ObjectAlreadyHasException;
/**
* Make this group inherit another group temporarily
*
* @param group the group to be inherited
* @param expireAt the unix time when the group should expire
* @throws ObjectAlreadyHasException if the group already inherits the group temporarily
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the expiry time is in the past
*/
void setInheritGroup(Group group, long expireAt) throws ObjectAlreadyHasException;
/**
* Make this group inherit another group on a specific server temporarily
*
* @param group the group to be inherited
* @param server The server inherit add the group on
* @param expireAt when the group should expire
* @throws ObjectAlreadyHasException if the group already inherits the group on that server temporarily
* @throws NullPointerException if the group or server is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the expiry time is in the past or the server is invalid
*/
void setInheritGroup(Group group, String server, long expireAt) throws ObjectAlreadyHasException;
/**
* Make this group inherit another group on a specific server and world temporarily
*
* @param group the group to be inherited
* @param server The server to inherit the group on
* @param world The world to inherit the group on
* @param expireAt when the group should expire
* @throws ObjectAlreadyHasException if the group already inherits the group on that server and world temporarily
* @throws NullPointerException if the group, server or world is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the expiry time is in the past or the server/world is invalid
*/
void setInheritGroup(Group group, String server, String world, long expireAt) throws ObjectAlreadyHasException;
/**
* Remove a previously set inheritance rule
*
* @param group the group to uninherit
* @throws ObjectLacksException if the group does not already inherit the group
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
void unsetInheritGroup(Group group) throws ObjectLacksException;
/**
* Remove a previously set inheritance rule
*
* @param group the group to uninherit
* @param temporary if the group being removed is temporary
* @throws ObjectLacksException if the group does not already inherit the group
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
void unsetInheritGroup(Group group, boolean temporary) throws ObjectLacksException;
/**
* Remove a previously set inheritance rule on a specific server
*
* @param group the group to uninherit
* @param server The server to remove the group on
* @throws ObjectLacksException if the group does not already inherit the group on that server
* @throws NullPointerException if the group or server is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the server is invalid
*/
void unsetInheritGroup(Group group, String server) throws ObjectLacksException;
/**
* Remove a previously set inheritance rule on a specific server and world
*
* @param group the group to uninherit
* @param server The server to remove the group on
* @param world The world to remove the group on
* @throws ObjectLacksException if the group does not already inherit the group
* @throws NullPointerException if the group, server or world is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the server or world is invalid
*/
void unsetInheritGroup(Group group, String server, String world) throws ObjectLacksException;
/**
* Remove a previously set inheritance rule on a specific server
*
* @param group the group to uninherit
* @param server The server to remove the group on
* @param temporary if the group being removed is temporary
* @throws ObjectLacksException if the group does not already inherit the group
* @throws NullPointerException if the group or server is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the expiry time is in the past or the server is invalid
*/
void unsetInheritGroup(Group group, String server, boolean temporary) throws ObjectLacksException;
/**
* Remove a previously set inheritance rule on a specific server and world
*
* @param group the group to uninherit
* @param server The server to remove the group on
* @param world The world to remove the group on
* @param temporary if the group being removed was set temporarily
* @throws ObjectLacksException if the group does not already inherit the group
* @throws NullPointerException if the group, server or world is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the expiry time is in the past or the server/world is invalid
*/
void unsetInheritGroup(Group group, String server, String world, boolean temporary) throws ObjectLacksException;
/**
* Get a {@link List} of all of the groups the group inherits, on all servers
*
* @return a {@link List} of group names
*/
List<String> getGroupNames();
/**
* Get a {@link List} of the groups the group inherits on a specific server
*
* @param server the server to check
* @return a {@link List} of group names
* @throws NullPointerException if the server is null
* @throws IllegalArgumentException if the server is invalid
*/
List<String> getLocalGroups(String server);
/**
* Get a {@link List} of the groups the group inherits on a specific server and world
*
* @param server the server to check
* @param world the world to check
* @return a {@link List} of group names
* @throws NullPointerException if the server or world is null
* @throws IllegalArgumentException if the server or world is invalid
*/
List<String> getLocalGroups(String server, String world);
/**
* Gets the weight of this group, is present.
* Gets the weight of this group, if present.
*
* @return the group weight
* @since 2.17
*/
OptionalInt getWeight();
@NonNull OptionalInt getWeight();
/**
* Gets the groups's {@link GroupData} cache.
*
* @return the groups cached data.
* @since 4.0
*/
@Override
@NonNull GroupData getCachedData();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,13 +25,15 @@
package me.lucko.luckperms.api;
import com.google.common.collect.Multimap;
import me.lucko.luckperms.api.context.ContextSet;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Optional;
import java.util.OptionalLong;
/**
* A relationship between a Holder and a permission
* A relationship between a {@link PermissionHolder} and a permission.
*
* @param <T> the identifier type of the holder
* @since 2.17
@@ -40,14 +45,14 @@ public interface HeldPermission<T> {
*
* @return the holder
*/
T getHolder();
@NonNull T getHolder();
/**
* Gets the permission being held
*
* @return the permission
*/
String getPermission();
@NonNull String getPermission();
/**
* Gets the value of the permission
@@ -61,34 +66,34 @@ public interface HeldPermission<T> {
*
* @return the server
*/
Optional<String> getServer();
@NonNull Optional<String> getServer();
/**
* Gets the world where the permission is held
*
* @return the world
*/
Optional<String> getWorld();
@NonNull Optional<String> getWorld();
/**
* Gets the time in unix time when the permission will expire
*
* @return the expiry time
*/
OptionalLong getExpiry();
@NonNull OptionalLong getExpiry();
/**
* Gets the context for the permission.
* Gets the extra context for the permission.
*
* @return the context
* @return the extra context
*/
Multimap<String, String> getContext();
@NonNull ContextSet getContexts();
/**
* Converts this permission into a Node
*
* @return a Node copy of this permission
*/
Node asNode();
@NonNull Node asNode();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,145 +25,93 @@
package me.lucko.luckperms.api;
import me.lucko.luckperms.api.data.DatastoreConfiguration;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Map;
/**
* Read-only access to the LuckPerms configuration settings
* Wrapper around parts of the LuckPerms configuration file
*/
public interface LPConfiguration {
/**
* Returns the name of this server
* Gets the name of this server
*
* @return the name of this server
*/
String getServer();
@NonNull String getServer();
/**
* Returns how often a sync task will run in minutes
* @return how often a sync task will run in minutes
*/
int getSyncTime();
/**
* Returns if the users on this server will have their global permissions applied
* Gets if the users on this server will have their global permissions applied
*
* @return if the users on this server will have their global permissions applied
*/
boolean getIncludeGlobalPerms();
/**
* Returns if the users on this server will have their global world permissions applied
* Gets if the users on this server will have their global world permissions applied
*
* @return if the users on this server will have their global world permissions applied
* @since 2.9
*/
boolean getIncludeGlobalWorldPerms();
/**
* Returns true if the platform is applying global groups
* Gets if the platform is applying global groups
*
* @return true if the platform is applying global groups
* @since 2.9
*/
boolean getApplyGlobalGroups();
/**
* Returns true if the platform is applying global world groups
* Gets if the platform is applying global world groups
*
* @return true if the platform is applying global world groups
* @since 2.9
*/
boolean getApplyGlobalWorldGroups();
/**
* Returns the online mode setting
* @return the online mode setting
*/
boolean getOnlineMode();
/**
* Returns if LuckPerms is applying wildcard permissions
* @return if LuckPerms is applying wildcard permissions
*/
boolean getApplyWildcards();
/**
* Returns if LuckPerms is resolving and applying regex permissions
* @return if LuckPerms is resolving and applying regex permissions
*/
boolean getApplyRegex();
/**
* Returns if LuckPerms is expanding shorthand permissions
* @return if LuckPerms is expanding shorthand permissions
*/
boolean getApplyShorthand();
/**
* Returns if LuckPerms will send notifications to users when permissions are modified
* @return if LuckPerms will send notifications to users when permissions are modified
* @since 2.7
*/
boolean getLogNotify();
/**
* Returns true if the vanilla op system is enabled
* @return true if the vanilla op system is enabled
* @since 2.8
*/
boolean getEnableOps();
/**
* Returns true if opped players are allowed to use LuckPerms commands
* @return true if opped players are allowed to use LuckPerms commands
* @since 2.8
*/
boolean getCommandsAllowOp();
/**
* Returns true if auto op is enabled
* @return true if auto op is enabled
* @since 2.9
*/
boolean getAutoOp();
/**
* Returns the name of the server used within Vault operations
* @return the name of the server used within Vault operations
* @since 2.7
*/
String getVaultServer();
/**
* Returns true if global permissions should be considered when retrieving meta or player groups
* @return true if global permissions should be considered when retrieving meta or player groups
* @since 2.7
*/
boolean getVaultIncludeGlobal();
/**
* Returns the values set for data storage in the configuration
* @return the values set for data storage in the configuration
*/
DatastoreConfiguration getDatastoreConfig();
/**
* Returns the storage method string from the configuration
* Gets the storage method string from the configuration
*
* @return the storage method string from the configuration
*/
String getStorageMethod();
@NonNull String getStorageMethod();
/**
* Returns true if split storage is enabled
* Gets true if split storage is enabled
*
* @return true if split storage is enabled
* @since 2.7
*/
boolean getSplitStorage();
/**
* Returns a map of split storage options
* Gets a map of split storage options
*
* @return a map of split storage options, where the key is the storage section, and the value is the storage
* method. For example: key = user, value = json
* @since 2.7
*/
Map<String, String> getSplitStorageOptions();
@NonNull Map<String, String> getSplitStorageOptions();
@NonNull Unsafe unsafe();
interface Unsafe {
/**
* Gets an Object from the config.
*
* <p>This method is nested under {@link Unsafe} because the keys
* and return types may change between versions without warning.</p>
*
* @param key the key, as defined as a field name in
* the "ConfigKeys" class.
* @return the corresponding object, if one is present
* @throws IllegalArgumentException if the key isn't known
*/
@NonNull Object getObject(String key);
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,26 +25,36 @@
package me.lucko.luckperms.api;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* A node with a traceable origin
* An extension of {@link Node}, providing information about
* where the node originated from.
*
* @since 2.11
*/
public interface LocalizedNode extends Node {
/**
* Gets the delegate node
* Gets the delegate node.
*
* <p>Result is never another {@link LocalizedNode} instance.</p>
*
* @return the node this instance is representing
*/
Node getNode();
@NonNull Node getNode();
/**
* Gets the location where the {@link Node} is inherited from
* Gets the location where the {@link Node} is inherited from.
*
* @return where the node was inherited from. Will not return null.
* @see PermissionHolder#getObjectName()
* <p>The resultant string is the {@link PermissionHolder#getObjectName() object name} of the
* permission holder the node was inherited from.</p>
*
* <p>If the node was not inherited, the {@link PermissionHolder#getObjectName() object name}
* of the permission holder itself (the one that defined the node) will be returned.</p>
*
* @return where the node was inherited from.
*/
String getLocation();
@NonNull String getLocation();
}
+25 -122
View File
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,160 +25,60 @@
package me.lucko.luckperms.api;
import java.util.SortedMap;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.SortedSet;
import java.util.UUID;
/**
* Represents the internal LuckPerms log.
*
* <p> The returned instance provides a copy of the data at the time of retrieval. Any changes made to log entries will
* only apply to this instance of the log. You can add to the log using the {@link Storage}, and then request an updated copy.
* <p>The returned instance provides a copy of the data at the time of retrieval.</p>
*
* <p>Any changes made to log entries will only apply to this instance of the log.
* You can add to the log using the {@link Storage}, and then request an updated copy.</p>
*
* <p>All methods are thread safe, and return immutable and thread safe collections.</p>
*/
public interface Log {
/**
* @return a {@link SortedSet} of all of the {@link LogEntry} objects in this {@link Log}
*/
SortedSet<LogEntry> getContent();
/**
* @return all content in this log
*/
SortedSet<LogEntry> getRecent();
/**
* Gets the recent content separated by page
* Gets the {@link LogEntry}s that make up this log.
*
* @param pageNo the page number
* @return the page content
* @throws IllegalArgumentException if the pageNo is less than 1
* @throws IllegalStateException if the log doesn't contain enough entries to populate the page. See {@link #getRecentMaxPages()}}
* @return the content
*/
SortedMap<Integer, LogEntry> getRecent(int pageNo);
/**
* @return the max page number allowed in the {@link #getRecent(int)} method
*/
int getRecentMaxPages();
@NonNull SortedSet<LogEntry> getContent();
/**
* Gets the entries in the log performed by the given actor.
*
* @param actor the uuid of the actor to filter by
* @return all content in this log where is actor = uuid
* @return the content for the given actor
*/
SortedSet<LogEntry> getRecent(UUID actor);
@NonNull SortedSet<LogEntry> getContent(@NonNull UUID actor);
/**
* Gets the recent content for the uuid, separated into pages
* Gets the log content for a given user
*
* @param pageNo the page number
* @param actor the uuid of the actor to filter by
* @return the page content
* @throws IllegalArgumentException if the pageNo is less than 1
* @throws IllegalStateException if the log doesn't contain enough entries to populate the page. See {@link #getRecentMaxPages(UUID)}}
*/
SortedMap<Integer, LogEntry> getRecent(int pageNo, UUID actor);
/**
* @param actor the actor to filter by
* @return the max page number allowed in the {@link #getRecent(int, UUID)} method
*/
int getRecentMaxPages(UUID actor);
/**
* @param uuid the uuid to filter by
* @return all content in this log where the user = uuid
*/
SortedSet<LogEntry> getUserHistory(UUID uuid);
@NonNull SortedSet<LogEntry> getUserHistory(@NonNull UUID uuid);
/**
* Gets the user history content, separated by pages
* Gets the log content for a given group
*
* @param pageNo the page number
* @param uuid the uuid of the acted user to filter by
* @return the page content
* @throws IllegalArgumentException if the pageNo is less than 1
* @throws IllegalStateException if the log doesn't contain enough entries to populate the page. See {@link #getUserHistoryMaxPages(UUID)}}
*/
SortedMap<Integer, LogEntry> getUserHistory(int pageNo, UUID uuid);
/**
* @param uuid the uuid to filter by
* @return the max page number allowed in the {@link #getUserHistory(int, UUID)} method
*/
int getUserHistoryMaxPages(UUID uuid);
/**
* @param name the name to filter by
* @return all content in this log where the group = name
*/
SortedSet<LogEntry> getGroupHistory(String name);
@NonNull SortedSet<LogEntry> getGroupHistory(@NonNull String name);
/**
* Gets the group history content, separated by pages
* Gets the log content for a given track
*
* @param pageNo the page number
* @param name the name of the acted group to filter by
* @return the page content
* @throws IllegalArgumentException if the pageNo is less than 1
* @throws IllegalStateException if the log doesn't contain enough entries to populate the page. See {@link #getGroupHistoryMaxPages(String)}}
*/
SortedMap<Integer, LogEntry> getGroupHistory(int pageNo, String name);
/**
* @param name the name to filter by
* @return the max page number allowed in the {@link #getGroupHistory(int, String)} method
*/
int getGroupHistoryMaxPages(String name);
/**
* @param name the name to filter by
* @return all content in this log where the track = name
*/
SortedSet<LogEntry> getTrackHistory(String name);
@NonNull SortedSet<LogEntry> getTrackHistory(@NonNull String name);
/**
* Gets the track history content, separated by pages
*
* @param pageNo the page number
* @param name the name of the acted track to filter by
* @return the page content
*/
SortedMap<Integer, LogEntry> getTrackHistory(int pageNo, String name);
/**
* @param name the name to filter by
* @return the max page number allowed in the {@link #getTrackHistory(int, String)} method
* @throws IllegalArgumentException if the pageNo is less than 1
* @throws IllegalStateException if the log doesn't contain enough entries to populate the page. See {@link #getTrackHistoryMaxPages(String)}}
*/
int getTrackHistoryMaxPages(String name);
/**
* @param query the query to filter by
* @return all content in this log where the content matches query
*/
SortedSet<LogEntry> getSearch(String query);
/**
* Gets the search content, separated by pages
*
* @param pageNo the page number
* @param query the query to filter by
* @return the page content
* @throws IllegalArgumentException if the pageNo is less than 1
* @throws IllegalStateException if the log doesn't contain enough entries to populate the page. See {@link #getSearchMaxPages(String)}}
*/
SortedMap<Integer, LogEntry> getSearch(int pageNo, String query);
/**
* @param query the query to filter by
* @return the max page number allowed in the {@link #getSearch(int, String)} method
*/
int getSearchMaxPages(String query);
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,297 +25,214 @@
package me.lucko.luckperms.api;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Optional;
import java.util.UUID;
/**
* A single entry in the log
* Represents a logged action.
*
* <p> Implements {@link Comparable} ordering based upon the timestamp of the entry.
* @see ActionLogger#newEntryBuilder() for creating an instance
*/
public class LogEntry implements Comparable<LogEntry> {
private static final String FORMAT = "&8(&e%s&8) [&a%s&8] (&b%s&8) &7--> &f%s";
public interface LogEntry extends Comparable<LogEntry> {
public static LogEntryBuilder builder() {
return new LogEntryBuilder();
}
/**
* Gets the time in unix seconds when the action occurred.
*
* @return the timestamp
*/
long getTimestamp();
private long timestamp;
private UUID actor;
private String actorName;
private char type;
private UUID acted;
private String actedName;
private String action;
/**
* Gets the id of the object which performed the action.
*
* <p>This is the players uuid in most cases.</p>
*
* @return the actor id
*/
@NonNull UUID getActor();
public LogEntry(long timestamp, UUID actor, String actorName, char type, UUID acted, String actedName, String action) {
if (actor == null) {
throw new NullPointerException("actor");
}
if (actorName == null) {
throw new NullPointerException("actorName");
}
if (actedName == null) {
throw new NullPointerException("actedName");
}
if (action == null) {
throw new NullPointerException("action");
}
/**
* Gets the name describing the actor.
*
* @return the name of the actor
*/
@NonNull String getActorName();
this.timestamp = timestamp;
this.actor = actor;
this.actorName = actorName;
this.type = type;
this.acted = acted;
this.actedName = actedName;
this.action = action;
}
/**
* Gets the type of action.
*
* @return the action type
*/
@NonNull Type getType();
protected LogEntry() {
this.timestamp = 0L;
this.actor = null;
this.actorName = null;
this.type = Character.MIN_VALUE;
this.acted = null;
this.actedName = null;
this.action = null;
}
/**
* Gets the uuid of the object which was acted upon.
*
* <p>Will only return a value for {@link Type#USER} entries.</p>
*
* @return the uuid of acted object
*/
@NonNull Optional<UUID> getActed();
@Override
public int compareTo(LogEntry o) {
return equals(o) ? 0 : (Long.compare(timestamp, o.getTimestamp()) == 0 ? 1 : Long.compare(timestamp, o.getTimestamp()));
}
/**
* Gets the name describing the object which was acted upon
*
* @return the name of the acted object
*/
@NonNull String getActedName();
public boolean matchesSearch(String query) {
query = query.toLowerCase();
return actorName.toLowerCase().contains(query) || actedName.toLowerCase().contains(query)
|| action.toLowerCase().contains(query);
}
/**
* Returns a string describing the action which took place.
*
* <p>In most instances, this returns a variation of the command string which caused
* the change.</p>
*
* @return the action
*/
@NonNull String getAction();
public String getFormatted() {
return String.format(FORMAT,
actorName,
Character.toString(type),
actedName,
action
);
}
/**
* Represents the type of a {@link LogEntry}.
*
* @since 3.3
*/
enum Type {
USER('U'), GROUP('G'), TRACK('T');
public long getTimestamp() {
return timestamp;
}
void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public UUID getActor() {
return actor;
}
void setActor(UUID actor) {
this.actor = actor;
}
public String getActorName() {
return actorName;
}
void setActorName(String actorName) {
this.actorName = actorName;
}
public char getType() {
return type;
}
void setType(char type) {
this.type = type;
}
public UUID getActed() {
return acted;
}
void setActed(UUID acted) {
this.acted = acted;
}
public String getActedName() {
return actedName;
}
void setActedName(String actedName) {
this.actedName = actedName;
}
public String getAction() {
return action;
}
void setAction(String action) {
this.action = action;
}
@Override
public String toString() {
return "LogEntry(" +
"timestamp=" + this.getTimestamp() + ", " +
"actor=" + this.getActor() + ", " +
"actorName=" + this.getActorName() + ", " +
"type=" + this.getType() + ", " +
"acted=" + this.getActed() + ", " +
"actedName=" + this.getActedName() + ", " +
"action=" + this.getAction() +
")";
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof LogEntry)) return false;
final LogEntry other = (LogEntry) o;
if (this.getTimestamp() != other.getTimestamp()) return false;
if (this.getActor() == null ? other.getActor() != null : !this.getActor().equals(other.getActor())) return false;
if (this.getActorName() == null ? other.getActorName() != null : !this.getActorName().equals(other.getActorName())) return false;
if (this.getType() != other.getType()) return false;
if (this.getActed() == null ? other.getActed() != null : !this.getActed().equals(other.getActed())) return false;
if (this.getActedName() == null ? other.getActedName() != null : !this.getActedName().equals(other.getActedName())) return false;
return this.getAction() == null ? other.getAction() == null : this.getAction().equals(other.getAction());
}
@Override
public int hashCode() {
final int PRIME = 59;
int result = 1;
result = result * PRIME + (int) (this.getTimestamp() >>> 32 ^ this.getTimestamp());
result = result * PRIME + (this.getActor() == null ? 43 : this.getActor().hashCode());
result = result * PRIME + (this.getActorName() == null ? 43 : this.getActorName().hashCode());
result = result * PRIME + this.getType();
result = result * PRIME + (this.getActed() == null ? 43 : this.getActed().hashCode());
result = result * PRIME + (this.getActedName() == null ? 43 : this.getActedName().hashCode());
result = result * PRIME + (this.getAction() == null ? 43 : this.getAction().hashCode());
return result;
}
public static class LogEntryBuilder extends AbstractLogEntryBuilder<LogEntry, LogEntry.LogEntryBuilder> {
@Override
protected LogEntry createObj() {
return new LogEntry();
}
@Override
protected LogEntryBuilder getThis() {
return this;
}
}
public static abstract class AbstractLogEntryBuilder<T extends LogEntry, B extends AbstractLogEntryBuilder<T, B>> {
private T obj;
private B thisObj;
public AbstractLogEntryBuilder() {
obj = createObj();
thisObj = getThis();
}
protected abstract T createObj();
protected abstract B getThis();
public long getTimestamp() {
return obj.getTimestamp();
}
public UUID getActor() {
return obj.getActor();
}
public String getActorName() {
return obj.getActorName();
}
public char getType() {
return obj.getType();
}
public UUID getActed() {
return obj.getActed();
}
public String getActedName() {
return obj.getActedName();
}
public String getAction() {
return obj.getAction();
}
public B timestamp(long timestamp) {
obj.setTimestamp(timestamp);
return thisObj;
}
public B actor(UUID actor) {
obj.setActor(actor);
return thisObj;
}
public B actorName(String actorName) {
obj.setActorName(actorName);
return thisObj;
}
public B type(char type) {
obj.setType(type);
return thisObj;
}
public B acted(UUID acted) {
obj.setActed(acted);
return thisObj;
}
public B actedName(String actedName) {
obj.setActedName(actedName);
return thisObj;
}
public B action(String action) {
obj.setAction(action);
return thisObj;
}
public T build() {
if (getActor() == null) {
throw new NullPointerException("actor");
/**
* Parses a {@link Type} from a string.
*
* @param type the string
* @return a type
* @throws IllegalArgumentException if a type could not be parsed
* @since 4.4
*/
public static @NonNull Type parse(String type) {
try {
return valueOf(type);
} catch (IllegalArgumentException e) {
// ignore
}
if (getActorName() == null) {
throw new NullPointerException("actorName");
try {
return valueOf(type.charAt(0));
} catch (IllegalArgumentException e) {
// ignore
}
if (getActedName() == null) {
throw new NullPointerException("actedName");
}
if (getAction() == null) {
throw new NullPointerException("action");
}
return obj;
throw new IllegalArgumentException("Unknown type: " + type);
}
@Override
public String toString() {
return "LogEntry.LogEntryBuilder(" +
"timestamp=" + this.getTimestamp() + ", " +
"actor=" + this.getActor() + ", " +
"actorName=" + this.getActorName() + ", " +
"type=" + this.getType() + ", " +
"acted=" + this.getActed() + ", " +
"actedName=" + this.getActedName() + ", " +
"action=" + this.getAction() +
")";
/**
* Returns a {@link Type} by its code.
*
* @param code the code - see {@link Type#getCode()}.
* @return a type
* @throws IllegalArgumentException if a type could not be resolved
*/
public static @NonNull Type valueOf(char code) {
switch (code) {
case 'U':
case 'u':
return USER;
case 'G':
case 'g':
return GROUP;
case 'T':
case 't':
return TRACK;
default:
throw new IllegalArgumentException("Unknown code: " + code);
}
}
private final char code;
Type(char code) {
this.code = code;
}
public char getCode() {
return this.code;
}
}
/**
* Builds a LogEntry instance
*/
interface Builder {
/**
* Sets the timestamp of the entry.
*
* @param timestamp the timestamp
* @return the builder
* @see LogEntry#getTimestamp()
*/
@NonNull Builder setTimestamp(long timestamp);
/**
* Sets the actor of the entry.
*
* @param actor the actor
* @return the builder
* @see LogEntry#getActor()
*/
@NonNull Builder setActor(@NonNull UUID actor);
/**
* Sets the actor name of the entry.
*
* @param actorName the actor name
* @return the builder
* @see LogEntry#getActorName()
*/
@NonNull Builder setActorName(@NonNull String actorName);
/**
* Sets the type of the entry.
*
* @param type the type
* @return the builder
* @see LogEntry#getType()
*/
@NonNull Builder setType(@NonNull Type type);
/**
* Sets the acted object for the entry.
*
* @param acted the acted object
* @return the builder
* @see LogEntry#getActed()
*/
@NonNull Builder setActed(@Nullable UUID acted);
/**
* Sets the acted name for the entry.
*
* @param actedName the acted name
* @return the builder
* @see LogEntry#getActedName()
*/
@NonNull Builder setActedName(@NonNull String actedName);
/**
* Sets the action of the entry.
*
* @param action the action
* @return the builder
* @see LogEntry#getAction()
*/
@NonNull Builder setAction(@NonNull String action);
/**
* Creates a {@link LogEntry} instance from the builder.
*
* @return a new log entry instance
*/
@NonNull LogEntry build();
}
}
@@ -0,0 +1,124 @@
/*
* 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 me.lucko.luckperms.api;
import java.util.EnumSet;
import java.util.Set;
/**
* The various lookup setting flags for {@link Contexts}.
*
* @since 4.2
*/
public enum LookupSetting {
/**
* If the target subject is OP
*/
IS_OP,
/**
* If global or non-server-specific nodes should be applied
*/
INCLUDE_NODES_SET_WITHOUT_SERVER,
/**
* If global or non-world-specific nodes should be applied
*/
INCLUDE_NODES_SET_WITHOUT_WORLD,
/**
* If parent groups should be resolved
*/
RESOLVE_INHERITANCE,
/**
* If global or non-server-specific group memberships should be applied
*/
APPLY_PARENTS_SET_WITHOUT_SERVER,
/**
* If global or non-world-specific group memberships should be applied
*/
APPLY_PARENTS_SET_WITHOUT_WORLD;
/* bitwise utility methods */
static boolean isSet(byte b, LookupSetting setting) {
return ((b >> setting.ordinal()) & 1) == 1;
}
static byte createFlag(LookupSetting... settings) {
byte b = 0;
for (LookupSetting setting : settings) {
b |= (1 << setting.ordinal());
}
return b;
}
static byte createFlag(Set<LookupSetting> settings) {
byte b = 0;
for (LookupSetting setting : settings) {
b |= (1 << setting.ordinal());
}
return b;
}
static Set<LookupSetting> createSetFromFlag(byte b) {
EnumSet<LookupSetting> settings = EnumSet.noneOf(LookupSetting.class);
for (LookupSetting setting : LookupSetting.values()) {
if (((b >> setting.ordinal()) & 1) == 1) {
settings.add(setting);
}
}
return settings;
}
static byte createFlag(boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) {
byte b = 0;
if (includeNodesSetWithoutServer) {
b |= (1 << LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER.ordinal());
}
if (includeNodesSetWithoutWorld) {
b |= (1 << LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD.ordinal());
}
if (resolveInheritance) {
b |= (1 << LookupSetting.RESOLVE_INHERITANCE.ordinal());
}
if (applyParentsWithoutServer) {
b |= (1 << LookupSetting.APPLY_PARENTS_SET_WITHOUT_SERVER.ordinal());
}
if (applyParentsWithoutWorld) {
b |= (1 << LookupSetting.APPLY_PARENTS_SET_WITHOUT_WORLD.ordinal());
}
if (isOp) {
b |= (1 << LookupSetting.IS_OP.ordinal());
}
return b;
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,86 +25,233 @@
package me.lucko.luckperms.api;
import me.lucko.luckperms.LuckPerms;
import me.lucko.luckperms.api.context.ContextCalculator;
import me.lucko.luckperms.api.context.ContextManager;
import me.lucko.luckperms.api.context.ContextSet;
import me.lucko.luckperms.api.event.EventBus;
import me.lucko.luckperms.api.manager.GroupManager;
import me.lucko.luckperms.api.manager.TrackManager;
import me.lucko.luckperms.api.manager.UserManager;
import me.lucko.luckperms.api.messenger.MessengerProvider;
import me.lucko.luckperms.api.metastacking.MetaStackFactory;
import me.lucko.luckperms.api.platform.PlatformInfo;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Collection;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
/**
* The root API interface for LuckPerms
* The LuckPerms API.
*
* <p>This interface is the base of the entire API package. All API functions
* are accessed via this interface.</p>
*
* <p>An instance can be obtained via {@link LuckPerms#getApi()}, or the platforms
* Services Manager.</p>
*/
public interface LuckPermsApi {
/**
* Schedules an update task to run
* Gets information about the platform LuckPerms is running on.
*
* @return the platform info
* @since 4.0
*/
void runUpdateTask();
@NonNull PlatformInfo getPlatformInfo();
/**
* Gets the API version
* @return the version of the API running on the platform
* @since 2.6
* Gets the {@link UserManager}, responsible for managing
* {@link User} instances.
*
* <p>This manager can be used to retrieve instances of {@link User} by uuid
* or name, or query all loaded users.</p>
*
* <p>The {@link #getStorage() storage} instance should be used to
* load/create/save users.</p>
*
* @return the user manager
* @since 4.0
*/
double getApiVersion();
@NonNull UserManager getUserManager();
/**
* Gets the plugin version
* @return the version of the plugin running on the platform
* Gets the {@link GroupManager}, responsible for managing
* {@link Group} instances.
*
* <p>This manager can be used to retrieve instances of {@link Group} by
* name, or query all loaded groups.</p>
*
* <p>The {@link #getStorage() storage} instance should be used to
* load/create/save/delete groups.</p>
*
* @return the group manager
* @since 4.0
*/
String getVersion();
@NonNull GroupManager getGroupManager();
/**
* Gets the platform LuckPerms is running on
* @return the platform LuckPerms is running on
* @since 2.7
* Gets the {@link TrackManager}, responsible for managing
* {@link Track} instances.
*
* <p>This manager can be used to retrieve instances of {@link Track} by
* name, or query all loaded tracks.</p>
*
* <p>The {@link #getStorage() storage} instance should be used to
* load/create/save/delete tracks.</p>
*
* @return the track manager
* @since 4.0
*/
PlatformType getPlatformType();
@NonNull TrackManager getTrackManager();
/**
* Gets the event bus, used for subscribing to events
* Schedules the execution of an update task, and returns an encapsulation
* of the task as a {@link CompletableFuture}.
*
* <p>The exact actions performed in an update task remains an
* implementation detail of the plugin, however, as a minimum, it is
* expected to perform a full reload of user, group and track data, and
* ensure that any changes are fully applied and propagated.</p>
*
* @return a future
* @since 4.0
*/
@NonNull CompletableFuture<Void> runUpdateTask();
/**
* Gets the {@link EventBus}, used for subscribing to internal LuckPerms
* events.
*
* @return the event bus
* @since 3.0
*/
EventBus getEventBus();
@NonNull EventBus getEventBus();
/**
* Gets a wrapped {@link LPConfiguration} instance, with read only access
* Gets a representation of the plugins configuration
*
* @return a configuration instance
* @return the configuration
*/
LPConfiguration getConfiguration();
@NonNull LPConfiguration getConfiguration();
/**
* Gets a wrapped {@link Storage} instance.
* Gets an object representing the plugins primary {@link Storage} backend.
*
* <p>The instance propagates calls to the internal DAO (Data Access Object),
* and applies any changes to the storage provider.</p>
*
* @return a storage instance
* @since 2.14
*/
Storage getStorage();
@NonNull Storage getStorage();
/**
* Gets the messaging service in use on the platform, if present.
* Gets the {@link MessagingService}, if present.
*
* @return an optional that may contain a messaging service instance.
* <p>The MessagingService is used to dispatch updates throughout a network
* of servers running the plugin.</p>
*
* <p>Not all instances of LuckPerms will have a messaging service setup and
* configured, but it is recommended that all users of the API account for
* and make use of this.</p>
*
* @return the messaging service instance, if present.
*/
Optional<MessagingService> getMessagingService();
@NonNull Optional<MessagingService> getMessagingService();
/**
* Gets the {@link Logger} wrapping used by the platform
* Registers a {@link MessengerProvider} for use by the platform.
*
* @return the logger instance
* <p>Note that the mere action of registering a provider doesn't
* necessarily mean that it will be used.</p>
*
* @param messengerProvider the messenger provider.
* @since 4.1
*/
Logger getLogger();
void registerMessengerProvider(@NonNull MessengerProvider messengerProvider);
/**
* Gets a wrapped {@link UuidCache} instance, providing read access to the LuckPerms internal uuid caching system
* Gets the {@link ActionLogger}.
*
* @return a uuid cache instance
* <p>The action logger is responsible for saving and broadcasting defined
* actions occurring on the platform.</p>
*
* @return the action logger
* @since 4.1
*/
UuidCache getUuidCache();
@NonNull ActionLogger getActionLogger();
/**
* Gets a {@link UuidCache}.
*
* <p>The uuid cache provides read access to the internal LuckPerms uuid
* mapping system.</p>
*
* @return the uuid cache
* @deprecated this feature is now handled internally - and the API returns a
* No-op implementation of this class.
*/
@Deprecated
@NonNull UuidCache getUuidCache();
/**
* Gets the {@link ContextManager}.
*
* <p>The context manager manages {@link ContextCalculator}s, and calculates
* applicable contexts for a given type.</p>
*
* @return the context manager
* @since 4.0
*/
@NonNull ContextManager getContextManager();
/**
* Gets a {@link Collection} of all known permission strings.
*
* @return a collection of the known permissions
* @since 4.4
*/
@NonNull Collection<String> getKnownPermissions();
/**
* Gets the {@link NodeFactory}.
*
* <p>The node factory provides methods for building {@link Node} instances.</p>
*
* @return the node factory
*/
@NonNull NodeFactory getNodeFactory();
/**
* Gets the {@link MetaStackFactory}.
*
* <p>The metastack factory provides methods for retrieving
* {@link me.lucko.luckperms.api.metastacking.MetaStackElement}s and constructing
* {@link me.lucko.luckperms.api.metastacking.MetaStackDefinition}s.</p>
*
* @return the meta stack factory
* @since 3.2
*/
@NonNull MetaStackFactory getMetaStackFactory();
/*
* The following methods are provided only for convenience, and offer no
* additional functionality.
*
* They are implemented as "default" methods, using the manager and factory
* instances provided by the methods above.
*/
/**
* Gets a wrapped user object from the user storage
@@ -110,16 +260,20 @@ public interface LuckPermsApi {
* @return a {@link User} object, if one matching the uuid is loaded, or null if not
* @throws NullPointerException if the uuid is null
*/
User getUser(UUID uuid);
default @Nullable User getUser(@NonNull UUID uuid) {
return getUserManager().getUser(uuid);
}
/**
* Gets a wrapped user object from the user storage. This method does not return null, unlike {@link #getUser(UUID)}
* Gets a wrapped user object from the user storage.
*
* @param uuid the uuid of the user to get
* @return an optional {@link User} object
* @throws NullPointerException if the uuid is null
*/
Optional<User> getUserSafe(UUID uuid);
default @NonNull Optional<User> getUserSafe(@NonNull UUID uuid) {
return getUserManager().getUserOpt(uuid);
}
/**
* Gets a wrapped user object from the user storage
@@ -128,24 +282,29 @@ public interface LuckPermsApi {
* @return a {@link User} object, if one matching the uuid is loaded, or null if not
* @throws NullPointerException if the name is null
*/
User getUser(String name);
default @Nullable User getUser(@NonNull String name) {
return getUserManager().getUser(name);
}
/**
* Gets a wrapped user object from the user storage. This method does not return null, unlike {@link
* #getUser(String)}
* Gets a wrapped user object from the user storage.
*
* @param name the username of the user to get
* @return an optional {@link User} object
* @throws NullPointerException if the name is null
*/
Optional<User> getUserSafe(String name);
default @NonNull Optional<User> getUserSafe(@NonNull String name) {
return getUserManager().getUserOpt(name);
}
/**
* Gets a set of all loaded users.
*
* @return a {@link Set} of {@link User} objects
*/
Set<User> getUsers();
default @NonNull Set<User> getUsers() {
return getUserManager().getLoadedUsers();
}
/**
* Check if a user is loaded in memory
@@ -154,16 +313,19 @@ public interface LuckPermsApi {
* @return true if the user is loaded
* @throws NullPointerException if the uuid is null
*/
boolean isUserLoaded(UUID uuid);
default boolean isUserLoaded(@NonNull UUID uuid) {
return getUserManager().isLoaded(uuid);
}
/**
* Unload a user from the internal storage, if they're not currently online.
*
* @param user the user to unload
* @throws NullPointerException if the user is null
* @since 2.6
*/
void cleanupUser(User user);
default void cleanupUser(@NonNull User user) {
getUserManager().cleanupUser(user);
}
/**
* Gets a wrapped group object from the group storage
@@ -172,23 +334,31 @@ public interface LuckPermsApi {
* @return a {@link Group} object, if one matching the name exists, or null if not
* @throws NullPointerException if the name is null
*/
Group getGroup(String name);
default @Nullable Group getGroup(@NonNull String name) {
return getGroupManager().getGroup(name);
}
/**
* Gets a wrapped group object from the group storage. This method does not return null, unlike {@link #getGroup}
* Gets a wrapped group object from the group storage.
*
* <p>This method does not return null, unlike {@link #getGroup}</p>
*
* @param name the name of the group to get
* @return an optional {@link Group} object
* @throws NullPointerException if the name is null
*/
Optional<Group> getGroupSafe(String name);
default @NonNull Optional<Group> getGroupSafe(@NonNull String name) {
return getGroupManager().getGroupOpt(name);
}
/**
* Gets a set of all loaded groups.
*
* @return a {@link Set} of {@link Group} objects
*/
Set<Group> getGroups();
default @NonNull Set<Group> getGroups() {
return getGroupManager().getLoadedGroups();
}
/**
* Check if a group is loaded in memory
@@ -197,32 +367,43 @@ public interface LuckPermsApi {
* @return true if the group is loaded
* @throws NullPointerException if the name is null
*/
boolean isGroupLoaded(String name);
default boolean isGroupLoaded(@NonNull String name) {
return getGroupManager().isLoaded(name);
}
/**
* Gets a wrapped track object from the track storage
*
* @param name the name of the track to get
* @return a {@link Track} object, if one matching the name exists, or null if not
* @return a {@link Track} object, if one matching the name exists, or null
* if not
* @throws NullPointerException if the name is null
*/
Track getTrack(String name);
default @Nullable Track getTrack(@NonNull String name) {
return getTrackManager().getTrack(name);
}
/**
* Gets a wrapped track object from the track storage. This method does not return null, unlike {@link #getTrack}
* Gets a wrapped track object from the track storage.
*
* <p>This method does not return null, unlike {@link #getTrack}</p>
*
* @param name the name of the track to get
* @return an optional {@link Track} object
* @throws NullPointerException if the name is null
*/
Optional<Track> getTrackSafe(String name);
default @NonNull Optional<Track> getTrackSafe(@NonNull String name) {
return getTrackManager().getTrackOpt(name);
}
/**
* Gets a set of all loaded tracks.
*
* @return a {@link Set} of {@link Track} objects
*/
Set<Track> getTracks();
default @NonNull Set<Track> getTracks() {
return getTrackManager().getLoadedTracks();
}
/**
* Check if a track is loaded in memory
@@ -231,14 +412,19 @@ public interface LuckPermsApi {
* @return true if the track is loaded
* @throws NullPointerException if the name is null
*/
boolean isTrackLoaded(String name);
default boolean isTrackLoaded(@NonNull String name) {
return getTrackManager().isLoaded(name);
}
/**
* Gets the node factory instance for the platform
* Returns a new LogEntry Builder instance
*
* @return the node factory
* @return a new builder
* @since 4.0
*/
NodeFactory getNodeFactory();
default LogEntry.@NonNull Builder newLogEntryBuilder() {
return getActionLogger().newEntryBuilder();
}
/**
* Returns a permission builder instance
@@ -249,15 +435,19 @@ public interface LuckPermsApi {
* @throws NullPointerException if the permission is null
* @since 2.6
*/
Node.Builder buildNode(String permission) throws IllegalArgumentException;
default Node.@NonNull Builder buildNode(@NonNull String permission) throws IllegalArgumentException {
return getNodeFactory().newBuilder(permission);
}
/**
* Register a custom context calculator to the server
*
* @param contextCalculator the context calculator to register. The type MUST be the player class of the platform.
* @param calculator the context calculator to register. The type MUST be the player class of the platform.
* @throws ClassCastException if the type is not the player class of the platform.
*/
void registerContextCalculator(ContextCalculator<?> contextCalculator);
default void registerContextCalculator(@NonNull ContextCalculator<?> calculator) {
getContextManager().registerCalculator(calculator);
}
/**
* Gets a calculated context instance for the user using the rules of the platform.
@@ -267,7 +457,9 @@ public interface LuckPermsApi {
* @param user the user to get contexts for
* @return an optional containing contexts. Will return empty if the user is not online.
*/
Optional<Contexts> getContextForUser(User user);
default @NonNull Optional<Contexts> getContextForUser(@NonNull User user) {
return getContextManager().lookupApplicableContexts(user);
}
/**
* Gets set of contexts applicable to a player using the platforms {@link ContextCalculator}s.
@@ -276,6 +468,19 @@ public interface LuckPermsApi {
* @return a set of contexts.
* @since 2.17
*/
ContextSet getContextForPlayer(Object player);
default @NonNull ContextSet getContextForPlayer(@NonNull Object player) {
return getContextManager().getApplicableContext(player);
}
/**
* Gets a Contexts instance for the player using the platforms {@link ContextCalculator}s.
*
* @param player the player to calculate for. Must be the player instance for the platform.
* @return a set of contexts.
* @since 3.3
*/
default @NonNull Contexts getContextsForPlayer(@NonNull Object player) {
return getContextManager().getApplicableContexts(player);
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,6 +25,8 @@
package me.lucko.luckperms.api;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* A means to push changes to other servers using the platforms networking
*
@@ -30,11 +35,42 @@ package me.lucko.luckperms.api;
public interface MessagingService {
/**
* Uses the messaging service to inform other servers about changes.
* Gets the name of this messaging service
*
* <p> This will push the update asynchronously, and this method will return immediately. Calling this method is
* equivalent to running "/lp networksync", except will not sync this server.
* @return the name of this messaging service
* @since 4.1
*/
String getName();
/**
* Uses the messaging service to inform other servers about a general
* change.
*
* <p>The standard response by other servers will be to execute a overall
* sync of all live data, equivalent to calling
* {@link LuckPermsApi#runUpdateTask()}.</p>
*
* <p>This will push the update asynchronously, and this method will return
* immediately. Note that this method will not cause an update to be
* processed on the local server.</p>
*/
void pushUpdate();
/**
* Uses the messaging service to inform other servers about a change to a
* specific user.
*
* <p>The standard response by other servers is undefined, however the
* current implementation will reload the corresponding users data if they
* are online.</p>
*
* <p>This will push the update asynchronously, and this method will return
* immediately. Note that this method will not cause an update to be
* processed on the local server.</p>
*
* @param user the user to push the update for
* @since 4.1
*/
void pushUserUpdate(@NonNull User user);
}
@@ -1,340 +0,0 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
*
* 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 me.lucko.luckperms.api;
import me.lucko.luckperms.LuckPerms;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* A collection of utilities to help retrieve meta values for {@link PermissionHolder}s
*
* @since 2.7
*/
public class MetaUtils {
private static String escapeDelimiters(String s, String... delims) {
for (String delim : delims) {
s = s.replace(delim, "\\" + delim);
}
return s;
}
private static String unescapeDelimiters(String s, String... delims) {
for (String delim : delims) {
s = s.replace("\\" + delim, delim);
}
return s;
}
/**
* Escapes special characters used within LuckPerms, so the string can be saved without issues
*
* @param s the string to escape
* @return an escaped string
* @throws NullPointerException if the string is null
*/
public static String escapeCharacters(String s) {
if (s == null) {
throw new NullPointerException();
}
return escapeDelimiters(s, ".", "/", "-", "$");
}
/**
* Unescapes special characters used within LuckPerms, the inverse of {@link #escapeCharacters(String)}
*
* @param s the string to unescape
* @return an unescaped string
* @throws NullPointerException if the string is null
*/
public static String unescapeCharacters(String s) {
if (s == null) {
throw new NullPointerException();
}
s = s.replace("{SEP}", ".");
s = s.replace("{FSEP}", "/");
s = s.replace("{DSEP}", "$");
s = unescapeDelimiters(s, ".", "/", "-", "$");
return s;
}
/**
* Sets a meta value on a holder
*
* @param holder the holder to apply the meta node to
* @param server the server to apply the meta on, can be null
* @param world the world to apply the meta on, can be null
* @param node the meta node
* @param value the meta value
* @throws NullPointerException if the holder, node or value is null
* @throws IllegalArgumentException if the node or value is empty
*/
public static void setMeta(PermissionHolder holder, String server, String world, String node, String value) {
if (holder == null) {
throw new NullPointerException("holder");
}
if (node == null) {
throw new NullPointerException("node");
}
if (value == null) {
throw new NullPointerException("value");
}
if (node.equals("")) {
throw new IllegalArgumentException("node is empty");
}
if (value.equals("")) {
throw new IllegalArgumentException("value is empty");
}
if (server == null || server.equals("")) {
server = "global";
}
node = escapeCharacters(node);
value = escapeCharacters(value);
Set<Node> toRemove = new HashSet<>();
for (Node n : holder.getEnduringPermissions()) {
if (n.isMeta() && n.getMeta().getKey().equals(node)) {
toRemove.add(n);
}
}
for (Node n : toRemove) {
try {
holder.unsetPermission(n);
} catch (ObjectLacksException ignored) {
}
}
Node.Builder metaNode = LuckPerms.getApi().buildNode("meta." + node + "." + value).setValue(true);
if (!server.equalsIgnoreCase("global")) {
metaNode.setServer(server);
}
if (world != null && !world.equals("")) {
metaNode.setServer(server).setWorld(world);
}
try {
holder.setPermission(metaNode.build());
} catch (ObjectAlreadyHasException ignored) {
}
}
/**
* Gets a meta value for the holder
*
* @param holder the holder to get the meta from
* @param server the server to retrieve the meta on, can be null
* @param world the world to retrieve the meta on, can be null
* @param node the node to get
* @param defaultValue the default value to return if the node is not set
* @param includeGlobal if global nodes should be considered when retrieving the meta
* @return a meta string, or the default value if the user does not have the meta node
* @throws NullPointerException if the holder or node is null
* @throws IllegalArgumentException if the node is empty
*/
public static String getMeta(PermissionHolder holder, String server, String world, String node, String defaultValue, boolean includeGlobal) {
if (holder == null) {
throw new NullPointerException("holder");
}
if (server == null || server.equals("")) {
server = "global";
}
if (node == null) {
throw new NullPointerException("node");
}
if (node.equals("")) {
throw new IllegalArgumentException("node is empty");
}
node = escapeCharacters(node);
for (Node n : holder.getPermissions()) {
if (!n.getValue()) {
continue;
}
if (!n.isMeta()) {
continue;
}
if (!server.equalsIgnoreCase("global")) {
if (!n.shouldApplyOnServer(server, includeGlobal, false)) {
continue;
}
}
if (!n.shouldApplyOnWorld(world, includeGlobal, false)) {
continue;
}
Map.Entry<String, String> meta = n.getMeta();
if (meta.getKey().equalsIgnoreCase(node)) {
return unescapeCharacters(meta.getValue());
}
}
return defaultValue;
}
private static void setChatMeta(boolean prefix, PermissionHolder holder, String value, int priority, String server, String world) {
if (holder == null) {
throw new NullPointerException("holder");
}
if (value == null || value.equals("")) {
throw new IllegalArgumentException("value is null/empty");
}
Node.Builder node = LuckPerms.getApi().buildNode(prefix ? "prefix" : "suffix" + "." + priority + "." + escapeCharacters(value));
node.setValue(true);
if (!server.equalsIgnoreCase("global")) {
node.setServer(server);
}
if (world != null && !world.equals("")) {
node.setServer(server).setWorld(world);
}
try {
holder.setPermission(node.build());
} catch (ObjectAlreadyHasException ignored) {
}
}
/**
* Adds a prefix to a holder on a specific server and world
*
* @param holder the holder to set the prefix for
* @param prefix the prefix value
* @param priority the priority to set the prefix at
* @param server the server to set the prefix on, can be null
* @param world the world to set the prefix on, can be null
* @throws NullPointerException if the holder is null
* @throws IllegalArgumentException if the prefix is null or empty
*/
public static void setPrefix(PermissionHolder holder, String prefix, int priority, String server, String world) {
setChatMeta(true, holder, prefix, priority, server, world);
}
/**
* Adds a suffix to a holder on a specific server and world
*
* @param holder the holder to set the suffix for
* @param suffix the suffix value
* @param priority the priority to set the suffix at
* @param server the server to set the suffix on, can be null
* @param world the world to set the suffix on, can be null
* @throws NullPointerException if the holder is null
* @throws IllegalArgumentException if the suffix is null or empty
*/
public static void setSuffix(PermissionHolder holder, String suffix, int priority, String server, String world) {
setChatMeta(false, holder, suffix, priority, server, world);
}
private static String getChatMeta(boolean prefix, PermissionHolder holder, String server, String world, boolean includeGlobal) {
if (holder == null) {
throw new NullPointerException("holder");
}
if (server == null) {
server = "global";
}
int priority = Integer.MIN_VALUE;
String meta = null;
for (Node n : holder.getAllNodes(Contexts.allowAll())) {
if (!n.getValue()) {
continue;
}
if (!server.equalsIgnoreCase("global")) {
if (!n.shouldApplyOnServer(server, includeGlobal, false)) {
continue;
}
}
if (!n.shouldApplyOnWorld(world, includeGlobal, false)) {
continue;
}
if (prefix ? !n.isPrefix() : !n.isSuffix()) {
continue;
}
Map.Entry<Integer, String> value = prefix ? n.getPrefix() : n.getSuffix();
if (value.getKey() > priority) {
meta = value.getValue();
priority = value.getKey();
}
}
return meta == null ? "" : unescapeCharacters(meta);
}
/**
* Returns a holders highest priority prefix, if they have one
*
* @param holder the holder
* @param server the server to retrieve the prefix on
* @param world the world to retrieve the prefix on
* @param includeGlobal if global nodes should be considered when retrieving the prefix
* @return a prefix string, if the holder has one, or an empty string if not.
* @throws NullPointerException if the holder is null
*/
public static String getPrefix(PermissionHolder holder, String server, String world, boolean includeGlobal) {
return getChatMeta(true, holder, server, world, includeGlobal);
}
/**
* Returns a holders highest priority suffix, if they have one
*
* @param holder the holder
* @param server the server to retrieve the suffix on
* @param world the world to retrieve the suffix on
* @param includeGlobal if global nodes should be considered when retrieving the suffix
* @return a suffix string, if the holder has one, or an empty string if not.
* @throws NullPointerException if the holder is null
*/
public static String getSuffix(PermissionHolder holder, String server, String world, boolean includeGlobal) {
return getChatMeta(false, holder, server, world, includeGlobal);
}
private MetaUtils() {
}
}
@@ -0,0 +1,74 @@
/*
* 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 me.lucko.luckperms.api;
/**
* Represents the result to a "mutation" on an object.
*
* @since 4.2
*/
public interface MutateResult {
/**
* Instance of {@link MutateResult} which always reports success.
*/
MutateResult GENERIC_SUCCESS = () -> true;
/**
* Instance of {@link MutateResult} which always reports failure.
*/
MutateResult GENERIC_FAILURE = () -> false;
/**
* Gets if the operation which produced this result completed successfully.
*
* @return if the result indicates a success
*/
boolean wasSuccess();
/**
* Gets if the operation which produced this result failed.
*
* @return if the result indicates a failure
*/
default boolean wasFailure() {
return !wasSuccess();
}
/**
* Gets a boolean representation of the result.
*
* <p>A value of <code>true</code> marks that the operation {@link #wasSuccess() was a success}
* and a value of <code>false</code> marks that the operation
* {@link #wasFailure() was a failure}.</p>
*
* @return a boolean representation
*/
default boolean asBoolean() {
return wasSuccess();
}
}
+459 -137
View File
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,327 +25,646 @@
package me.lucko.luckperms.api;
import com.google.common.base.Preconditions;
import me.lucko.luckperms.api.context.ContextSet;
import me.lucko.luckperms.api.nodetype.NodeType;
import me.lucko.luckperms.api.nodetype.NodeTypeKey;
import me.lucko.luckperms.api.nodetype.types.DisplayNameType;
import me.lucko.luckperms.api.nodetype.types.InheritanceType;
import me.lucko.luckperms.api.nodetype.types.MetaType;
import me.lucko.luckperms.api.nodetype.types.PrefixType;
import me.lucko.luckperms.api.nodetype.types.SuffixType;
import me.lucko.luckperms.api.nodetype.types.WeightType;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
/**
* An immutable permission node
* Represents a LuckPerms "node".
*
* <p> Use {@link LuckPermsApi#buildNode(String)} to get an instance.
* <p>The {@link Node} class encapsulates more than just permission assignments.
* Nodes are used to store data about inherited groups, as well as assigned
* prefixes, suffixes and meta values.</p>
*
* <p>Combining these various states into one object (a "node") means that a
* holder only has to have one type of data set (a set of nodes) in order to
* take on various properties.</p>
*
* <p>It is recommended that users of the API make use of {@link Stream}s
* to manipulate data and obtain the required information.</p>
*
* <p>This interface provides a number of methods to read the attributes of the
* node, as well as methods to query and extract additional state and properties
* from these settings.</p>
*
* <p>Nodes have the following attributes:</p>
* <p></p>
* <ul>
* <li>{@link #getPermission() permission} - the actual permission string</li>
* <li>{@link #getValue() value} - the value of the node (false for negated)</li>
* <li>{@link #isOverride() override} - if the node is marked as having special priority over other nodes</li>
* <li>{@link #getServer() server} - the specific server where this node should apply</li>
* <li>{@link #getWorld() world} - the specific world where this node should apply</li>
* <li>{@link #getContexts() context} - the additional contexts required for this node to apply </li>
* <li>{@link #getExpiry() expiry} - the time when this node should expire</li>
* </ul>
*
* <p>The 'permission' property of a {@link Node} is also used in some cases to represent state
* beyond a granted permission. This state is encapsulated by extra {@link NodeType} data which
* can be obtained from this instance using {@link #getTypeData(NodeTypeKey)}.</p>
*
* <p>Type data is mapped by {@link NodeTypeKey}s, which are usually stored as static members of the
* corresponding {@link NodeType} class under the <code>KEY</code> field.</p>
*
* <p>The current types are:</p>
* <p></p>
* <ul>
* <li>normal - just a regular permission</li>
* <li>{@link InheritanceType} - an "inheritance node" marks that the holder should inherit data from another group</li>
* <li>{@link PrefixType} - represents an assigned prefix</li>
* <li>{@link SuffixType} - represents an assigned suffix</li>
* <li>{@link MetaType} - represents an assigned meta option</li>
* <li>{@link WeightType} - marks the weight of the object holding this node</li>
* <li>{@link DisplayNameType} - marks the display name of the object holding this node</li>
* </ul>
*
* <p>The core node state must be immutable in all implementations.</p>
*
* @see NodeFactory for obtaining and constructing instances.
* @since 2.6
*/
public interface Node extends Map.Entry<String, Boolean> {
public interface Node {
/**
* Gets the permission string this node encapsulates.
*
* <p>The exact value of this string may vary for nodes which aren't regular
* permission settings.</p>
*
* @return the actual permission node
*/
String getPermission();
@NonNull String getPermission();
/**
* Get what value the permission is set to. A negated node would return <code>false</code>.
* Gets the value of the node.
*
* @return the permission's value
* <p>A negated setting would result in a value of <code>false</code>.</p>
*
* @return the nodes value
*/
@Override
Boolean getValue();
boolean getValue();
/**
* Gets the value of this node as a {@link Tristate}.
*
* @return the value of this node as a Tristate
*/
Tristate getTristate();
default @NonNull Tristate getTristate() {
return Tristate.fromBoolean(getValue());
}
/**
* Gets if the node is negated.
*
* <p>This is the inverse of the {@link #getValue() value}.</p>
*
* @return true if the node is negated
*/
boolean isNegated();
default boolean isNegated() {
return !getValue();
}
/**
* If this node is set to override explicitly.
* This value does not persist across saves, and is therefore only useful for transient nodes
* Gets if this node is set to override explicitly.
*
* <p>This value does not persist across saves, and is therefore only
* useful for transient nodes.</p>
*
* @return true if this node is set to override explicitly
*/
boolean isOverride();
/**
* Gets the server this node applies on, if the node is server specific
* Gets the server this node applies on, if the node is server specific.
*
* @return an {@link Optional} containing the server, if one is defined
*/
Optional<String> getServer();
@NonNull Optional<String> getServer();
/**
* Gets the world this node applies on, if the node is world specific
* Gets the world this node applies on, if the node is world specific.
*
* @return an {@link Optional} containing the world, if one is defined
*/
Optional<String> getWorld();
@NonNull Optional<String> getWorld();
/**
* Gets if this node is server specific.
*
* @return true if this node is server specific
*/
boolean isServerSpecific();
/**
* Gets if this node is server specific.
*
* @return true if this node is server specific
*/
boolean isWorldSpecific();
/**
* If this node should apply on a specific server
* Gets if this node applies globally, and therefore has no specific context.
*
* @param server the name of the server
* @param includeGlobal if global permissions should apply
* @param applyRegex if regex should be applied
* @return true if the node should apply
* @return true if this node applies globally, and has no specific context
* @since 3.1
*/
boolean shouldApplyOnServer(String server, boolean includeGlobal, boolean applyRegex);
boolean appliesGlobally();
/**
* If this node should apply on a specific world
* Gets if this node has any specific context in order for it to apply.
*
* @param world the name of the world
* @param includeGlobal if global permissions should apply
* @param applyRegex if regex should be applied
* @return true if the node should apply
* @return true if this node has specific context
* @since 3.1
*/
boolean shouldApplyOnWorld(String world, boolean includeGlobal, boolean applyRegex);
boolean hasSpecificContext();
/**
* If this node should apply in the given context
* Gets if this node should apply in the given context
*
* @param context the context key value pairs
* @param worldAndServer if world and server contexts should be checked
* @param contextSet the context set
* @return true if the node should apply
* @since 2.13
*/
boolean shouldApplyWithContext(ContextSet context, boolean worldAndServer);
boolean shouldApplyWithContext(@NonNull ContextSet contextSet);
/**
* If this node should apply in the given context
* Resolves any shorthand parts of this node and returns the full list of
* resolved nodes.
*
* @param context the context key value pairs
* @return true if the node should apply
* @since 2.13
*/
boolean shouldApplyWithContext(ContextSet context);
/**
* Similar to {@link #shouldApplyOnServer(String, boolean, boolean)}, except this method accepts a List
*
* @param servers the list of servers
* @param includeGlobal if global permissions should apply
* @return true if the node should apply
*/
boolean shouldApplyOnAnyServers(List<String> servers, boolean includeGlobal);
/**
* Similar to {@link #shouldApplyOnWorld(String, boolean, boolean)}, except this method accepts a List
*
* @param worlds the list of world
* @param includeGlobal if global permissions should apply
* @return true if the node should apply
*/
boolean shouldApplyOnAnyWorlds(List<String> worlds, boolean includeGlobal);
/**
* Resolves a list of wildcards that match this node
*
* @param possibleNodes a list of possible permission nodes
* @return a list of permissions that match this wildcard
*/
List<String> resolveWildcard(List<String> possibleNodes);
/**
* Resolves any shorthand parts of this node and returns the full list
* <p>The list will not contain the exact permission itself.</p>
*
* @return a list of full nodes
*/
List<String> resolveShorthand();
@NonNull List<String> resolveShorthand();
/**
* Gets if this node is assigned temporarily.
*
* @return true if this node will expire in the future
*/
boolean isTemporary();
/**
* Gets if this node is permanent (will not expire).
*
* @return true if this node will not expire
*/
boolean isPermanent();
default boolean isPermanent() {
return !isTemporary();
}
/**
* Gets the unix timestamp (in seconds) when this node will expire.
*
* @return the time in Unix time when this node will expire
* @throws IllegalStateException if the node is not temporary
*/
long getExpiryUnixTime();
long getExpiryUnixTime() throws IllegalStateException;
/**
* Gets the date when this node will expire.
*
* @return the {@link Date} when this node will expire
* @throws IllegalStateException if the node is not temporary
*/
Date getExpiry();
@NonNull Date getExpiry() throws IllegalStateException;
/**
* Gets the number of seconds until this permission will expire.
*
* <p>Will return a negative value if the node has already expired.</p>
*
* @return the number of seconds until this permission will expire
* @throws IllegalStateException if the node is not temporary
*/
long getSecondsTilExpiry();
long getSecondsTilExpiry() throws IllegalStateException;
/**
* Return true if the node has expired.
* This also returns false if the node is not temporary
* Gets if the node has expired.
*
* <p>This returns false if the node is not temporary.</p>
*
* @return true if this node has expired
*/
boolean hasExpired();
/**
* Gets the extra contexts required for this node to apply.
*
* @return the extra contexts required for this node to apply
* @since 2.13
*/
ContextSet getContexts();
@NonNull ContextSet getContexts();
/**
* Converts this node into a serialized form
* The same as {@link #getContexts()}, but also includes context pairs for
* "server" and "world" keys if present.
*
* @return a serialized node string
* @return the full contexts required for this node to apply
* @see Contexts#SERVER_KEY
* @see Contexts#WORLD_KEY
* @since 3.1
*/
String toSerializedNode();
@NonNull ContextSet getFullContexts();
/**
* @return true if this is a group node
*/
boolean isGroupNode();
/**
* @return the name of the group
* @throws IllegalStateException if this is not a group node. See {@link #isGroupNode()}
*/
String getGroupName();
/**
* @return true is this node is a wildcard node
* Gets if this node is a wildcard permission.
*
* @return true if this node is a wildcard permission
*/
boolean isWildcard();
/**
* Gets the level of this wildcard, higher is more specific
* Gets the level of this wildcard.
*
* <p>The node <code>luckperms.*</code> has a wildcard level of 1.</p>
* <p>The node <code>luckperms.user.permission.*</code> has a wildcard level of 3.</p>
*
* <p>Nodes with a higher wildcard level are more specific and have priority over
* less specific nodes (nodes with a lower wildcard level).</p>
*
* @return the wildcard level
* @throws IllegalStateException if this is not a wildcard
*/
int getWildcardLevel();
int getWildcardLevel() throws IllegalStateException;
/**
* @return true if this node is a meta node
*/
boolean isMeta();
/**
* Gets the meta value from this node
* Gets if this node has any extra {@link NodeType} data attached to it.
*
* @return the meta value
* @throws IllegalStateException if this node is not a meta node
* @return if this node has any type data
* @since 4.2
*/
Map.Entry<String, String> getMeta();
boolean hasTypeData();
/**
* Gets the type data corresponding to the given <code>key</code>, if present.
*
* @param key the key
* @param <T> the {@link NodeType} type
* @return the data, if present
* @since 4.2
*/
<T extends NodeType> Optional<T> getTypeData(NodeTypeKey<T> key);
/**
* Gets the type data corresponding to the given <code>key</code>, throwing an exception
* if no data is present.
*
* @param key the key
* @param <T> the {@link NodeType} type
* @return the data
* @throws IllegalStateException if data isn't present
* @since 4.2
*/
default <T extends NodeType> T typeData(NodeTypeKey<T> key) throws IllegalStateException {
return getTypeData(key).orElseThrow(() -> new IllegalStateException("Node '" + getPermission() + "' does not have the '" + key.getTypeName() + "' type."));
}
/**
* Gets if this node has {@link InheritanceType} type data.
*
* @return true if this is a inheritance (group) node.
*/
default boolean isGroupNode() {
return getTypeData(InheritanceType.KEY).isPresent();
}
/**
* Gets the name of the inherited group if this node has {@link InheritanceType} type data,
* throwing an exception if the data is not present.
*
* @return the name of the group
* @throws IllegalStateException if this node doesn't have {@link InheritanceType} data
*/
default @NonNull String getGroupName() throws IllegalStateException {
return typeData(InheritanceType.KEY).getGroupName();
}
/**
* Gets if this node has {@link MetaType} type data.
*
* @return true if this is a meta node.
*/
default boolean isMeta() {
return getTypeData(MetaType.KEY).isPresent();
}
/**
* Gets the meta entry if this node has {@link MetaType} type data,
* throwing an exception if the data is not present.
*
* @return the meta entry
* @throws IllegalStateException if this node doesn't have {@link MetaType} data
*/
default Map.@NonNull Entry<String, String> getMeta() throws IllegalStateException {
return typeData(MetaType.KEY);
}
/**
* Gets if this node has {@link PrefixType} type data.
*
* @return true if this node is a prefix node
*/
boolean isPrefix();
default boolean isPrefix() {
return getTypeData(PrefixType.KEY).isPresent();
}
/**
* Gets the prefix value from this node
* Gets the prefix entry if this node has {@link PrefixType} type data,
* throwing an exception if the data is not present.
*
* @return the prefix value
* @throws IllegalStateException if this node is a not a prefix node
* @return the meta entry
* @throws IllegalStateException if this node doesn't have {@link PrefixType} data
*/
Map.Entry<Integer, String> getPrefix();
default Map.@NonNull Entry<Integer, String> getPrefix() throws IllegalStateException {
return typeData(PrefixType.KEY).getAsEntry();
}
/**
* Gets if this node has {@link SuffixType} type data.
*
* @return true if this node is a suffix node
*/
boolean isSuffix();
default boolean isSuffix() {
return getTypeData(SuffixType.KEY).isPresent();
}
/**
* Gets the suffix value from this node
* Gets the suffix entry if this node has {@link SuffixType} type data,
* throwing an exception if the data is not present.
*
* @return the suffix value
* @throws IllegalStateException if this node is a not a suffix node
* @return the meta entry
* @throws IllegalStateException if this node doesn't have {@link SuffixType} data
*/
Map.Entry<Integer, String> getSuffix();
default Map.@NonNull Entry<Integer, String> getSuffix() throws IllegalStateException {
return typeData(SuffixType.KEY).getAsEntry();
}
/**
* Checks if this Node is equal to another node
* Gets if this Node is equal to another node.
*
* @param obj the other node
* @return true if this node is equal to the other provided
* @see #equalsIgnoringValue(Node) for a less strict implementation of this method
* @see StandardNodeEquality#EXACT
*/
@Override
boolean equals(Object obj);
/**
* Similar to {@link Node#equals(Object)}, except doesn't take note of the value
* Gets if this Node is equal to another node as defined by the given
* {@link NodeEqualityPredicate}.
*
* @param other the other node
* @return true if the two nodes are almost equal
* @param other the other node
* @param equalityPredicate the predicate
* @return true if this node is considered equal
* @since 4.1
*/
boolean equalsIgnoringValue(Node other);
boolean equals(Node other, NodeEqualityPredicate equalityPredicate);
/**
* Similar to {@link Node#equals(Object)}, except doesn't take note of the expiry time or value
* Similar to {@link Node#equals(Object)}, except doesn't take note of the
* value.
*
* @param other the other node
* @return true if the two nodes are almost equal
* @see StandardNodeEquality#IGNORE_VALUE
* @deprecated in favour of {@link #equals(Node, NodeEqualityPredicate)}
*/
boolean almostEquals(Node other);
@Deprecated
default boolean equalsIgnoringValue(@NonNull Node other) {
return equals(other, StandardNodeEquality.IGNORE_VALUE);
}
/**
* Similar to {@link Node#equals(Object)}, except doesn't take note of the value or if the node is temporary
* Similar to {@link Node#equals(Object)}, except doesn't take note of the
* expiry time or value.
*
* @param other the other node
* @return true if the two nodes are almost equal
* @see StandardNodeEquality#IGNORE_EXPIRY_TIME_AND_VALUE
* @deprecated in favour of {@link #equals(Node, NodeEqualityPredicate)}
*/
@Deprecated
default boolean almostEquals(@NonNull Node other) {
return equals(other, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
}
/**
* Similar to {@link Node#equals(Object)}, except doesn't take note of the
* value or if the node is temporary.
*
* @param other the other node
* @return true if the two nodes are almost equal
* @see StandardNodeEquality#IGNORE_VALUE_OR_IF_TEMPORARY
* @since 2.8
* @deprecated in favour of {@link #equals(Node, NodeEqualityPredicate)}
*/
boolean equalsIgnoringValueOrTemp(Node other);
@Deprecated
default boolean equalsIgnoringValueOrTemp(@NonNull Node other) {
return equals(other, StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY);
}
/**
* Constructs a new builder initially containing the current properties of
* this node.
*
* @return a new builder
* @since 4.1
*/
Builder toBuilder();
/**
* Builds a Node instance
*/
interface Builder {
Builder setNegated(boolean negated);
Builder setValue(boolean value);
/**
* Warning: this value does not persist, and disappears when the holder is re-loaded.
* It is therefore only useful for transient nodes.
* Copies the attributes from the given node and applies them to this
* builder.
*
* <p>Note that this copies all attributes <strong>except</strong> the
* permission itself.</p>
*
* @param node the node to copy from
* @return the builder
* @since 4.2
*/
Builder setOverride(boolean override);
Builder copyFrom(@NonNull Node node);
Builder setExpiry(long expireAt);
/**
* Sets the value of negated for the node.
*
* @param negated the value
* @return the builder
* @see Node#isNegated()
*/
@NonNull Builder setNegated(boolean negated);
Builder setWorld(String world);
/**
* Sets the value of the node.
*
* @param value the value
* @return the builder
* @see Node#getValue()
*/
@NonNull Builder setValue(boolean value);
Builder setServer(String server) throws IllegalArgumentException;
/**
* Sets the override property for the node.
*
* <p>Warning: this value does not persist, and disappears when the holder is re-loaded.
* It is therefore only useful for transient nodes.</p>
*
* @param override the override state
* @return the builder
* @see Node#isOverride()
*/
@NonNull Builder setOverride(boolean override);
Builder withExtraContext(String key, String value);
/**
* Sets the time when the node should expire.
*
* <p>The parameter passed to this method must be the unix timestamp
* (in seconds) when the node should expire.</p>
*
* @param expiryUnixTimestamp the expiry timestamp (unix seconds)
* @return the builder
* @see Node#getExpiryUnixTime()
*/
@NonNull Builder setExpiry(long expiryUnixTimestamp);
Builder withExtraContext(Map<String, String> map);
/**
* Sets the time when the node should expire.
*
* <p>The expiry timestamp is calculated relative to the current
* system time.</p>
*
* @param duration how long the node should be added for
* @param unit the unit <code>duration</code> is measured in
* @return the builder
* @since 4.2
*/
default @NonNull Builder setExpiry(long duration, TimeUnit unit) {
Preconditions.checkArgument(duration > 0, "duration must be positive");
long seconds = Objects.requireNonNull(unit, "unit").toSeconds(duration);
long timeNow = System.currentTimeMillis() / 1000L;
return setExpiry(timeNow + seconds);
}
Builder withExtraContext(Set<Map.Entry<String, String>> context);
/**
* Marks that the node being built should never expire.
*
* @return the builder
* @since 4.2
*/
@NonNull Builder clearExpiry();
Builder withExtraContext(Map.Entry<String, String> entry);
/**
* Sets the world value for the node.
*
* @param world the world value
* @return the builder
* @see Node#getWorld()
*/
@NonNull Builder setWorld(@Nullable String world);
Builder withExtraContext(ContextSet set);
/**
* Sets the server value for the node.
*
* @param server the world value
* @return the builder
* @see Node#getServer()
*/
@NonNull Builder setServer(@Nullable String server);
Node build();
/**
* Appends an extra context onto the node.
*
* @param key the context key
* @param value the context value
* @return the builder
* @see ContextSet
* @see Node#getContexts()
*/
@NonNull Builder withExtraContext(@NonNull String key, @NonNull String value);
/**
* Appends extra contexts onto the node.
*
* @param map a map of contexts
* @return the builder
* @see ContextSet
* @see Node#getContexts()
*/
@NonNull Builder withExtraContext(@NonNull Map<String, String> map);
/**
* Appends extra contexts onto the node.
*
* @param context a set of contexts
* @return the builder
* @see ContextSet
* @see Node#getContexts()
*/
@NonNull Builder withExtraContext(@NonNull Set<Map.Entry<String, String>> context);
/**
* Appends an extra context onto the node.
*
* @param entry the context
* @return the builder
* @see ContextSet
* @see Node#getContexts()
*/
@NonNull Builder withExtraContext(Map.@NonNull Entry<String, String> entry);
/**
* Appends extra contexts onto the node.
*
* @param contextSet a context set
* @return the builder
* @see ContextSet
* @see Node#getContexts()
*/
@NonNull Builder withExtraContext(@NonNull ContextSet contextSet);
/**
* Sets the extra contexts for the node.
*
* @param contextSet a context set
* @return the builder
* @see ContextSet
* @see Node#getContexts()
* @since 4.2
*/
@NonNull Builder setExtraContext(@NonNull ContextSet contextSet);
/**
* Creates a {@link Node} instance from the builder.
*
* @return a new node instance
*/
@NonNull Node build();
}
}
@@ -0,0 +1,55 @@
/*
* 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 me.lucko.luckperms.api;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* A rule for determining if two nodes are equal.
*
* <p>Generally, individual instances of this interface should fulfil the same
* requirements as the {@link Object#equals(Object)} contract.</p>
*
* <p>Some standard implementations are provided by {@link StandardNodeEquality}.</p>
*
* @since 4.1
*/
@FunctionalInterface
public interface NodeEqualityPredicate {
/**
* Returns if the two nodes are equal.
*
* <p>This method should avoid making calls to {@link Node#equals(Node, NodeEqualityPredicate)}
* with {@code this} as the second argument, directly or otherwise.</p>
*
* @param o1 the first node
* @param o2 the second node
* @return true if equal
*/
boolean areEqual(@NonNull Node o1, @NonNull Node o2);
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,24 +25,15 @@
package me.lucko.luckperms.api;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Builds {@link Node} instances
* Assists with constructing {@link Node} instances.
*
* @since 2.17
*/
public interface NodeFactory {
/**
* Creates a node from a serialised node string
*
* @param serialisedPermission the serialised permission string
* @param value the value of the node
* @return a node instance
* @throws NullPointerException if the permission is null
*/
Node fromSerialisedNode(String serialisedPermission, boolean value);
/**
* Creates a new node builder from a given base permission string
*
@@ -47,7 +41,7 @@ public interface NodeFactory {
* @return a node builder instance
* @throws NullPointerException if the permission is null
*/
Node.Builder newBuilder(String permission);
Node.@NonNull Builder newBuilder(@NonNull String permission);
/**
* Creates a node builder instance from an existing node
@@ -56,46 +50,70 @@ public interface NodeFactory {
* @return a node builder instance
* @throws NullPointerException if the other node is null
*/
Node.Builder newBuilderFromExisting(Node other);
Node.@NonNull Builder newBuilderFromExisting(@NonNull Node other);
/**
* Creates a node builder from a serialised node string
* @param serialisedPermission the serialised permission string
* @param value the value of the node
* Creates a node builder from a group
*
* @param group the group
* @return a node builder instance
* @throws NullPointerException if the permission is null
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @since 3.1
*/
Node.Builder newBuilderFromSerialisedNode(String serialisedPermission, boolean value);
Node.@NonNull Builder makeGroupNode(@NonNull Group group);
/**
* Creates a node builder from a group
*
* @param groupName the name of the group
* @return a node builder instance
* @throws NullPointerException if the groupName is null
* @since 4.0
*/
Node.@NonNull Builder makeGroupNode(@NonNull String groupName);
/**
* Creates a node builder from a key value pair
*
* @param key the key
* @param key the key
* @param value the value
* @return a node builder instance
* @throws NullPointerException if the key or value is null
*/
Node.Builder makeMetaNode(String key, String value);
Node.@NonNull Builder makeMetaNode(@NonNull String key, @NonNull String value);
/**
* Creates a node builder for the given chat meta type
*
* @param type the type
* @param priority the priority
* @param value the value for the prefix/suffix
* @return a node builder instance
* @throws NullPointerException if the type or value is null
* @since 3.2
*/
Node.@NonNull Builder makeChatMetaNode(@NonNull ChatMetaType type, int priority, @NonNull String value);
/**
* Creates a node builder from a prefix string and priority
*
* @param priority the priority
* @param prefix the prefix string
* @param prefix the prefix string
* @return a node builder instance
* @throws NullPointerException if the prefix is null
*/
Node.Builder makePrefixNode(int priority, String prefix);
Node.@NonNull Builder makePrefixNode(int priority, @NonNull String prefix);
/**
* Creates a node builder from a prefix string and priority
*
* @param priority the priority
* @param suffix the suffix string
* @param suffix the suffix string
* @return a node builder instance
* @throws NullPointerException if the suffix is null
*/
Node.Builder makeSuffixNode(int priority, String suffix);
Node.@NonNull Builder makeSuffixNode(int priority, @NonNull String suffix);
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,124 @@
/*
* 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 me.lucko.luckperms.api;
import me.lucko.luckperms.api.manager.UserManager;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
/**
* Encapsulates the result of an operation to save uuid data about a player.
*
* <p>The corresponding method can be found at
* {@link UserManager#savePlayerData(UUID, String)}.</p>
*
* @since 4.2
*/
public interface PlayerSaveResult {
/**
* Gets the status returned by the operation
*
* @return the status
*/
@NonNull Set<Status> getStatus();
/**
* Gets if the result includes a certain status code.
*
* @param status the status to check for
* @return if the result includes the status
*/
default boolean includes(@NonNull Status status) {
Objects.requireNonNull(status, "status");
return getStatus().contains(status);
}
/**
* Gets the old username involved in the result.
*
* <p>Returns null when the result doesn't {@link #includes(Status) include} the
* {@link Status#USERNAME_UPDATED} status.</p>
*
* @return the old username
* @see Status#USERNAME_UPDATED
*/
@Nullable String getOldUsername();
/**
* Gets the other uuids involved in the result.
*
* <p>Returns null when the result doesn't {@link #includes(Status) include} the
* {@link Status#OTHER_UUIDS_PRESENT_FOR_USERNAME} status.</p>
*
* @return the other uuids
* @see Status#OTHER_UUIDS_PRESENT_FOR_USERNAME
*/
@Nullable Set<UUID> getOtherUuids();
/**
* The various states the result can take
*/
enum Status {
/**
* There was no existing data saved for either the uuid or username
*/
CLEAN_INSERT,
/**
* There was existing data for the player, no change was needed.
*/
NO_CHANGE,
/**
* There was already a record for the UUID saved, but it was for a different username.
*
* <p>This is normal, players are able to change their usernames.</p>
*/
USERNAME_UPDATED,
/**
* There was already a record for the username saved, but it was under a different uuid.
*
* <p>This is a bit of a cause for concern. It's possible that "player1" has changed
* their username to "player2", and "player3" has changed their username to "player1".
* If the original "player1" doesn't join after changing their name, this conflict could
* occur.</p>
*
* <p>However, what's more likely is that the server is not setup to authenticate
* correctly. Usually this is a problem with BungeeCord "ip-forwarding", but could be
* that the user of the plugin is running a network off a shared database with one
* server in online mode and another in offline mode.</p>
*/
OTHER_UUIDS_PRESENT_FOR_USERNAME,
}
}
@@ -0,0 +1,127 @@
/*
* 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 me.lucko.luckperms.api;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Optional;
/**
* Encapsulates the result of {@link User}s promotion along a {@link Track}.
*
* @since 4.2
*/
public interface PromotionResult extends MutateResult {
/**
* Gets the status of the result.
*
* @return the status
*/
@NonNull Status getStatus();
@Override
default boolean wasSuccess() {
return getStatus().wasSuccess();
}
/**
* Gets the name of the group the user was promoted from, if applicable.
*
* <p>Will only be present for results with a {@link #getStatus() status} of
* {@link Status#SUCCESS}.</p>
*
* @return the group the user was promoted from.
*/
@NonNull Optional<String> getGroupFrom();
/**
* Gets the name of the group the user was promoted from, if applicable.
*
* <p>Will only be present for results with a {@link #getStatus() status} of
* {@link Status#SUCCESS} or {@link Status#ADDED_TO_FIRST_GROUP}.</p>
*
* <p>The value will also be set for results with the {@link Status#MALFORMED_TRACK} status,
* with this value marking the group which no longer exists.</p>
*
* @return the group the user was promoted to.
*/
@NonNull Optional<String> getGroupTo();
/**
* The result status
*/
enum Status implements MutateResult {
/**
* Indicates that the user was promoted normally.
*/
SUCCESS(true),
/**
* Indicates that the user was added to the first group in the track.
*
* <p>This usually occurs when the user isn't already on any of the groups in the track.</p>
*/
ADDED_TO_FIRST_GROUP(true),
/**
* Indicates that the next group in the track no longer exists.
*/
MALFORMED_TRACK(false),
/**
* Indicates that the user is already a member of the group at the end of the track,
* and as such cannot be promoted any further.
*/
END_OF_TRACK(false),
/**
* Indicates that the implementation was unable to determine the users current position on
* this track.
*
* <p>This usually occurs when the user is on more than one group on the track.</p>
*/
AMBIGUOUS_CALL(false),
/**
* An undefined failure occurred.
*/
UNDEFINED_FAILURE(false);
private final boolean success;
Status(boolean success) {
this.success = success;
}
@Override
public boolean wasSuccess() {
return this.success;
}
}
}
@@ -0,0 +1,78 @@
/*
* 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 me.lucko.luckperms.api;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Standard {@link NodeEqualityPredicate}s.
*
* @since 4.1
*/
public enum StandardNodeEquality implements NodeEqualityPredicate {
/**
* Represents an exact match.
*
* <p>All attributes of the nodes must match for them to be considered
* equal.</p>
*/
EXACT,
/**
* All attributes must match, except for
* {@link Node#getValue() value}, which is ignored.
*/
IGNORE_VALUE,
/**
* All attributes must match, except for the
* {@link Node#getExpiry() expiry time}, which is ignored.
*
* <p>Note that with this setting, whether a node is temporary or not is
* still considered.</p>
*/
IGNORE_EXPIRY_TIME,
/**
* All attributes must match, except for
* {@link Node#getValue() value} and the
* {@link Node#getExpiry() expiry time}, which are ignored.
*/
IGNORE_EXPIRY_TIME_AND_VALUE,
/**
* All attributes must match, except for
* {@link Node#getValue() value} and the if the node is
* {@link Node#isTemporary() temporary}, which are ignored.
*/
IGNORE_VALUE_OR_IF_TEMPORARY;
@Override
public boolean areEqual(@NonNull Node o1, @NonNull Node o2) {
return o1.equals(o2, this);
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,23 +25,21 @@
package me.lucko.luckperms.api;
import me.lucko.luckperms.api.manager.GroupManager;
import me.lucko.luckperms.api.manager.TrackManager;
import me.lucko.luckperms.api.manager.UserManager;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
/**
* A means of loading and saving data to/from the Storage provider.
*
* <p>All methods return {@link CompletableFuture}s, which will be populated with the result once the data has been
* loaded asynchronously. Care should be taken when using the methods to ensure that the main server thread is not
* blocked.
*
* <p>Methods such as {@link CompletableFuture#get()} and equivalent should <strong>not</strong> be called on the main
* server thread. If you need to use the result of these operations on the main server thread, please register a
* callback using {@link CompletableFuture#thenAcceptAsync(Consumer, Executor)} and {@link #getSyncExecutor()}.
* A means of loading and saving permission data to/from the backend.
*
* @since 2.14
*/
@@ -49,81 +50,86 @@ public interface Storage {
*
* @return the name of the implementation
*/
String getName();
@NonNull String getName();
/**
* Return whether the storage instance is allowing logins on the platform.
* Gets whether the storage instance is allowing logins on the platform.
*
* @return true if logins are enabled
* @deprecated as this method always returns true.
*/
@Deprecated
boolean isAcceptingLogins();
/**
* Returns an executor which will run all passed runnables on the main server thread.
*
* @return an executor instance
*/
Executor getSyncExecutor();
/**
* Returns an executor which will run all passed runnables asynchronously using the platforms scheduler and thread
* pools.
*
* @return an executor instance
*/
Executor getAsyncExecutor();
/**
* Saves an action to storage
*
* @param entry the log entry to be saved
* @return true if the operation completed successfully.
* @throws NullPointerException if entry is null
* @deprecated in favour of {@link ActionLogger#submit(LogEntry)}.
*/
CompletableFuture<Boolean> logAction(LogEntry entry);
@Deprecated
@NonNull CompletableFuture<Boolean> logAction(@NonNull LogEntry entry);
/**
* Loads and returns the entire log from storage
*
* @return a log instance, could be null if loading failed
* @deprecated in favour of {@link ActionLogger#getLog()}
*/
CompletableFuture<Log> getLog();
@Deprecated
@NonNull CompletableFuture<Log> getLog();
/**
* Loads a user's data from the main storage into the plugins local storage.
*
* @param uuid the uuid of the user to load
* @param username the users username. (if you want to specify <code>null</code> here, just input "null" as a
* string.)
* @param username the users username, or null if it is not known.
* @return if the operation completed successfully
* @throws NullPointerException if uuid or username is null
* @throws NullPointerException if uuid is null
* @deprecated in favour of {@link UserManager#loadUser(UUID, String)}
*/
CompletableFuture<Boolean> loadUser(UUID uuid, String username);
@Deprecated
@NonNull CompletableFuture<Boolean> loadUser(@NonNull UUID uuid, @Nullable String username);
/**
* Saves a user object back to storage. You should call this after you make any changes to a user.
* Loads a user's data from the main storage into the plugins local storage.
*
* @param uuid the uuid of the user to load
* @return if the operation completed successfully
* @throws NullPointerException if uuid is null
* @deprecated in favour of {@link UserManager#loadUser(UUID)}
*/
@Deprecated
default @NonNull CompletableFuture<Boolean> loadUser(@NonNull UUID uuid) {
return loadUser(uuid, null);
}
/**
* Saves a user object back to storage.
*
* <p>You should call this after you make any changes to a user.</p>
*
* @param user the user to save
* @return true if the operation completed successfully.
* @throws NullPointerException if user is null
* @throws IllegalStateException if the user instance was not obtained from LuckPerms.
* @deprecated in favour of {@link UserManager#saveUser(User)}
*/
CompletableFuture<Boolean> saveUser(User user);
/**
* Removes users from the main storage who are "default". This is called every time the plugin loads.
*
* @return true if the operation completed successfully
*/
CompletableFuture<Boolean> cleanupUsers();
@Deprecated
@NonNull CompletableFuture<Boolean> saveUser(@NonNull User user);
/**
* Gets a set all "unique" user UUIDs.
* "Unique" meaning the user isn't just a member of the "default" group.
*
* <p>"Unique" meaning the user isn't just a member of the "default" group.</p>
*
* @return a set of uuids, or null if the operation failed.
* @deprecated in favour of {@link UserManager#getUniqueUsers()}
*/
CompletableFuture<Set<UUID>> getUniqueUsers();
@Deprecated
@NonNull CompletableFuture<Set<UUID>> getUniqueUsers();
/**
* Searches for a list of users with a given permission.
@@ -132,8 +138,10 @@ public interface Storage {
* @return a list of held permissions, or null if the operation failed
* @throws NullPointerException if the permission is null
* @since 2.17
* @deprecated in favour of {@link UserManager#getWithPermission(String)}
*/
CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(String permission);
@Deprecated
@NonNull CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(@NonNull String permission);
/**
* Creates and loads a group into the plugins local storage
@@ -142,8 +150,10 @@ public interface Storage {
* @return true if the operation completed successfully
* @throws NullPointerException if name is null
* @throws IllegalArgumentException if the name is invalid
* @deprecated in favour of {@link GroupManager#createAndLoadGroup(String)}
*/
CompletableFuture<Boolean> createAndLoadGroup(String name);
@Deprecated
@NonNull CompletableFuture<Boolean> createAndLoadGroup(@NonNull String name);
/**
* Loads a group into the plugins local storage.
@@ -152,25 +162,33 @@ public interface Storage {
* @return true if the operation completed successfully
* @throws NullPointerException if name is null
* @throws IllegalArgumentException if the name is invalid
* @deprecated in favour of {@link GroupManager#loadGroup(String)}
*/
CompletableFuture<Boolean> loadGroup(String name);
@Deprecated
@NonNull CompletableFuture<Boolean> loadGroup(@NonNull String name);
/**
* Loads all groups from the storage into memory
*
* @return true if the operation completed successfully.
* @deprecated in favour of {@link GroupManager#loadAllGroups()}
*/
CompletableFuture<Boolean> loadAllGroups();
@Deprecated
@NonNull CompletableFuture<Boolean> loadAllGroups();
/**
* Saves a group back to storage. You should call this after you make any changes to a group.
* Saves a group back to storage.
*
* <p>You should call this after you make any changes to a group.</p>
*
* @param group the group to save
* @return true if the operation completed successfully.
* @throws NullPointerException if group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @deprecated in favour of {@link GroupManager#saveGroup(Group)}
*/
CompletableFuture<Boolean> saveGroup(Group group);
@Deprecated
@NonNull CompletableFuture<Boolean> saveGroup(@NonNull Group group);
/**
* Permanently deletes a group from storage.
@@ -179,8 +197,10 @@ public interface Storage {
* @return true if the operation completed successfully.
* @throws NullPointerException if group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @deprecated in favour of {@link GroupManager#deleteGroup(Group)}
*/
CompletableFuture<Boolean> deleteGroup(Group group);
@Deprecated
@NonNull CompletableFuture<Boolean> deleteGroup(@NonNull Group group);
/**
* Searches for a list of groups with a given permission.
@@ -189,8 +209,10 @@ public interface Storage {
* @return a list of held permissions, or null if the operation failed
* @throws NullPointerException if the permission is null
* @since 2.17
* @deprecated in favour of {@link GroupManager#getWithPermission(String)}
*/
CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(String permission);
@Deprecated
@NonNull CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(@NonNull String permission);
/**
* Creates and loads a track into the plugins local storage
@@ -199,8 +221,10 @@ public interface Storage {
* @return true if the operation completed successfully
* @throws NullPointerException if name is null
* @throws IllegalArgumentException if the name is invalid
* @deprecated in favour of {@link TrackManager#createAndLoadTrack(String)}
*/
CompletableFuture<Boolean> createAndLoadTrack(String name);
@Deprecated
@NonNull CompletableFuture<Boolean> createAndLoadTrack(@NonNull String name);
/**
* Loads a track into the plugins local storage.
@@ -209,15 +233,19 @@ public interface Storage {
* @return true if the operation completed successfully
* @throws NullPointerException if name is null
* @throws IllegalArgumentException if the name is invalid
* @deprecated in favour of {@link TrackManager#loadTrack(String)}
*/
CompletableFuture<Boolean> loadTrack(String name);
@Deprecated
@NonNull CompletableFuture<Boolean> loadTrack(@NonNull String name);
/**
* Loads all tracks from the storage into memory
*
* @return true if the operation completed successfully.
* @deprecated in favour of {@link TrackManager#loadAllTracks()}
*/
CompletableFuture<Boolean> loadAllTracks();
@Deprecated
@NonNull CompletableFuture<Boolean> loadAllTracks();
/**
* Saves a track back to storage. You should call this after you make any changes to a track.
@@ -226,8 +254,10 @@ public interface Storage {
* @return true if the operation completed successfully.
* @throws NullPointerException if track is null
* @throws IllegalStateException if the track instance was not obtained from LuckPerms.
* @deprecated in favour of {@link TrackManager#saveTrack(Track)}
*/
CompletableFuture<Boolean> saveTrack(Track track);
@Deprecated
@NonNull CompletableFuture<Boolean> saveTrack(@NonNull Track track);
/**
* Permanently deletes a track from storage
@@ -236,8 +266,10 @@ public interface Storage {
* @return true if the operation completed successfully.
* @throws NullPointerException if track is null
* @throws IllegalStateException if the track instance was not obtained from LuckPerms.
* @deprecated in favour of {@link TrackManager#deleteTrack(Track)}
*/
CompletableFuture<Boolean> deleteTrack(Track track);
@Deprecated
@NonNull CompletableFuture<Boolean> deleteTrack(@NonNull Track track);
/**
* Saves UUID caching data to the global cache
@@ -247,8 +279,9 @@ public interface Storage {
* @return true if the operation completed successfully.
* @throws NullPointerException if either parameters are null
* @throws IllegalArgumentException if the username is invalid
* @deprecated in favour of {@link UserManager#savePlayerData(UUID, String)}
*/
CompletableFuture<Boolean> saveUUIDData(String username, UUID uuid);
@NonNull CompletableFuture<Boolean> saveUUIDData(@NonNull String username, @NonNull UUID uuid);
/**
* Gets a UUID from a username
@@ -257,8 +290,9 @@ public interface Storage {
* @return a uuid object, could be null
* @throws NullPointerException if either parameters are null
* @throws IllegalArgumentException if the username is invalid
* @deprecated in favour of {@link UserManager#lookupUuid(String)}
*/
CompletableFuture<UUID> getUUID(String username);
@NonNull CompletableFuture<UUID> getUUID(@NonNull String username);
/**
* Gets a username from a UUID
@@ -267,7 +301,32 @@ public interface Storage {
* @return a name string, could be null
* @throws NullPointerException if either parameters are null
* @since 2.17
* @deprecated in favour of {@link UserManager#lookupUsername(UUID)}
*/
CompletableFuture<String> getName(UUID uuid);
@NonNull @Deprecated CompletableFuture<String> getName(@NonNull UUID uuid);
/**
* Returns an executor which will run all passed runnables on the
* main server thread.
*
* <p>This method is deprecated as plugins should create and use their own
* executor instances.</p>
*
* @return an executor instance
* @deprecated as plugins should create their own executors
*/
@NonNull @Deprecated Executor getSyncExecutor();
/**
* Returns an executor which will run all passed runnables asynchronously
* using the platforms scheduler and thread pools.
*
* <p>This method is deprecated as plugins should create and use their own
* executor instances.</p>
*
* @return an executor instance
* @deprecated as plugins should create their own executors
*/
@NonNull @Deprecated Executor getAsyncExecutor();
}
@@ -0,0 +1,55 @@
/*
* 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 me.lucko.luckperms.api;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Extension of {@link DataMutateResult} for temporary set operations.
*
* @since 4.3
*/
public interface TemporaryDataMutateResult {
/**
* Gets the underlying result.
*
* @return the result
*/
@NonNull DataMutateResult getResult();
/**
* Gets the node that resulted from any {@link TemporaryMergeBehaviour}
* processing.
*
* <p>If no processing took place, the same instance will be returned by
* this method.</p>
*
* @return the resultant node
*/
@NonNull Node getMergedNode();
}
@@ -0,0 +1,58 @@
/*
* 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 me.lucko.luckperms.api;
/**
* Controls how the implementation should behave when new temporary nodes are set
* that would otherwise conflict with existing entries.
*
* <p>The default behaviour of {@link PermissionHolder#setPermission(Node)} is
* to return a result of {@link DataMutateResult#ALREADY_HAS} when an equivalent
* node is found. This can be replicated using {@link #FAIL_WITH_ALREADY_HAS}.</p>
*
* <p>However, the {@link PermissionHolder#setPermission(Node, TemporaryMergeBehaviour)}
* method allows this behaviour to be customized for temporary permissions.</p>
*
* @since 4.3
*/
public enum TemporaryMergeBehaviour {
/**
* Expiry durations will be added to the existing expiry time of a permission.
*/
ADD_NEW_DURATION_TO_EXISTING,
/**
* Expiry durations will be replaced if the new duration is longer than the current one.
*/
REPLACE_EXISTING_IF_DURATION_LONGER,
/**
* The operation will fail if an existing temporary node is present.
*/
FAIL_WITH_ALREADY_HAS
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,30 +25,35 @@
package me.lucko.luckperms.api;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException;
import me.lucko.luckperms.api.context.ContextSet;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.List;
/**
* An ordered collection of groups for easy promotions and demotions
* An ordered chain of {@link Group}s.
*/
public interface Track {
/**
* Gets the name of this track
*
* @return the name of this track
*/
String getName();
@NonNull String getName();
/**
* Gets an ordered list of the groups on this track
* Gets a list of the groups on this track
*
* <p> Index 0 is the first/lowest group in (or start of) the track
* <p>Index 0 is the first/lowest group in (or start of) the track.</p>
*
* <p>The returned collection is immutable, and cannot be modified.</p>
*
* @return an ordered {@link List} of the groups on this track
*/
List<String> getGroups();
@NonNull List<String> getGroups();
/**
* Gets the number of groups on this track
@@ -57,65 +65,87 @@ public interface Track {
/**
* Gets the next group on the track, after the one provided
*
* <p>{@code null} is returned if the group is not on the track.</p>
*
* @param current the group before the group being requested
* @return the group name, or null if the end of the track has been reached
* @throws ObjectLacksException if the track does not contain the group given
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
String getNext(Group current) throws ObjectLacksException;
@Nullable String getNext(@NonNull Group current);
/**
* Gets the previous group on the track, before the one provided
*
* <p>{@code null} is returned if the group is not on the track.</p>
*
* @param current the group after the group being requested
* @return the group name, or null if the start of the track has been reached
* @throws ObjectLacksException if the track does not contain the group given
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
String getPrevious(Group current) throws ObjectLacksException;
@Nullable String getPrevious(@NonNull Group current);
/**
* Promotes the given user along this track.
*
* @param user the user to promote
* @param contextSet the contexts to promote the user in
* @return the result of the action
* @since 4.2
*/
@NonNull PromotionResult promote(@NonNull User user, @NonNull ContextSet contextSet);
/**
* Demotes the given user along this track.
*
* @param user the user to demote
* @param contextSet the contexts to demote the user in
* @return the result of the action
* @since 4.2
*/
@NonNull DemotionResult demote(@NonNull User user, @NonNull ContextSet contextSet);
/**
* Appends a group to the end of this track
*
* @param group the group to append
* @throws ObjectAlreadyHasException if the group is already on this track somewhere
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @return the result of the operation
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
void appendGroup(Group group) throws ObjectAlreadyHasException;
@NonNull DataMutateResult appendGroup(@NonNull Group group);
/**
* Inserts a group at a certain position on this track
*
* @param group the group to be inserted
* @param position the index position (a value of 0 inserts at the start)
* @throws ObjectAlreadyHasException if the group is already on this track somewhere
* @return the result of the operation
* @throws IndexOutOfBoundsException if the position is less than 0 or greater than the size of the track
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
void insertGroup(Group group, int position) throws ObjectAlreadyHasException, IndexOutOfBoundsException;
@NonNull DataMutateResult insertGroup(@NonNull Group group, int position) throws IndexOutOfBoundsException;
/**
* Removes a group from this track
*
* @param group the group to remove
* @throws ObjectLacksException if the group is not on this track
* @return the result of the operation
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
void removeGroup(Group group) throws ObjectLacksException;
@NonNull DataMutateResult removeGroup(@NonNull Group group);
/**
* Removes a group from this track
*
* @param group the group to remove
* @throws ObjectLacksException if the group is not on this track
* @return the result of the operation
* @throws NullPointerException if the group is null
*/
void removeGroup(String group) throws ObjectLacksException;
@NonNull DataMutateResult removeGroup(@NonNull String group);
/**
* Checks if a group features on this track
@@ -125,7 +155,7 @@ public interface Track {
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
boolean containsGroup(Group group);
boolean containsGroup(@NonNull Group group);
/**
* Checks if a group features on this track
@@ -134,7 +164,7 @@ public interface Track {
* @return true if the group is on this track
* @throws NullPointerException if the group is null
*/
boolean containsGroup(String group);
boolean containsGroup(@NonNull String group);
/**
* Clear all of the groups from this track
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,37 +25,59 @@
package me.lucko.luckperms.api;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Represents a permission setting.
* Represents three different states of a setting.
*
* <p> Consider a value of {@link #FALSE} to be a "negated" setting, and a value of {@link #UNDEFINED} to be a
* non-existent value.
* <p>Possible values:</p>
* <p></p>
* <ul>
* <li>{@link #TRUE} - a positive setting</li>
* <li>{@link #FALSE} - a negative (negated) setting</li>
* <li>{@link #UNDEFINED} - a non-existent setting</li>
* </ul>
*/
public enum Tristate {
/**
* A value indicating a holder has a permission set.
* A value indicating a positive setting
*/
TRUE(true),
/**
* A value indicating a holder has a negated value for a permission.
* A value indicating a negative (negated) setting
*/
FALSE(false),
/**
* A value indicating a holder doesn't have a value for a permission set.
* A value indicating a non-existent setting
*/
UNDEFINED(false);
/**
* Converts from {@link Boolean} a boolean
* Returns a {@link Tristate} from a boolean
*
* @param b the boolean
* @return {@link #TRUE} or {@link #FALSE}, depending on the value of the boolean.
* @param val the boolean value
* @return {@link #TRUE} or {@link #FALSE}, if the value is <code>true</code> or <code>false</code>, respectively.
*/
public static Tristate fromBoolean(boolean b) {
return b ? TRUE : FALSE;
public static @NonNull Tristate fromBoolean(boolean val) {
return val ? TRUE : FALSE;
}
/**
* Returns a {@link Tristate} from a nullable boolean.
*
* <p>Unlike {@link #fromBoolean(boolean)}, this method returns {@link #UNDEFINED}
* if the value is null.</p>
*
* @param val the boolean value
* @return {@link #UNDEFINED}, {@link #TRUE} or {@link #FALSE}, if the value
* is <code>null</code>, <code>true</code> or <code>false</code>, respectively.
* @since 4.1
*/
public static @NonNull Tristate fromNullableBoolean(Boolean val) {
return val == null ? UNDEFINED : val ? TRUE : FALSE;
}
private final boolean booleanValue;
@@ -63,11 +88,12 @@ public enum Tristate {
/**
* Returns the value of the Tristate as a boolean.
* <p> A value of {@link #UNDEFINED} converts to false.
*
* <p>A value of {@link #UNDEFINED} converts to false.</p>
*
* @return a boolean representation of the Tristate.
*/
public boolean asBoolean() {
return booleanValue;
return this.booleanValue;
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -23,15 +26,14 @@
package me.lucko.luckperms.api;
import me.lucko.luckperms.api.caching.UserData;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException;
import java.util.List;
import java.util.Optional;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.UUID;
/**
* A player holding permission data
* A player which holds permission data.
*/
public interface User extends PermissionHolder {
@@ -40,260 +42,67 @@ public interface User extends PermissionHolder {
*
* @return the users Mojang assigned unique id
*/
UUID getUuid();
@NonNull UUID getUuid();
/**
* Gets the users username
*
* @return the Users Username
* <p>Returns null if no username is known for the user.</p>
*
* @return the users username
*/
String getName();
@Nullable String getName();
/**
* Gets the users primary group
* Gets the users current primary group.
*
* <p>The result of this method depends on which method is configured for primary group
* calculation. It may not be the same as any value set through
* {@link #setPrimaryGroup(String)}.</p>
*
* @return the users primary group
*/
String getPrimaryGroup();
@NonNull String getPrimaryGroup();
/**
* Sets a users primary group
* Sets a users primary group.
*
* <p>This modifies the "stored value" for the users primary group, which may or may not
* actually take effect, depending on how the platform is calculating primary groups.</p>
*
* @param group the new primary group
* @throws ObjectAlreadyHasException if the user already has this set as their primary group
* @throws IllegalStateException if the user is not a member of that group
* @throws NullPointerException if the group is null
* @return if the change was applied successfully
* @throws IllegalStateException if the user is not a member of that group
* @throws NullPointerException if the group is null
*/
void setPrimaryGroup(String group) throws ObjectAlreadyHasException;
@NonNull DataMutateResult setPrimaryGroup(@NonNull String group);
/**
* Gets the user's {@link UserData} cache.
*
* @return the users cached data.
* @since 3.2
*/
@Override
@NonNull UserData getCachedData();
/**
* Refresh and re-assign the users permissions.
*
* <p> This request is not buffered, and the refresh call will be ran directly. This should ideally be called on
* an asynchronous thread.
* @deprecated Calling this method is no longer necessary. Permissions data is now refreshed on
* demand, as changes are made. Consider use of {@link #refreshCachedData()}
* instead. This method is now implemented as a no-op.
*/
@Deprecated
void refreshPermissions();
/**
* Gets the user's {@link UserData} cache, if they have one setup.
*
* @return an optional, possibly containing the user's cached lookup data.
* @since 2.13
*/
Optional<UserData> getUserDataCache();
/**
* Sets up the users data cache, if the don't have one setup already.
* Pre-calculates some values in the user's data cache.
*
* @since 2.17
* @deprecated Use of this method is no longer necessary. It is implemented as a no-op.
*/
@Deprecated
void setupDataCache();
/**
* Check to see if the user is a member of a group
*
* @param group The group to check membership of
* @return true if the user is a member of the group
* @throws NullPointerException if the group is null
*/
boolean isInGroup(Group group);
/**
* Check to see if a user is a member of a group on a specific server
*
* @param group The group to check membership of
* @param server The server to check on
* @return true if the user is a member of the group
* @throws NullPointerException if the group or server is null
* @throws IllegalArgumentException if the server is invalid
*/
boolean isInGroup(Group group, String server);
/**
* Check to see if a user is a member of a group on a specific server and world
*
* @param group The group to check membership of
* @param server The server to check on
* @param world The world to check on
* @return true if the user is a member of the group
* @throws NullPointerException if the group, server or world is null
* @throws IllegalArgumentException if the server or world is invalid
*/
boolean isInGroup(Group group, String server, String world);
/**
* Add a user to a group
*
* @param group The group to add the user to
* @throws ObjectAlreadyHasException if the user is already a member of the group
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
void addGroup(Group group) throws ObjectAlreadyHasException;
/**
* Add a user to a group on a specific server
*
* @param group The group to add the user to
* @param server The server to add the group on
* @throws ObjectAlreadyHasException if the user is already a member of the group on that server
* @throws NullPointerException if the group or server is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the server is invalid
*/
void addGroup(Group group, String server) throws ObjectAlreadyHasException;
/**
* Add a user to a group on a specific server and world
*
* @param group The group to add the user to
* @param server The server to add the group on
* @param world The world to add the group on
* @throws ObjectAlreadyHasException if the user is already a member of the group on that server
* @throws NullPointerException if the group, server or world is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the server or world is invalid
*/
void addGroup(Group group, String server, String world) throws ObjectAlreadyHasException;
/**
* Add a user to a group temporarily on a specific server
*
* @param group The group to add the user to
* @param expireAt when the group should expire
* @throws ObjectAlreadyHasException if the user is already a member of the group on that server
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the expiry time is in the past
*/
void addGroup(Group group, long expireAt) throws ObjectAlreadyHasException;
/**
* Add a user to a group temporarily on a specific server
*
* @param group The group to add the user to
* @param server The server to add the group on
* @param expireAt when the group should expire
* @throws ObjectAlreadyHasException if the user is already a member of the group on that server
* @throws NullPointerException if the group or server is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the expiry time is in the past or the server is invalid
*/
void addGroup(Group group, String server, long expireAt) throws ObjectAlreadyHasException;
/**
* Add a user to a group temporarily on a specific server and world
*
* @param group The group to add the user to
* @param server The server to add the group on
* @param world The world to add the group on
* @param expireAt when the group should expire
* @throws ObjectAlreadyHasException if the user is already a member of the group on that server
* @throws NullPointerException if the group, server or world is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the expiry time is in the past or the server/world is invalid
*/
void addGroup(Group group, String server, String world, long expireAt) throws ObjectAlreadyHasException;
/**
* Remove the user from a group
*
* @param group the group to remove the user from
* @throws ObjectLacksException if the user isn't a member of the group
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
void removeGroup(Group group) throws ObjectLacksException;
/**
* Remove the user from a group
*
* @param group the group to remove the user from
* @param temporary if the group being removed is temporary
* @throws ObjectLacksException if the user isn't a member of the group
* @throws NullPointerException if the group is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
*/
void removeGroup(Group group, boolean temporary) throws ObjectLacksException;
/**
* Remove the user from a group on a specific server
*
* @param group The group to remove the user from
* @param server The server to remove the group on
* @throws ObjectLacksException if the user isn't a member of the group
* @throws NullPointerException if the group or server is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the server is invalid
*/
void removeGroup(Group group, String server) throws ObjectLacksException;
/**
* Remove the user from a group on a specific server and world
*
* @param group The group to remove the user from
* @param server The server to remove the group on
* @param world The world to remove the group on
* @throws ObjectLacksException if the user isn't a member of the group
* @throws NullPointerException if the group, server or world is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the server or world is invalid
*/
void removeGroup(Group group, String server, String world) throws ObjectLacksException;
/**
* Remove the user from a group on a specific server
*
* @param group The group to remove the user from
* @param server The server to remove the group on
* @param temporary if the group being removed is temporary
* @throws ObjectLacksException if the user isn't a member of the group
* @throws NullPointerException if the group or server is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the expiry time is in the past or the server is invalid
*/
void removeGroup(Group group, String server, boolean temporary) throws ObjectLacksException;
/**
* Remove the user from a group on a specific server and world
*
* @param group The group to remove the user from
* @param server The server to remove the group on
* @param world The world to remove the group on
* @param temporary if the group being removed is temporary
* @throws ObjectLacksException if the user isn't a member of the group
* @throws NullPointerException if the group, server or world is null
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
* @throws IllegalArgumentException if the expiry time is in the past or the server/world is invalid
*/
void removeGroup(Group group, String server, String world, boolean temporary) throws ObjectLacksException;
/**
* Get a {@link List} of all of the groups the user is a member of, on all servers
*
* @return a {@link List} of group names
*/
List<String> getGroupNames();
/**
* Get a {@link List} of the groups the user is a member of on a specific server
*
* @param server the server to check
* @param world the world to check
* @return a {@link List} of group names
* @throws NullPointerException if the server or world is null
* @throws IllegalArgumentException if the server or world is invalid
*/
List<String> getLocalGroups(String server, String world);
/**
* Get a {@link List} of the groups the user is a member of on a specific server
*
* @param server the server to check
* @return a {@link List} of group names
* @throws NullPointerException if the server is null
* @throws IllegalArgumentException if the server is invalid
*/
List<String> getLocalGroups(String server);
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,37 +25,43 @@
package me.lucko.luckperms.api;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.UUID;
/**
* A UUID cache for online users, between external Mojang UUIDs, and internal LuckPerms UUIDs.
* A UUID cache for online users, between external Mojang UUIDs, and internal
* LuckPerms UUIDs.
*
* <p> This UuidCache is a means of allowing users to have the same internal UUID across a network of offline mode
* servers or mixed offline mode and online mode servers. Platforms running in offline mode generate a UUID for a
* user when they first join the server, but this UUID will then not be consistent across the network. LuckPerms will
* instead check the datastore cache, to get a UUID for a user that is consistent across an entire network.
*
* <p> If you want to get a user object from the Storage using the api on a server in offline mode, you will need to use
* this cache, OR use Storage#getUUID, for users that are not online.
*
* <p> THIS IS ONLY EFFECTIVE FOR ONLINE PLAYERS. USE THE DATASTORE METHODS FOR OFFLINE PLAYERS.
* @deprecated this feature is now handled internally - and the API returns a
* No-op implementation of this class.
*/
@Deprecated
public interface UuidCache {
/**
* Gets a users internal "LuckPerms" UUID, from the one given by the server.
* Gets a users "internal" LuckPerms UUID, from the one given by the server.
*
* @param external the UUID assigned by the server, through Player#getUniqueId or ProxiedPlayer#getUniqueId
* <p>When <code>use-server-uuids</code> is true, this returns the same UUID
* instance.</p>
*
* @param mojangUuid the UUID assigned by the server, through
* <code>Player#getUniqueId</code> or
* <code>ProxiedPlayer#getUniqueId</code>
* @return the corresponding internal UUID
*/
UUID getUUID(UUID external);
@Deprecated
@NonNull UUID getUUID(@NonNull UUID mojangUuid);
/**
* Gets a users external, server assigned or Mojang assigned unique id, from the internal one used within LuckPerms.
* Gets a users "external", server assigned unique id, from the internal
* one used within LuckPerms.
*
* @param internal the UUID used within LuckPerms, through User#getUuid
* @param internalUuid the UUID used within LuckPerms, through
* <code>User#getUuid</code>
* @return the corresponding external UUID
*/
UUID getExternalUUID(UUID internal);
@Deprecated
@NonNull UUID getExternalUUID(@NonNull UUID internalUuid);
}
@@ -0,0 +1,422 @@
/*
* 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 me.lucko.luckperms.api.caching;
import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.PermissionHolder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
/**
* Holds cached permission and meta lookup data for a {@link PermissionHolder}.
*
* <p>All calls will account for inheritance, as well as any default data
* provided by the platform. This calls are heavily cached and are therefore
* fast.</p>
*
* <p>For meta, both methods accepting {@link Contexts} and {@link MetaContexts}
* are provided. The only difference is that the latter allows you to define
* how the meta stack should be structured internally. Where {@link Contexts}
* are passed, the values from the configuration are used.</p>
*
* @since 4.0
*/
public interface CachedData {
/**
* Gets PermissionData from the cache, given a specified context.
*
* @param contexts the contexts to get the permission data in
* @return a permission data instance
* @throws NullPointerException if contexts is null
*/
@NonNull PermissionData getPermissionData(@NonNull Contexts contexts);
/**
* Gets MetaData from the cache, given a specified context.
*
* @param contexts the contexts to get the permission data in
* @return a meta data instance
* @throws NullPointerException if contexts is null
* @since 3.2
*/
@NonNull MetaData getMetaData(@NonNull MetaContexts contexts);
/**
* Gets MetaData from the cache, given a specified context.
*
* @param contexts the contexts to get the permission data in
* @return a meta data instance
* @throws NullPointerException if contexts is null
*/
@NonNull MetaData getMetaData(@NonNull Contexts contexts);
/**
* Calculates permission data, bypassing the cache.
*
* <p>The result of this operation is calculated each time the method is called.
* The result is not added to the internal cache.</p>
*
* <p>It is therefore highly recommended to use {@link #getPermissionData(Contexts)} instead.</p>
*
* <p>The use cases of this method are more around constructing one-time
* instances of {@link PermissionData}, without adding the result to the cache.</p>
*
* @param contexts the contexts to get permission data in
* @return a permission data instance
* @throws NullPointerException if contexts is null
*/
@NonNull PermissionData calculatePermissions(@NonNull Contexts contexts);
/**
* Calculates meta data, bypassing the cache.
*
* <p>The result of this operation is calculated each time the method is called.
* The result is not added to the internal cache.</p>
*
* <p>It is therefore highly recommended to use {@link #getMetaData(MetaContexts)} instead.</p>
*
* <p>The use cases of this method are more around constructing one-time
* instances of {@link MetaData}, without adding the result to the cache.</p>
*
* @param contexts the contexts to get meta data in
* @return a meta data instance
* @throws NullPointerException if contexts is null
* @since 3.2
*/
@NonNull MetaData calculateMeta(@NonNull MetaContexts contexts);
/**
* Calculates meta data, bypassing the cache.
*
* <p>The result of this operation is calculated each time the method is called.
* The result is not added to the internal cache.</p>
*
* <p>It is therefore highly recommended to use {@link #getMetaData(Contexts)} instead.</p>
*
* <p>The use cases of this method are more around constructing one-time
* instances of {@link MetaData}, without adding the result to the cache.</p>
*
* @param contexts the contexts to get meta data in
* @return a meta data instance
* @throws NullPointerException if contexts is null
*/
@NonNull MetaData calculateMeta(@NonNull Contexts contexts);
/**
* (Re)calculates permission data for a given context.
*
* <p>This method returns immediately in all cases. The (re)calculation is
* performed asynchronously and applied to the cache in the background.</p>
*
* <p>If there was a previous {@link PermissionData} instance associated with
* the given {@link Contexts}, then that instance will continue to be returned by
* {@link #getPermissionData(Contexts)} until the recalculation is completed.</p>
*
* <p>If there was no value calculated and cached prior to the call of this
* method, then one will be calculated.</p>
*
* @param contexts the contexts to recalculate in.
* @throws NullPointerException if contexts is null
*/
void recalculatePermissions(@NonNull Contexts contexts);
/**
* (Re)calculates meta data for a given context.
*
* <p>This method returns immediately in all cases. The (re)calculation is
* performed asynchronously and applied to the cache in the background.</p>
*
* <p>If there was a previous {@link MetaData} instance associated with
* the given {@link MetaContexts}, then that instance will continue to be returned by
* {@link #getMetaData(MetaContexts)} until the recalculation is completed.</p>
*
* <p>If there was no value calculated and cached prior to the call of this
* method, then one will be calculated.</p>
*
* @param contexts the contexts to recalculate in.
* @throws NullPointerException if contexts is null
* @since 3.2
*/
void recalculateMeta(@NonNull MetaContexts contexts);
/**
* (Re)calculates meta data for a given context.
*
* <p>This method returns immediately in all cases. The (re)calculation is
* performed asynchronously and applied to the cache in the background.</p>
*
* <p>If there was a previous {@link MetaData} instance associated with
* the given {@link Contexts}, then that instance will continue to be returned by
* {@link #getMetaData(Contexts)} until the recalculation is completed.</p>
*
* <p>If there was no value calculated and cached prior to the call of this
* method, then one will be calculated.</p>
*
* @param contexts the contexts to recalculate in.
* @throws NullPointerException if contexts is null
*/
void recalculateMeta(@NonNull Contexts contexts);
/**
* (Re)loads permission data for a given context.
*
* <p>Unlike {@link #recalculatePermissions(Contexts)}, this method immediately
* invalidates any previous {@link PermissionData} values contained within the cache,
* and then schedules a task to reload a new {@link PermissionData} instance to
* replace the one which was invalidated.</p>
*
* <p>The invalidation happens immediately during the execution of this method.
* The result of the re-computation encapsulated by the future.</p>
*
* <p>Subsequent calls to {@link #getPermissionData(Contexts)} will block until
* the result of this operation is complete.</p>
*
* <p>If there was no value calculated and cached prior to the call of this
* method, then one will be calculated.</p>
*
* <p>This method returns a Future so users can optionally choose to wait
* until the recalculation has been performed.</p>
*
* @param contexts the contexts to reload in.
* @return a future
* @throws NullPointerException if contexts is null
* @since 4.0
*/
@NonNull CompletableFuture<? extends PermissionData> reloadPermissions(@NonNull Contexts contexts);
/**
* (Re)loads meta data for a given context.
*
* <p>Unlike {@link #recalculateMeta(MetaContexts)}, this method immediately
* invalidates any previous {@link MetaData} values contained within the cache,
* and then schedules a task to reload a new {@link MetaData} instance to
* replace the one which was invalidated.</p>
*
* <p>The invalidation happens immediately during the execution of this method.
* The result of the re-computation encapsulated by the future.</p>
*
* <p>Subsequent calls to {@link #getMetaData(MetaContexts)} will block until
* the result of this operation is complete.</p>
*
* <p>If there was no value calculated and cached prior to the call of this
* method, then one will be calculated.</p>
*
* <p>This method returns a Future so users can optionally choose to wait
* until the recalculation has been performed.</p>
*
* @param contexts the contexts to reload in.
* @return a future
* @throws NullPointerException if contexts is null
* @since 4.0
*/
@NonNull CompletableFuture<? extends MetaData> reloadMeta(@NonNull MetaContexts contexts);
/**
* (Re)loads meta data for a given context.
*
* <p>Unlike {@link #recalculateMeta(Contexts)}, this method immediately
* invalidates any previous {@link MetaData} values contained within the cache,
* and then schedules a task to reload a new {@link MetaData} instance to
* replace the one which was invalidated.</p>
*
* <p>The invalidation happens immediately during the execution of this method.
* The result of the re-computation encapsulated by the future.</p>
*
* <p>Subsequent calls to {@link #getMetaData(Contexts)} will block until
* the result of this operation is complete.</p>
*
* <p>If there was no value calculated and cached prior to the call of this
* method, then one will be calculated.</p>
*
* <p>This method returns a Future so users can optionally choose to wait
* until the recalculation has been performed.</p>
*
* @param contexts the contexts to reload in.
* @return a future
* @throws NullPointerException if contexts is null
* @since 4.0
*/
@NonNull CompletableFuture<? extends MetaData> reloadMeta(@NonNull Contexts contexts);
/**
* Recalculates permission data for all known contexts.
*
* <p>This method returns immediately. The recalculation is performed
* asynchronously and applied to the cache in the background.</p>
*
* <p>The previous {@link PermissionData} instances will continue to be returned
* by {@link #getPermissionData(Contexts)} until the recalculation is completed.</p>
*/
void recalculatePermissions();
/**
* Recalculates meta data for all known contexts.
*
* <p>This method returns immediately. The recalculation is performed
* asynchronously and applied to the cache in the background.</p>
*
* <p>The previous {@link MetaData} instances will continue to be returned
* by {@link #getMetaData(MetaContexts)} and {@link #getMetaData(Contexts)}
* until the recalculation is completed.</p>
*/
void recalculateMeta();
/**
* Reloads permission data for all known contexts.
*
* <p>Unlike {@link #recalculatePermissions()}, this method immediately
* invalidates all previous {@link PermissionData} values contained within the cache,
* and then schedules a task to reload a new {@link PermissionData} instances to
* replace the ones which were invalidated.</p>
*
* <p>The invalidation happens immediately during the execution of this method.
* The result of the re-computation encapsulated by the future.</p>
*
* <p>Subsequent calls to {@link #getPermissionData(Contexts)} will block until
* the result of this operation is complete.</p>
*
* <p>This method returns a Future so users can optionally choose to wait
* until the recalculation has been performed.</p>
*
* @return a future
* @since 4.0
*/
@NonNull CompletableFuture<Void> reloadPermissions();
/**
* Reloads meta data for all known contexts.
*
* <p>Unlike {@link #recalculateMeta()}, this method immediately
* invalidates all previous {@link MetaData} values contained within the cache,
* and then schedules a task to reload a new {@link MetaData} instances to
* replace the ones which were invalidated.</p>
*
* <p>The invalidation happens immediately during the execution of this method.
* The result of the re-computation encapsulated by the future.</p>
*
* <p>Subsequent calls to {@link #getMetaData(MetaContexts)} and
* {@link #getMetaData(Contexts)} will block until the result of this operation
* is complete.</p>
*
* <p>This method returns a Future so users can optionally choose to wait
* until the recalculation has been performed.</p>
*
* @return a future
* @since 4.0
*/
@NonNull CompletableFuture<Void> reloadMeta();
/**
* Pre-calculates and caches {@link PermissionData} and {@link MetaData}
* instances for the given contexts.
*
* <p>If the cache already contains a value for the given context,
* no action is taken.</p>
*
* <p>This method blocks until the calculation is completed.</p>
*
* @param contexts a set of contexts
* @throws NullPointerException if contexts is null
*/
default void preCalculate(@NonNull Set<Contexts> contexts) {
contexts.forEach(this::preCalculate);
}
/**
* Pre-calculates and caches {@link PermissionData} and {@link MetaData}
* instances for a given context.
*
* <p>If the cache already contains a value for the given context,
* no action is taken.</p>
*
* <p>This method blocks until the calculation is completed.</p>
*
* @param contexts the contexts to pre-calculate for
* @throws NullPointerException if contexts is null
*/
default void preCalculate(@NonNull Contexts contexts) {
Objects.requireNonNull(contexts, "contexts");
// pre-calculate just by requesting the data from this cache.
// if the data isn't already loaded, it will be calculated.
getPermissionData(contexts);
getMetaData(contexts);
}
/**
* Invalidates any cached {@link PermissionData} instances mapped to the given
* {@link Contexts}.
*
* @param contexts the contexts to invalidate for
* @since 4.0
*/
void invalidatePermissions(@NonNull Contexts contexts);
/**
* Invalidates any cached {@link MetaData} instances mapped to the given
* {@link MetaContexts}.
*
* @param contexts the contexts to invalidate for
* @since 4.0
*/
void invalidateMeta(@NonNull MetaContexts contexts);
/**
* Invalidates any cached {@link MetaData} instances mapped to the given
* {@link Contexts}.
*
* @param contexts the contexts to invalidate for
* @since 4.0
*/
void invalidateMeta(@NonNull Contexts contexts);
/**
* Invalidates all cached {@link PermissionData} instances.
*
* @since 4.2
*/
void invalidatePermissions();
/**
* Invalidates all cached {@link MetaData} instances.
*
* @since 4.2
*/
void invalidateMeta();
/**
* Invalidates all of the underlying Permission calculators.
*
* <p>Can be called to allow for an update in defaults.</p>
*/
void invalidatePermissionCalculators();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -20,22 +23,24 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.caching.holder;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
package me.lucko.luckperms.api.caching;
import me.lucko.luckperms.api.Contexts;
@Getter
@ToString
@EqualsAndHashCode
@AllArgsConstructor(staticName = "of")
public class ExportNodesHolder {
import org.checkerframework.checker.nullness.qual.NonNull;
private final Contexts contexts;
private final Boolean lowerCase;
/**
* Holds cached lookup data in a specific set of contexts.
*
* @since 4.1
*/
public interface CachedDataContainer {
/**
* Gets the contexts this container is holding data for.
*
* @return the contexts this container is caching
*/
@NonNull Contexts getContexts();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -20,21 +23,23 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.event.impl;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
package me.lucko.luckperms.api.caching;
import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.api.event.group.GroupLoadEvent;
import me.lucko.luckperms.common.event.AbstractEvent;
@Getter
@ToString
@AllArgsConstructor
public class EventGroupLoad extends AbstractEvent implements GroupLoadEvent {
private final Group group;
/**
* Holds cached permission and meta lookup data for a {@link Group}.
*
* <p>All calls will account for inheritance, as well as any default data provided
* by the platform. This calls are heavily cached and are therefore fast.</p>
*
* <p>For meta, both methods accepting {@link Contexts} and {@link MetaContexts} are provided. The only difference is that
* the latter allows you to define how the meta stack should be structured internally. Where {@link Contexts} are passed, the
* values from the configuration are used.</p>
*
* @since 4.0
*/
public interface GroupData extends CachedData {
}
@@ -0,0 +1,117 @@
/*
* 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 me.lucko.luckperms.api.caching;
import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Objects;
/**
* Encapsulates the options and settings for a meta lookup.
*
* <p>Consists of a standard {@link Contexts} element, plus options to define how
* the meta stack should be constructed.</p>
*
* @since 3.2
*/
public final class MetaContexts {
/**
* Creates a new meta contexts instance
*
* @param contexts the standard contexts for the query
* @param prefixStackDefinition the prefix stack definition to be used
* @param suffixStackDefinition the suffix stack definition to be used
* @return the new instance
*/
public static MetaContexts of(@NonNull Contexts contexts, @NonNull MetaStackDefinition prefixStackDefinition, @NonNull MetaStackDefinition suffixStackDefinition) {
return new MetaContexts(contexts, prefixStackDefinition, suffixStackDefinition);
}
private final Contexts contexts;
private final MetaStackDefinition prefixStackDefinition;
private final MetaStackDefinition suffixStackDefinition;
// cache hashcode - this class is immutable, and is used as an index in the permission cache.
private final int hashCode;
/**
* Creates a new meta contexts instance
*
* @param contexts the standard contexts for the query
* @param prefixStackDefinition the prefix stack definition to be used
* @param suffixStackDefinition the suffix stack definition to be used
*/
public MetaContexts(@NonNull Contexts contexts, @NonNull MetaStackDefinition prefixStackDefinition, @NonNull MetaStackDefinition suffixStackDefinition) {
this.contexts = Objects.requireNonNull(contexts, "contexts");
this.prefixStackDefinition = Objects.requireNonNull(prefixStackDefinition, "prefixStackDefinition");
this.suffixStackDefinition = Objects.requireNonNull(suffixStackDefinition, "suffixStackDefinition");
this.hashCode = calculateHashCode();
}
public @NonNull Contexts getContexts() {
return this.contexts;
}
public @NonNull MetaStackDefinition getPrefixStackDefinition() {
return this.prefixStackDefinition;
}
public @NonNull MetaStackDefinition getSuffixStackDefinition() {
return this.suffixStackDefinition;
}
@Override
public @NonNull String toString() {
return "MetaContexts(" +
"contexts=" + this.getContexts() + ", " +
"prefixStackDefinition=" + this.getPrefixStackDefinition() + ", " +
"suffixStackDefinition=" + this.getSuffixStackDefinition() +
")";
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof MetaContexts)) return false;
final MetaContexts that = (MetaContexts) o;
return this.contexts.equals(that.contexts) &&
this.prefixStackDefinition.equals(that.prefixStackDefinition) &&
this.suffixStackDefinition.equals(that.suffixStackDefinition);
}
private int calculateHashCode() {
return Objects.hash(this.contexts, this.prefixStackDefinition, this.suffixStackDefinition);
}
@Override
public int hashCode() {
return this.hashCode;
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,22 +25,53 @@
package me.lucko.luckperms.api.caching;
import com.google.common.collect.ListMultimap;
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Map;
import java.util.SortedMap;
/**
* Holds cached Meta lookup data for a specific set of contexts
* Holds cached meta lookup data for a specific set of contexts.
*
* @since 2.13
*/
public interface MetaData {
public interface MetaData extends CachedDataContainer {
/**
* Gets an immutable copy of the meta this user has
* Gets the contexts this container is holding data for.
*
* @return the contexts this container is caching
*/
@NonNull MetaContexts getMetaContexts();
/**
* Gets an immutable copy of the meta this user has.
*
* <p>A list multimap is used because when inherited values are included, each key can be
* mapped to multiple values.</p>
*
* <p>The first value to be accumulated (and used to represent the key in {@link #getMeta()} is at index 0
* in the list. Any additional values are stored in order of accumulation.</p>
*
* @return an immutable multimap of meta
* @since 3.3
*/
@NonNull ListMultimap<String, String> getMetaMultimap();
/**
* Gets an immutable copy of the meta this user has.
*
* <p>This map is formed by taking the entries in {@link #getMetaMultimap()}, and mapping each key
* to the value at index 0 in the corresponding list.</p>
*
* @return an immutable map of meta
*/
Map<String, String> getMeta();
@NonNull Map<String, String> getMeta();
/**
* Gets an immutable sorted map of all of the prefixes the user has, whereby the first value is the highest priority
@@ -45,7 +79,7 @@ public interface MetaData {
*
* @return a sorted map of prefixes
*/
SortedMap<Integer, String> getPrefixes();
@NonNull SortedMap<Integer, String> getPrefixes();
/**
* Gets an immutable sorted map of all of the suffixes the user has, whereby the first value is the highest priority
@@ -53,20 +87,36 @@ public interface MetaData {
*
* @return a sorted map of suffixes
*/
SortedMap<Integer, String> getSuffixes();
@NonNull SortedMap<Integer, String> getSuffixes();
/**
* Gets the user's highest priority prefix, or null if the user has no prefixes
*
* @return a prefix string, or null
*/
String getPrefix();
@Nullable String getPrefix();
/**
* Gets the user's highest priority suffix, or null if the user has no suffixes
*
* @return a suffix string, or null
*/
String getSuffix();
@Nullable String getSuffix();
/**
* Gets the definition used for the prefix stack
*
* @return the definition used for the prefix stack
* @since 3.2
*/
@NonNull MetaStackDefinition getPrefixStackDefinition();
/**
* Gets the definition used for the suffix stack
*
* @return the definition used for the suffix stack
* @since 3.2
*/
@NonNull MetaStackDefinition getSuffixStackDefinition();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -24,28 +27,30 @@ package me.lucko.luckperms.api.caching;
import me.lucko.luckperms.api.Tristate;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Map;
/**
* Holds cached Permission lookup data for a specific set of contexts
* Holds cached permission lookup data for a specific set of contexts.
*
* @since 2.13
*/
public interface PermissionData {
public interface PermissionData extends CachedDataContainer {
/**
* Gets a permission value for the given permission node
* Gets a permission check result for the given permission node.
*
* @param permission the permission node
* @return a tristate result
* @throws NullPointerException if permission is null
*/
Tristate getPermissionValue(String permission);
@NonNull Tristate getPermissionValue(@NonNull String permission);
/**
* Invalidates the underlying permission calculator cache.
*
* <p> Can be called to allow for an update in defaults.
* <p>Can be called to allow for an update in defaults.</p>
*/
void invalidateCache();
@@ -54,6 +59,6 @@ public interface PermissionData {
*
* @return an immutable set of permissions
*/
Map<String, Boolean> getImmutableBacking();
@NonNull Map<String, Boolean> getImmutableBacking();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -23,113 +26,20 @@
package me.lucko.luckperms.api.caching;
import me.lucko.luckperms.api.Contexts;
import java.util.Set;
import me.lucko.luckperms.api.User;
/**
* Holds cached permission and meta lookup data for a {@link me.lucko.luckperms.api.User}.
* Holds cached permission and meta lookup data for a {@link User}.
*
* <p>Data is only likely to be available for online users. All calls will account for inheritance, as well as any
* default data provided by the platform. This calls are heavily cached and are therefore fast.
* <p>All calls will account for inheritance, as well as any default data provided by
* the platform. This calls are heavily cached and are therefore fast.</p>
*
* <p>For meta, both methods accepting {@link Contexts} and {@link MetaContexts} are provided. The only difference is that
* the latter allows you to define how the meta stack should be structured internally. Where {@link Contexts} are passed, the
* values from the configuration are used.</p>
*
* @since 2.13
*/
public interface UserData {
/**
* Gets PermissionData from the cache, given a specified context.
*
* <p> If the data is not cached, it is calculated. Therefore, this call could be costly.
*
* @param contexts the contexts to get the permission data in
* @return a permission data instance
* @throws NullPointerException if contexts is null
*/
PermissionData getPermissionData(Contexts contexts);
/**
* Gets MetaData from the cache, given a specified context.
*
* <p> If the data is not cached, it is calculated. Therefore, this call could be costly.
*
* @param contexts the contexts to get the permission data in
* @return a meta data instance
* @throws NullPointerException if contexts is null
*/
MetaData getMetaData(Contexts contexts);
/**
* Calculates permission data, bypassing the cache.
*
* @param contexts the contexts to get permission data in
* @return a permission data instance
* @throws NullPointerException if contexts is null
*/
PermissionData calculatePermissions(Contexts contexts);
/**
* Calculates meta data, bypassing the cache.
*
* @param contexts the contexts to get meta data in
* @return a meta data instance
* @throws NullPointerException if contexts is null
*/
MetaData calculateMeta(Contexts contexts);
/**
* Calculates permission data and stores it in the cache.
*
* <p> If there is already data cached for the given contexts, and if the resultant output is different,
* the cached value is updated.
*
* @param contexts the contexts to recalculate in.
* @throws NullPointerException if contexts is null
*/
void recalculatePermissions(Contexts contexts);
/**
* Calculates meta data and stores it in the cache.
*
* <p> If there is already data cached for the given contexts, and if the resultant output is different,
* the cached value is updated.
*
* @param contexts the contexts to recalculate in.
* @throws NullPointerException if contexts is null
*/
void recalculateMeta(Contexts contexts);
/**
* Calls {@link #recalculatePermissions(Contexts)} for all current loaded contexts
*/
void recalculatePermissions();
/**
* Calls {@link #recalculateMeta(Contexts)} for all current loaded contexts
*/
void recalculateMeta();
/**
* Calls {@link #preCalculate(Contexts)} for the given contexts
*
* @param contexts a set of contexts
* @throws NullPointerException if contexts is null
*/
void preCalculate(Set<Contexts> contexts);
/**
* Ensures that PermissionData and MetaData is cached for a context.
*
* <p> If the cache does not contain any data for the context, it will be calculated and saved.
*
* @param contexts the contexts to pre-calculate for
* @throws NullPointerException if contexts is null
*/
void preCalculate(Contexts contexts);
/**
* Invalidates all of the underlying Permission calculators.
* Can be called to allow for an update in defaults.
*/
void invalidatePermissionCalculators();
public interface UserData extends CachedData {
}
@@ -0,0 +1,102 @@
/*
* 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 me.lucko.luckperms.api.context;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.SetMultimap;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
import java.util.Objects;
import java.util.Set;
abstract class AbstractContextSet implements ContextSet {
protected abstract SetMultimap<String, String> backing();
protected abstract void copyTo(SetMultimap<String, String> other);
@Override
public boolean containsKey(@NonNull String key) {
return backing().containsKey(sanitizeKey(key));
}
@Override
public @NonNull Set<String> getValues(@NonNull String key) {
Collection<String> values = backing().asMap().get(sanitizeKey(key));
return values != null ? ImmutableSet.copyOf(values) : ImmutableSet.of();
}
@Override
public boolean has(@NonNull String key, @NonNull String value) {
return backing().containsEntry(sanitizeKey(key), sanitizeValue(value));
}
@Override
public boolean isEmpty() {
return backing().isEmpty();
}
@Override
public int size() {
return backing().size();
}
@Override
public int hashCode() {
return backing().hashCode();
}
static String sanitizeKey(String key) {
Objects.requireNonNull(key, "key is null");
if (stringIsEmpty(key)) {
throw new IllegalArgumentException("key is (effectively) empty");
}
return key.toLowerCase();
}
static String sanitizeValue(String value) {
Objects.requireNonNull(value, "value is null");
if (stringIsEmpty(value)) {
throw new IllegalArgumentException("value is (effectively) empty");
}
return value.toLowerCase();
}
private static boolean stringIsEmpty(String s) {
if (s.isEmpty()) {
return true;
}
for (char c : s.toCharArray()) {
if (c != ' ') {
return false;
}
}
return true;
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,15 +25,15 @@
package me.lucko.luckperms.api.context;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Calculates whether contexts are applicable to {@link T}
*
* <p>Somewhat inspired by the system used on Sponge.
* Calculates whether contexts are applicable to a {@link T subject}.
*
* @param <T> the subject type. Is ALWAYS the player class of the platform.
* @since 2.13
*/
@FunctionalInterface
public interface ContextCalculator<T> {
/**
@@ -41,15 +44,6 @@ public interface ContextCalculator<T> {
* @return the map
* @since 2.13
*/
MutableContextSet giveApplicableContext(T subject, MutableContextSet accumulator);
/**
* Checks to see if a context is applicable to a subject
*
* @param subject the subject to check against
* @param context the context to check for
* @return true if met, or false if not. If this calculator does not calculate the given context, return false.
*/
boolean isContextApplicable(T subject, Map.Entry<String, String> context);
@NonNull MutableContextSet giveApplicableContext(@NonNull T subject, @NonNull MutableContextSet accumulator);
}
@@ -0,0 +1,167 @@
/*
* 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 me.lucko.luckperms.api.context;
import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.User;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Optional;
/**
* Manages {@link ContextCalculator}s, and calculates applicable contexts for a
* given type.
*
* This interface accepts {@link Object} types as a parameter to avoid having to depend
* on specific server implementations. In all cases, the "player" or "subject" type for
* the platform must be used.
*
* Specifically:
*
* <p></p>
* <ul>
* <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 cn.nukkit.Player}</li>
* <li>{@code com.velocitypowered.api.proxy.Player}</li>
* </ul>
*
* @since 4.0
*/
public interface ContextManager {
/**
* Queries the ContextManager for current context values for the subject.
*
* @param subject the subject
* @return the applicable context for the subject
*/
@NonNull ImmutableContextSet getApplicableContext(@NonNull Object subject);
/**
* Queries the ContextManager for current context values for the subject.
*
* @param subject the subject
* @return the applicable context for the subject
*/
@NonNull Contexts getApplicableContexts(@NonNull Object subject);
/**
* Queries the ContextManager for current context values for the given User.
*
* <p>This will only return a value if the player corresponding to the
* {@link User} is online.</p>
*
* <p>If you need to be a {@link Contexts} instance regardless, you should
* initially try this method, and then fallback on {@link #getStaticContext()}.</p>
*
* @param user the user
* @return the applicable context for the subject
*/
@NonNull Optional<ImmutableContextSet> lookupApplicableContext(@NonNull User user);
/**
* Queries the ContextManager for current context values for the given User.
*
* <p>This will only return a value if the player corresponding to the
* {@link User} is online.</p>
*
* <p>If you need to be a {@link Contexts} instance regardless, you should
* initially try this method, and then fallback on {@link #getStaticContexts()}.</p>
*
* @param user the user
* @return the applicable context for the subject
*/
@NonNull Optional<Contexts> lookupApplicableContexts(@NonNull User user);
/**
* Gets the contexts from the static calculators in this manager.
*
* <p>Static calculators provide the same context for all subjects, and are
* marked as such when registered.</p>
*
* @return the current active static contexts
*/
@NonNull ImmutableContextSet getStaticContext();
/**
* Gets the contexts from the static calculators in this manager.
*
* <p>Static calculators provide the same context for all subjects, and are
* marked as such when registered.</p>
*
* @return the current active static contexts
*/
@NonNull Contexts getStaticContexts();
/**
* Forms a {@link Contexts} instance from an {@link ImmutableContextSet}.
*
* <p>This method relies on the plugins configuration to form the
* {@link Contexts} instance.</p>
*
* @param subject the reference subject
* @param contextSet the context set
* @return a contexts instance
*/
@NonNull Contexts formContexts(@NonNull Object subject, @NonNull ImmutableContextSet contextSet);
/**
* Forms a {@link Contexts} instance from an {@link ImmutableContextSet}.
*
* <p>This method relies on the plugins configuration to form the
* {@link Contexts} instance.</p>
*
* @param contextSet the context set
* @return a contexts instance
*/
@NonNull Contexts formContexts(@NonNull ImmutableContextSet contextSet);
/**
* Registers a context calculator with the manager.
*
* @param calculator the calculator
*/
void registerCalculator(@NonNull ContextCalculator<?> calculator);
/**
* Unregisters a context calculator with the manager.
*
* @param calculator the calculator
* @since 4.4
*/
void unregisterCalculator(@NonNull ContextCalculator<?> calculator);
/**
* Invalidates the lookup cache for a given subject
*
* @param subject the subject
*/
void invalidateCache(@NonNull Object subject);
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -24,178 +27,316 @@ package me.lucko.luckperms.api.context;
import com.google.common.collect.Multimap;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
/**
* Holds contexts.
* Implementations may be either mutable or immutable.
* A set of contexts.
*
* <p>Context in the most basic sense simply means the circumstances where
* 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>
*
* <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>
*
* @since 2.13
*/
public interface ContextSet {
public interface ContextSet extends Iterable<Map.Entry<String, String>> {
/**
* Make a singleton ImmutableContextSet from a context pair
* Creates an {@link ImmutableContextSet} from a context pair.
*
* @param key the key
* @param value the value
* @return a new ImmutableContextSet containing one KV pair
* @return a new ImmutableContextSet containing one context pair
* @throws NullPointerException if key or value is null
*/
static ImmutableContextSet singleton(String key, String value) {
static @NonNull ImmutableContextSet singleton(@NonNull String key, @NonNull String value) {
return ImmutableContextSet.singleton(key, value);
}
/**
* Creates a ImmutableContextSet from an existing map
* Creates an {@link ImmutableContextSet} from two context pairs.
*
* @param map the map to copy from
* @return a new ImmutableContextSet representing the pairs from the map
* @throws NullPointerException if the map is null
* @param key1 the first key
* @param value1 the first value
* @param key2 the second key
* @param value2 the second value
* @return a new ImmutableContextSet containing the two pairs
* @throws NullPointerException if any of the keys or values are null
* @since 3.1
*/
static ImmutableContextSet fromMap(Map<String, String> map) {
return ImmutableContextSet.fromMap(map);
static @NonNull ImmutableContextSet of(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2) {
return ImmutableContextSet.of(key1, value1, key2, value2);
}
/**
* Creates a ImmutableContextSet from an existing iterable of Map Entries
* Creates an {@link ImmutableContextSet} from an existing {@link Iterable} of {@link Map.Entry}s.
*
* @param iterable the iterable to copy from
* @return a new ImmutableContextSet representing the pairs in the iterable
* @throws NullPointerException if the iterable is null
*/
static ImmutableContextSet fromEntries(Iterable<? extends Map.Entry<String, String>> iterable) {
static @NonNull ImmutableContextSet fromEntries(@NonNull Iterable<? extends Map.Entry<String, String>> iterable) {
return ImmutableContextSet.fromEntries(iterable);
}
/**
* Creates a ImmutableContextSet from an existing multimap
* Creates an {@link ImmutableContextSet} from an existing {@link Map}.
*
* @param map the map to copy from
* @return a new ImmutableContextSet representing the pairs from the map
* @throws NullPointerException if the map is null
*/
static @NonNull ImmutableContextSet fromMap(@NonNull Map<String, String> map) {
return ImmutableContextSet.fromMap(map);
}
/**
* Creates an {@link ImmutableContextSet} from an existing {@link Multimap}.
*
* @param multimap the multimap to copy from
* @return a new ImmutableContextSet representing the pairs in the multimap
* @throws NullPointerException if the multimap is null
* @since 2.16
*/
static ImmutableContextSet fromMultimap(Multimap<String, String> multimap) {
static @NonNull ImmutableContextSet fromMultimap(@NonNull Multimap<String, String> multimap) {
return ImmutableContextSet.fromMultimap(multimap);
}
/**
* Creates a new ImmutableContextSet from an existing set.
* Only really useful for converting between mutable and immutable types.
* Creates an new {@link ImmutableContextSet} from an existing {@link Set}.
*
* <p>Only really useful for converting between mutable and immutable types.</p>
*
* @param contextSet the context set to copy from
* @return a new ImmutableContextSet with the same content and the one provided
* @throws NullPointerException if contextSet is null
*/
static ImmutableContextSet fromSet(ContextSet contextSet) {
static @NonNull ImmutableContextSet fromSet(@NonNull ContextSet contextSet) {
return ImmutableContextSet.fromSet(contextSet);
}
/**
* Creates a new empty ImmutableContextSet.
* Returns an empty {@link ImmutableContextSet}.
*
* @return a new ImmutableContextSet
* @return an empty ImmutableContextSet
*/
static ImmutableContextSet empty() {
static @NonNull ImmutableContextSet empty() {
return ImmutableContextSet.empty();
}
/**
* Check to see if this set is in an immutable form
* Gets if this {@link ContextSet} is immutable.
*
* <p>The state of immutable instances will never change.</p>
*
* @return true if the set is immutable
*/
boolean isImmutable();
/**
* If the set is mutable, this method will return an immutable copy. Otherwise just returns itself.
* Returns an immutable representation of this {@link ContextSet}.
*
* @return an immutable ContextSet
* <p>If the set is already immutable, the same object will be returned.
* If the set is mutable, an immutable copy will be made.</p>
*
* @return an immutable representation of this set
*/
ImmutableContextSet makeImmutable();
@NonNull ImmutableContextSet makeImmutable();
/**
* Creates a mutable copy of this set.
* Creates a mutable copy of this {@link ContextSet}.
*
* <p>A new copy is returned regardless of the
* {@link #isImmutable() mutability} of this set.</p>
*
* @return a mutable ContextSet
* @since 2.16
*/
MutableContextSet mutableCopy();
@NonNull MutableContextSet mutableCopy();
/**
* Converts this ContextSet to an immutable {@link Set} of {@link Map.Entry}s.
* Returns a {@link Set} of {@link Map.Entry}s representing the current
* state of this {@link ContextSet}.
*
* <p>The returned set is immutable, and is a copy of the current set.
* (will not update live)</p>
*
* @return an immutable set
*/
Set<Map.Entry<String, String>> toSet();
@NonNull Set<Map.Entry<String, String>> toSet();
/**
* Converts this ContextSet to an immutable {@link Map}
* Returns a {@link Map} <b>loosely</b> representing the current state of
* this {@link ContextSet}.
*
* <b>NOTE: Use of this method may result in data being lost. ContextSets can contain lots of different values for
* one key.</b>
* <p>The returned map is immutable, and is a copy of the current set.
* (will not update live)</p>
*
* <p>As a single context key can be mapped to multiple values, this method
* may not be a true representation of the set.</p>
*
* <p>If you need a representation of the set in a Java collection instance,
* use {@link #toSet()} or {@link #toMultimap()} followed by
* {@link Multimap#asMap()}.</p>
*
* @return an immutable map
* @deprecated because the resultant map may not contain all data in the ContextSet
*/
Map<String, String> toMap();
@Deprecated
@NonNull Map<String, String> toMap();
/**
* Converts this ContextSet to an immutable {@link Multimap}
* Returns a {@link Multimap} representing the current state of this
* {@link ContextSet}.
*
* <p>The returned multimap is immutable, and is a copy of the current set.
* (will not update live)</p>
*
* @return a multimap
* @since 2.16
*/
Multimap<String, String> toMultimap();
@NonNull Multimap<String, String> toMultimap();
/**
* Check if the set contains at least one value for the given key.
* Returns an {@link Iterator} over each of the context pairs in this set.
*
* <p>The returned iterator represents the state of the set at the time of creation. It is not
* updated as the set changes.</p>
*
* <p>The iterator does not support {@link Iterator#remove()} calls.</p>
*
* @return an iterator
*/
@Override
@NonNull Iterator<Map.Entry<String, String>> iterator();
/**
* Returns if the {@link ContextSet} contains at least one value for the
* given key.
*
* @param key the key to check for
* @return true if the set contains a value for the key
* @throws NullPointerException if the key is null
*/
boolean containsKey(String key);
boolean containsKey(@NonNull String key);
/**
* Gets a set of all of the values mapped to the given key
* Returns a {@link Set} of the values mapped to the given key.
*
* @param key the key to find values for
* <p>The returned set is immutable, and only represents the current state
* of the {@link ContextSet}. (will not update live)</p>
*
* @param key the key to get values for
* @return a set of values
* @throws NullPointerException if the key is null
*/
Set<String> getValues(String key);
@NonNull Set<String> getValues(@NonNull String key);
/**
* Check if thr set contains a given key mapped to a given value
* Returns any value from this {@link ContextSet} matching the key, if present.
*
* @param key the key to look for
* @param value the value to look for (case sensitive)
* @return true if the set contains the KV pair
* @throws NullPointerException if the key or value is null
* <p>Note that context keys can be mapped to multiple values.
* Use {@link #getValues(String)} to retrieve all associated values.</p>
*
* @param key the key to find values for
* @return an optional containing any match
* @since 3.1
*/
boolean has(String key, String value);
default @NonNull Optional<String> getAnyValue(@NonNull String key) {
return getValues(key).stream().findAny();
}
/**
* Same as {@link #has(String, String)}, except ignores the case of the value.
* Returns if the {@link ContextSet} contains a given context pairing.
*
* @param key the key to look for
* @param value the value to look for
* @return true if the set contains the KV pair
* @return true if the set contains the context pair
* @throws NullPointerException if the key or value is null
*/
boolean hasIgnoreCase(String key, String value);
boolean has(@NonNull String key, @NonNull String value);
/**
* Check if the set is empty
* Returns if the {@link ContextSet} contains a given context pairing.
*
* @param entry the entry to look for
* @return true if the set contains the context pair
* @throws NullPointerException if the key or value is null
*/
default boolean has(Map.@NonNull Entry<String, String> entry) {
Objects.requireNonNull(entry, "entry");
return has(entry.getKey(), entry.getValue());
}
/**
* Returns if this {@link ContextSet} is fully "satisfied" by another set.
*
* <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
* @since 3.1
*/
default boolean isSatisfiedBy(@NonNull ContextSet other) {
if (this == other) {
return true;
}
Objects.requireNonNull(other, "other");
if (this.isEmpty()) {
// this is empty, so is therefore always satisfied.
return true;
} else if (other.isEmpty()) {
// this set isn't empty, but the other one is
return false;
} else if (this.size() > other.size()) {
// this set has more unique entries than the other set, so there's no way this can be satisfied.
return false;
} else {
// neither are empty, we need to compare the individual entries
for (Map.Entry<String, String> context : toSet()) {
if (!other.has(context)) {
return false;
}
}
return true;
}
}
/**
* Returns if the {@link ContextSet} is empty.
*
* @return true if the set is empty
*/
boolean isEmpty();
/**
* Gets the number of key-value context pairs in the set
* Gets the number of context pairs in the {@link ContextSet}.
*
* @return the size of the set
*/
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -23,116 +26,145 @@
package me.lucko.luckperms.api.context;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.SetMultimap;
import java.util.Collection;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.Spliterator;
/**
* An immutable implementation of {@link ContextSet}.
*
* @since 2.16
*/
public final class ImmutableContextSet implements ContextSet {
private static final ImmutableContextSet EMPTY = new ImmutableContextSet(ImmutableMultimap.of());
public final class ImmutableContextSet extends AbstractContextSet implements ContextSet {
private static final ImmutableContextSet EMPTY = new ImmutableContextSet(ImmutableSetMultimap.of());
/**
* Make a singleton ImmutableContextSet from a context pair
* Creates an {@link ImmutableContextSet.Builder}.
*
* @return a new ImmutableContextSet builder
* @since 4.1
*/
public static @NonNull Builder builder() {
return new Builder();
}
/**
* Creates an {@link ImmutableContextSet} from a context pair.
*
* @param key the key
* @param value the value
* @return a new ImmutableContextSet containing one KV pair
* @return a new ImmutableContextSet containing one context pair
* @throws NullPointerException if key or value is null
*/
public static ImmutableContextSet singleton(String key, String value) {
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
return new ImmutableContextSet(ImmutableMultimap.of(key.toLowerCase(), value));
public static @NonNull ImmutableContextSet singleton(@NonNull String key, @NonNull String value) {
return new ImmutableContextSet(ImmutableSetMultimap.of(sanitizeKey(key), sanitizeValue(value)));
}
/**
* Creates a ImmutableContextSet from an existing map
* Creates an {@link ImmutableContextSet} from two context pairs.
*
* @param map the map to copy from
* @return a new ImmutableContextSet representing the pairs from the map
* @throws NullPointerException if the map is null
* @param key1 the first key
* @param value1 the first value
* @param key2 the second key
* @param value2 the second value
* @return a new ImmutableContextSet containing the two pairs
* @throws NullPointerException if any of the keys or values are null
* @since 3.1
*/
public static ImmutableContextSet fromMap(Map<String, String> map) {
if (map == null) {
throw new NullPointerException("map");
}
ImmutableMultimap.Builder<String, String> b = ImmutableMultimap.builder();
for (Map.Entry<String, String> e : map.entrySet()) {
b.put(e.getKey(), e.getValue());
}
return new ImmutableContextSet(b.build());
public static @NonNull ImmutableContextSet of(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2) {
return new ImmutableContextSet(ImmutableSetMultimap.of(
sanitizeKey(key1),
sanitizeValue(value1),
sanitizeKey(key2),
sanitizeValue(value2)
));
}
/**
* Creates a ImmutableContextSet from an existing iterable of Map Entries
* Creates an {@link ImmutableContextSet} from an existing {@link Iterable} of {@link Map.Entry}s.
*
* @param iterable the iterable to copy from
* @return a new ImmutableContextSet representing the pairs in the iterable
* @throws NullPointerException if the iterable is null
*/
public static ImmutableContextSet fromEntries(Iterable<? extends Map.Entry<String, String>> iterable) {
if (iterable == null) {
throw new NullPointerException("iterable");
public static @NonNull ImmutableContextSet fromEntries(@NonNull Iterable<? extends Map.Entry<String, String>> iterable) {
Objects.requireNonNull(iterable, "iterable");
ImmutableContextSet.Builder builder = builder();
for (Map.Entry<String, String> entry : iterable) {
builder.add(entry);
}
return MutableContextSet.fromEntries(iterable).makeImmutable();
return builder.build();
}
/**
* Creates a ImmutableContextSet from an existing multimap
* Creates an {@link ImmutableContextSet} from an existing {@link Map}.
*
* @param map the map to copy from
* @return a new ImmutableContextSet representing the pairs from the map
* @throws NullPointerException if the map is null
*/
public static @NonNull ImmutableContextSet fromMap(@NonNull Map<String, String> map) {
return fromEntries(Objects.requireNonNull(map, "map").entrySet());
}
/**
* Creates an {@link ImmutableContextSet} from an existing {@link Multimap}.
*
* @param multimap the multimap to copy from
* @return a new ImmutableContextSet representing the pairs in the multimap
* @throws NullPointerException if the multimap is null
* @since 2.16
*/
public static ImmutableContextSet fromMultimap(Multimap<String, String> multimap) {
if (multimap == null) {
throw new NullPointerException("multimap");
}
return MutableContextSet.fromMultimap(multimap).makeImmutable();
public static @NonNull ImmutableContextSet fromMultimap(@NonNull Multimap<String, String> multimap) {
return fromEntries(Objects.requireNonNull(multimap, "multimap").entries());
}
/**
* Creates a new ImmutableContextSet from an existing set.
* Only really useful for converting between mutable and immutable types.
* Creates an new {@link ImmutableContextSet} from an existing {@link Set}.
*
* <p>Only really useful for converting between mutable and immutable types.</p>
*
* @param contextSet the context set to copy from
* @return a new ImmutableContextSet with the same content and the one provided
* @throws NullPointerException if contextSet is null
*/
public static ImmutableContextSet fromSet(ContextSet contextSet) {
return contextSet.makeImmutable();
public static @NonNull ImmutableContextSet fromSet(@NonNull ContextSet contextSet) {
return Objects.requireNonNull(contextSet, "contextSet").makeImmutable();
}
/**
* Creates a new empty ContextSet.
* Returns an empty {@link ImmutableContextSet}.
*
* @return a new ContextSet
* @return an empty ImmutableContextSet
*/
public static ImmutableContextSet empty() {
public static @NonNull ImmutableContextSet empty() {
return EMPTY;
}
private final Multimap<String, String> map;
private final ImmutableSetMultimap<String, String> map;
private final int hashCode;
ImmutableContextSet(Multimap<String, String> contexts) {
this.map = ImmutableMultimap.copyOf(contexts);
ImmutableContextSet(ImmutableSetMultimap<String, String> contexts) {
this.map = contexts;
this.hashCode = this.map.hashCode();
}
@Override
protected SetMultimap<String, String> backing() {
return this.map;
}
@Override
protected void copyTo(SetMultimap<String, String> other) {
other.putAll(this.map);
}
@Override
@@ -140,118 +172,205 @@ public final class ImmutableContextSet implements ContextSet {
return true;
}
@Override
@Deprecated // This set is already immutable!
public ImmutableContextSet makeImmutable() {
@Deprecated
@Override // This set is already immutable!
public @NonNull ImmutableContextSet makeImmutable() {
return this;
}
@Override
public MutableContextSet mutableCopy() {
public @NonNull MutableContextSet mutableCopy() {
return MutableContextSet.fromSet(this);
}
@Override
public Set<Map.Entry<String, String>> toSet() {
return ImmutableSet.copyOf(map.entries());
public @NonNull Set<Map.Entry<String, String>> toSet() {
return this.map.entries();
}
@Deprecated
@Override
public Map<String, String> toMap() {
public @NonNull Map<String, String> toMap() {
ImmutableMap.Builder<String, String> m = ImmutableMap.builder();
for (Map.Entry<String, String> e : map.entries()) {
for (Map.Entry<String, String> e : this.map.entries()) {
m.put(e.getKey(), e.getValue());
}
return m.build();
}
@Override
public Multimap<String, String> toMultimap() {
return map;
public @NonNull Multimap<String, String> toMultimap() {
return this.map;
}
@Override
public boolean containsKey(String key) {
if (key == null) {
throw new NullPointerException("key");
}
return map.containsKey(key);
public @NonNull Iterator<Map.Entry<String, String>> iterator() {
return this.map.entries().iterator();
}
@Override
public Set<String> getValues(String key) {
if (key == null) {
throw new NullPointerException("key");
}
Collection<String> c = map.get(key);
return c != null && !c.isEmpty() ? ImmutableSet.copyOf(c) : ImmutableSet.of();
}
@Override
public boolean has(String key, String value) {
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
return map.containsEntry(key, value);
}
@Override
public boolean hasIgnoreCase(String key, String value) {
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
Collection<String> c = map.get(key);
if (c == null || c.isEmpty()) {
return false;
}
for (String val : c) {
if (val.equalsIgnoreCase(value)) {
return true;
}
}
return false;
}
@Override
public boolean isEmpty() {
return map.isEmpty();
}
@Override
public int size() {
return map.size();
public Spliterator<Map.Entry<String, String>> spliterator() {
return this.map.entries().spliterator();
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof ContextSet)) return false;
final ContextSet other = (ContextSet) o;
final ContextSet that = (ContextSet) o;
final Multimap<String, String> thisContexts = this.toMultimap();
final Multimap<String, String> otherContexts = other.toMultimap();
return thisContexts == null ? otherContexts == null : thisContexts.equals(otherContexts);
// fast(er) path for ImmutableContextSet comparisons
if (that instanceof ImmutableContextSet) {
ImmutableContextSet immutableThat = (ImmutableContextSet) that;
if (this.hashCode != immutableThat.hashCode) return false;
}
final Multimap<String, String> thatBacking;
if (that instanceof AbstractContextSet) {
thatBacking = ((AbstractContextSet) that).backing();
} else {
thatBacking = that.toMultimap();
}
return backing().equals(thatBacking);
}
@Override
public int hashCode() {
return 59 + (this.map == null ? 43 : this.map.hashCode());
return this.hashCode;
}
@Override
public String toString() {
return "ImmutableContextSet(contexts=" + this.map + ")";
}
/**
* A builder for {@link ImmutableContextSet}.
*
* @since 4.1
*/
public static final class Builder {
private ImmutableSetMultimap.Builder<String, String> builder;
private Builder() {
}
private synchronized ImmutableSetMultimap.Builder<String, String> builder() {
if (this.builder == null) {
this.builder = ImmutableSetMultimap.builder();
}
return this.builder;
}
private void put(String key, String value) {
builder().put(key, value);
}
/**
* Adds a context to the set.
*
* @param key the key to add
* @param value the value to add
* @return the builder
* @throws NullPointerException if the key or value is null
* @see MutableContextSet#add(String, String)
*/
public @NonNull Builder add(@NonNull String key, @NonNull String value) {
put(sanitizeKey(key), sanitizeValue(value));
return this;
}
/**
* Adds a context to the set.
*
* @param entry the entry to add
* @return the builder
* @throws NullPointerException if the entry is null
* @see MutableContextSet#add(Map.Entry)
*/
public @NonNull Builder add(Map.@NonNull Entry<String, String> entry) {
Objects.requireNonNull(entry, "entry");
add(entry.getKey(), entry.getValue());
return this;
}
/**
* Adds the contexts contained in the given {@link Iterable} to the set.
*
* @param iterable an iterable of key value context pairs
* @return the builder
* @throws NullPointerException if iterable is null
* @see MutableContextSet#addAll(Iterable)
*/
public @NonNull Builder addAll(@NonNull Iterable<? extends Map.Entry<String, String>> iterable) {
for (Map.Entry<String, String> e : Objects.requireNonNull(iterable, "iterable")) {
add(e);
}
return this;
}
/**
* Adds the contexts contained in the given {@link Map} to the set.
*
* @param map the map to add from
* @return the builder
* @throws NullPointerException if the map is null
* @see MutableContextSet#addAll(Map)
*/
public @NonNull Builder addAll(@NonNull Map<String, String> map) {
addAll(Objects.requireNonNull(map, "map").entrySet());
return this;
}
/**
* Adds the contexts contained in the given {@link Multimap} to the set.
*
* @param multimap the multimap to add from
* @return the builder
* @throws NullPointerException if the map is null
* @since 3.4
* @see MutableContextSet#addAll(Multimap)
*/
public @NonNull Builder addAll(@NonNull Multimap<String, String> multimap) {
addAll(Objects.requireNonNull(multimap, "multimap").entries());
return this;
}
/**
* Adds of of the contexts in another {@link ContextSet} to the set.
*
* @param contextSet the set to add from
* @return the builder
* @throws NullPointerException if the contextSet is null
* @see MutableContextSet#addAll(ContextSet)
*/
public @NonNull Builder addAll(@NonNull ContextSet contextSet) {
Objects.requireNonNull(contextSet, "contextSet");
if (contextSet instanceof AbstractContextSet) {
AbstractContextSet other = ((AbstractContextSet) contextSet);
if (!other.isEmpty()) {
builder().putAll(other.backing());
}
} else {
addAll(contextSet.toMultimap());
}
return this;
}
/**
* Creates a {@link ImmutableContextSet} from the values previously
* added to the builder.
*
* @return an {@link ImmutableContextSet} from the builder
*/
public @NonNull ImmutableContextSet build() {
if (this.builder == null) {
return empty();
} else {
return new ImmutableContextSet(this.builder.build());
}
}
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -25,106 +28,129 @@ package me.lucko.luckperms.api.context;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.SetMultimap;
import java.util.Collection;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.Spliterator;
/**
* A mutable implementation of {@link ContextSet}.
*
* @since 2.16
*/
public final class MutableContextSet implements ContextSet {
public final class MutableContextSet extends AbstractContextSet implements ContextSet {
/**
* Make a singleton MutableContextSet from a context pair
* Creates a {@link MutableContextSet} from a context pair.
*
* @param key the key
* @param value the value
* @return a new MutableContextSet containing one KV pair
* @return a new MutableContextSet containing one context pair
* @throws NullPointerException if key or value is null
*/
public static MutableContextSet singleton(String key, String value) {
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
MutableContextSet set = new MutableContextSet();
public static @NonNull MutableContextSet singleton(@NonNull String key, @NonNull String value) {
Objects.requireNonNull(key, "key");
Objects.requireNonNull(value, "value");
MutableContextSet set = MutableContextSet.create();
set.add(key, value);
return set;
}
/**
* Creates a MutableContextSet from an existing map
* Creates a {@link MutableContextSet} from two context pairs.
*
* @param map the map to copy from
* @return a new MutableContextSet representing the pairs from the map
* @throws NullPointerException if the map is null
* @param key1 the first key
* @param value1 the first value
* @param key2 the second key
* @param value2 the second value
* @return a new MutableContextSet containing the two pairs
* @throws NullPointerException if any of the keys or values are null
* @since 3.1
*/
public static MutableContextSet fromMap(Map<String, String> map) {
if (map == null) {
throw new NullPointerException("map");
}
MutableContextSet set = new MutableContextSet();
set.addAll(map);
public static @NonNull MutableContextSet of(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2) {
Objects.requireNonNull(key1, "key1");
Objects.requireNonNull(value1, "value1");
Objects.requireNonNull(key2, "key2");
Objects.requireNonNull(value2, "value2");
MutableContextSet set = create();
set.add(key1, value1);
set.add(key2, value2);
return set;
}
/**
* Creates a MutableContextSet from an existing iterable of Map Entries
* Creates a {@link MutableContextSet} from an existing {@link Iterable} of {@link Map.Entry}s.
*
* @param iterable the iterable to copy from
* @return a new MutableContextSet representing the pairs in the iterable
* @throws NullPointerException if the iterable is null
*/
public static MutableContextSet fromEntries(Iterable<? extends Map.Entry<String, String>> iterable) {
if (iterable == null) {
throw new NullPointerException("iterable");
}
MutableContextSet set = new MutableContextSet();
public static @NonNull MutableContextSet fromEntries(@NonNull Iterable<? extends Map.Entry<String, String>> iterable) {
Objects.requireNonNull(iterable, "iterable");
MutableContextSet set = create();
set.addAll(iterable);
return set;
}
/**
* Creates a MutableContextSet from an existing multimap
* Creates a {@link MutableContextSet} from an existing {@link Map}.
*
* @param map the map to copy from
* @return a new MutableContextSet representing the pairs from the map
* @throws NullPointerException if the map is null
*/
public static @NonNull MutableContextSet fromMap(@NonNull Map<String, String> map) {
Objects.requireNonNull(map, "map");
MutableContextSet set = create();
set.addAll(map);
return set;
}
/**
* Creates a {@link MutableContextSet} from an existing {@link Multimap}.
*
* @param multimap the multimap to copy from
* @return a new MutableContextSet representing the pairs in the multimap
* @throws NullPointerException if the multimap is null
* @since 2.16
*/
public static MutableContextSet fromMultimap(Multimap<String, String> multimap) {
if (multimap == null) {
throw new NullPointerException("multimap");
}
return fromEntries(multimap.entries());
public static @NonNull MutableContextSet fromMultimap(@NonNull Multimap<String, String> multimap) {
Objects.requireNonNull(multimap, "multimap");
MutableContextSet set = create();
set.addAll(multimap);
return set;
}
/**
* Creates a new MutableContextSet from an existing set.
* Only really useful for converting between mutable and immutable types.
* Creates a new {@link MutableContextSet} from an existing {@link Set}.
*
* <p>Only really useful for converting between mutable and immutable types.</p>
*
* @param contextSet the context set to copy from
* @return a new MutableContextSet with the same content and the one provided
* @throws NullPointerException if contextSet is null
*/
public static MutableContextSet fromSet(ContextSet contextSet) {
if (contextSet == null) {
throw new NullPointerException("contextSet");
}
public static @NonNull MutableContextSet fromSet(@NonNull ContextSet contextSet) {
Objects.requireNonNull(contextSet, "contextSet");
MutableContextSet set = new MutableContextSet();
set.addAll(contextSet.toSet());
return set;
if (contextSet instanceof ImmutableContextSet) {
SetMultimap<String, String> map = ((ImmutableContextSet) contextSet).backing();
return new MutableContextSet(map);
} else if (contextSet instanceof MutableContextSet) {
return contextSet.mutableCopy();
} else {
MutableContextSet set = create();
set.addAll(contextSet);
return set;
}
}
/**
@@ -132,18 +158,30 @@ public final class MutableContextSet implements ContextSet {
*
* @return a new MutableContextSet
*/
public static MutableContextSet create() {
public static @NonNull MutableContextSet create() {
return new MutableContextSet();
}
private final Multimap<String, String> map;
private final SetMultimap<String, String> map;
public MutableContextSet() {
this.map = Multimaps.synchronizedMultimap(HashMultimap.create());
this.map = Multimaps.synchronizedSetMultimap(HashMultimap.create());
}
private MutableContextSet(Multimap<String, String> contexts) {
this.map = Multimaps.synchronizedMultimap(HashMultimap.create(contexts));
private MutableContextSet(SetMultimap<String, String> other) {
this.map = Multimaps.synchronizedSetMultimap(HashMultimap.create(other));
}
@Override
protected SetMultimap<String, String> backing() {
return this.map;
}
@Override
protected void copyTo(SetMultimap<String, String> other) {
synchronized (this.map) {
other.putAll(this.map);
}
}
@Override
@@ -152,244 +190,175 @@ public final class MutableContextSet implements ContextSet {
}
@Override
public ImmutableContextSet makeImmutable() {
return new ImmutableContextSet(map);
}
@Override
public MutableContextSet mutableCopy() {
return new MutableContextSet(map);
}
@Override
public Set<Map.Entry<String, String>> toSet() {
return ImmutableSet.copyOf(map.entries());
}
@Override
public Map<String, String> toMap() {
ImmutableMap.Builder<String, String> m = ImmutableMap.builder();
for (Map.Entry<String, String> e : map.entries()) {
m.put(e.getKey(), e.getValue());
public @NonNull ImmutableContextSet makeImmutable() {
// if the map is empty, don't create a new instance
if (this.map.isEmpty()) {
return ImmutableContextSet.empty();
}
synchronized (this.map) {
return new ImmutableContextSet(ImmutableSetMultimap.copyOf(this.map));
}
}
@Override
public @NonNull MutableContextSet mutableCopy() {
synchronized (this.map) {
return new MutableContextSet(this.map);
}
}
@Override
public @NonNull Set<Map.Entry<String, String>> toSet() {
synchronized (this.map) {
// map.entries() returns immutable Map.Entry instances, so we can just call copyOf
return ImmutableSet.copyOf(this.map.entries());
}
}
@Deprecated
@Override
public @NonNull Map<String, String> toMap() {
ImmutableMap.Builder<String, String> m = ImmutableMap.builder();
synchronized (this.map) {
for (Map.Entry<String, String> e : this.map.entries()) {
m.put(e.getKey(), e.getValue());
}
}
return m.build();
}
@Override
public Multimap<String, String> toMultimap() {
return map;
public @NonNull Multimap<String, String> toMultimap() {
synchronized (this.map) {
return ImmutableSetMultimap.copyOf(this.map);
}
}
@Override
public boolean containsKey(String key) {
if (key == null) {
throw new NullPointerException("key");
}
return map.containsKey(key);
public @NonNull Iterator<Map.Entry<String, String>> iterator() {
return toSet().iterator();
}
@Override
public Set<String> getValues(String key) {
if (key == null) {
throw new NullPointerException("key");
}
Collection<String> c = map.get(key);
return c != null && !c.isEmpty() ? ImmutableSet.copyOf(c) : ImmutableSet.of();
}
@Override
public boolean has(String key, String value) {
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
return map.containsEntry(key, value);
}
@Override
public boolean hasIgnoreCase(String key, String value) {
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
Collection<String> c = map.get(key);
if (c == null || c.isEmpty()) {
return false;
}
for (String val : c) {
if (val.equalsIgnoreCase(value)) {
return true;
}
}
return false;
}
@Override
public boolean isEmpty() {
return map.isEmpty();
}
@Override
public int size() {
return map.size();
public Spliterator<Map.Entry<String, String>> spliterator() {
return toSet().spliterator();
}
/**
* Adds a new key value pair to the set
* Adds a context to this set.
*
* @param key the key to add
* @param value the value to add
* @throws NullPointerException if the key or value is null
*/
public void add(String key, String value) {
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
map.put(key.toLowerCase(), value);
public void add(@NonNull String key, @NonNull String value) {
this.map.put(sanitizeKey(key), sanitizeValue(value));
}
/**
* Adds a new key value pair to the set
* Adds a context to this set.
*
* @param entry the entry to add
* @throws NullPointerException if the entry is null
*/
public void add(Map.Entry<String, String> entry) {
if (entry == null) {
throw new NullPointerException("context");
}
map.put(entry.getKey().toLowerCase(), entry.getValue());
public void add(Map.@NonNull Entry<String, String> entry) {
Objects.requireNonNull(entry, "entry");
add(entry.getKey(), entry.getValue());
}
/**
* Adds an iterable containing contexts to the set
* Adds the contexts contained in the given {@link Iterable} to this set.
*
* @param iterable an iterable of key value context pairs
* @throws NullPointerException if iterable is null
*/
public void addAll(Iterable<? extends Map.Entry<String, String>> iterable) {
if (iterable == null) {
throw new NullPointerException("contexts");
}
for (Map.Entry<String, String> e : iterable) {
this.map.put(e.getKey().toLowerCase(), e.getValue());
public void addAll(@NonNull Iterable<? extends Map.Entry<String, String>> iterable) {
for (Map.Entry<String, String> e : Objects.requireNonNull(iterable, "iterable")) {
add(e);
}
}
/**
* Adds the entry set of a map to the set
* Adds the contexts contained in the given {@link Map} to this set.
*
* @param map the map to add from
* @throws NullPointerException if the map is null
*/
public void addAll(Map<String, String> map) {
if (map == null) {
throw new NullPointerException("contexts");
}
addAll(map.entrySet());
public void addAll(@NonNull Map<String, String> map) {
addAll(Objects.requireNonNull(map, "map").entrySet());
}
/**
* Adds of of the values in another ContextSet to this set
* Adds the contexts contained in the given {@link Multimap} to this set.
*
* @param multimap the multimap to add from
* @throws NullPointerException if the map is null
* @since 3.4
*/
public void addAll(@NonNull Multimap<String, String> multimap) {
addAll(Objects.requireNonNull(multimap, "multimap").entries());
}
/**
* Adds of of the contexts in another {@link ContextSet} to this set.
*
* @param contextSet the set to add from
* @throws NullPointerException if the contextSet is null
*/
public void addAll(ContextSet contextSet) {
if (contextSet == null) {
throw new NullPointerException("contextSet");
public void addAll(@NonNull ContextSet contextSet) {
Objects.requireNonNull(contextSet, "contextSet");
if (contextSet instanceof AbstractContextSet) {
AbstractContextSet other = ((AbstractContextSet) contextSet);
synchronized (this.map) {
other.copyTo(this.map);
}
} else {
addAll(contextSet.toMultimap());
}
this.map.putAll(contextSet.toMultimap());
}
/**
* Remove a key value pair from this set
*
* @param key the key to remove
* @param value the value to remove (case sensitive)
* @throws NullPointerException if the key or value is null
*/
public void remove(String key, String value) {
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
map.entries().removeIf(entry -> entry.getKey().equalsIgnoreCase(key) && entry.getValue().equals(value));
}
/**
* Same as {@link #remove(String, String)}, except ignores the case of the value
* Removes a context from this set.
*
* @param key the key to remove
* @param value the value to remove
* @throws NullPointerException if the key or value is null
*/
public void removeIgnoreCase(String key, String value) {
if (key == null) {
throw new NullPointerException("key");
}
if (value == null) {
throw new NullPointerException("value");
}
map.entries().removeIf(e -> e.getKey().equalsIgnoreCase(key) && e.getValue().equalsIgnoreCase(value));
public void remove(@NonNull String key, @NonNull String value) {
this.map.remove(sanitizeKey(key), sanitizeValue(value));
}
/**
* Removes all pairs with the given key
* Removes all contexts from this set with the given key.
*
* @param key the key to remove
* @throws NullPointerException if the key is null
*/
public void removeAll(String key) {
if (key == null) {
throw new NullPointerException("key");
}
map.removeAll(key.toLowerCase());
public void removeAll(@NonNull String key) {
this.map.removeAll(sanitizeKey(key));
}
/**
* Clears the set
* Removes all contexts from the set.
*/
public void clear() {
map.clear();
this.map.clear();
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof ContextSet)) return false;
final ContextSet other = (ContextSet) o;
final ContextSet that = (ContextSet) o;
final Multimap<String, String> thisContexts = this.toMultimap();
final Multimap<String, String> otherContexts = other.toMultimap();
return thisContexts == null ? otherContexts == null : thisContexts.equals(otherContexts);
}
final Multimap<String, String> thatBacking;
if (that instanceof AbstractContextSet) {
thatBacking = ((AbstractContextSet) that).backing();
} else {
thatBacking = that.toMultimap();
}
@Override
public int hashCode() {
return 59 + (this.map == null ? 43 : this.map.hashCode());
return backing().equals(thatBacking);
}
@Override
@@ -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 me.lucko.luckperms.api.context;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Extension of {@link ContextCalculator} which provides the same context
* regardless of the subject.
*
* @since 4.0
*/
@FunctionalInterface
public interface StaticContextCalculator extends ContextCalculator<Object> {
/**
* Adds this calculators context to the given accumulator.
*
* @param accumulator a map of contexts to add to
* @return the map
*/
@NonNull MutableContextSet giveApplicableContext(@NonNull MutableContextSet accumulator);
/**
* Gives the subject all of the applicable contexts they meet
*
* @param subject the subject to add contexts to
* @param accumulator a map of contexts to add to
* @return the map
*/
@Deprecated
@Override
default @NonNull MutableContextSet giveApplicableContext(@Nullable Object subject, @NonNull MutableContextSet accumulator) {
return giveApplicableContext(accumulator);
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,6 +25,8 @@
package me.lucko.luckperms.api.event;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.concurrent.atomic.AtomicBoolean;
/**
@@ -34,6 +39,37 @@ public interface Cancellable {
*
* @return the cancellation
*/
AtomicBoolean getCancellationState();
@NonNull @Param(-1) AtomicBoolean getCancellationState();
/**
* Returns true if the event is currently cancelled.
*
* @return if the event is cancelled
* @since 4.1
*/
default boolean isCancelled() {
return getCancellationState().get();
}
/**
* Returns true if the event is not currently cancelled.
*
* @return if the event is not cancelled
* @since 4.1
*/
default boolean isNotCancelled() {
return !isCancelled();
}
/**
* Sets the cancellation state of the event.
*
* @param cancelled the new state
* @return the previous state
* @since 4.1
*/
default boolean setCancelled(boolean cancelled) {
return getCancellationState().getAndSet(cancelled);
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,33 +25,61 @@
package me.lucko.luckperms.api.event;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Set;
import java.util.function.Consumer;
/**
* The LuckPerms event bus. Used for subscribing (or registering listeners) to events.
* The LuckPerms event bus.
*
* <p>Used to subscribe (or "listen") to LuckPerms events.</p>
*
* @since 3.0
*/
public interface EventBus {
/**
* Subscribe to an event
* Registers a new subscription to the given event.
*
* <p>The returned {@link EventHandler} instance encapsulates the subscription state. It has
* methods which can be used to terminate the subscription, or view stats about the nature of
* the subscription.</p>
*
* @param eventClass the event class
* @param handler the event handler
* @param <T> the event class
* @return an event handler instance representing this subscription
*/
<T extends LuckPermsEvent> EventHandler<T> subscribe(Class<T> eventClass, Consumer<T> handler);
@NonNull <T extends LuckPermsEvent> EventHandler<T> subscribe(@NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler);
/**
* Gets a set of all registered handlers for a given event
* Registers a new subscription to the given event.
*
* <p>The returned {@link EventHandler} instance encapsulates the subscription state. It has
* methods which can be used to terminate the subscription, or view stats about the nature of
* the subscription.</p>
*
* <p>Unlike {@link #subscribe(Class, Consumer)}, this method accepts an additional parameter
* for {@code plugin}. This object must be a "plugin" instance on the platform, and is used to
* automatically {@link EventHandler#unregister() unregister} the subscription when the
* corresponding plugin is disabled.</p>
*
* @param <T> the event class
* @param plugin a plugin instance to bind the subscription to.
* @param eventClass the event class
* @param handler the event handler
* @return an event handler instance representing this subscription
*/
@NonNull <T extends LuckPermsEvent> EventHandler<T> subscribe(Object plugin, @NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler);
/**
* Gets a set of all registered handlers for a given event.
*
* @param eventClass the event to find handlers for
* @param <T> the event class
* @return an immutable set of event handlers
*/
<T extends LuckPermsEvent> Set<EventHandler<T>> getHandlers(Class<T> eventClass);
@NonNull <T extends LuckPermsEvent> Set<EventHandler<T>> getHandlers(@NonNull Class<T> eventClass);
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,21 +25,23 @@
package me.lucko.luckperms.api.event;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.function.Consumer;
/**
* Represents a handler for a LuckPerms event
* Represents a subscription to a {@link LuckPermsEvent}.
*
* @param <T> the event class
*/
public interface EventHandler<T extends LuckPermsEvent> {
public interface EventHandler<T extends LuckPermsEvent> extends AutoCloseable {
/**
* Gets the class this handler is listening to
*
* @return the event class
*/
Class<T> getEventClass();
@NonNull Class<T> getEventClass();
/**
* Returns true if this handler is active
@@ -57,7 +62,7 @@ public interface EventHandler<T extends LuckPermsEvent> {
*
* @return the event consumer
*/
Consumer<T> getConsumer();
@NonNull Consumer<? super T> getConsumer();
/**
* Gets the number of times this handler has been called
@@ -66,4 +71,8 @@ public interface EventHandler<T extends LuckPermsEvent> {
*/
int getCallCount();
@Override
default void close() {
unregister();
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -24,8 +27,10 @@ package me.lucko.luckperms.api.event;
import me.lucko.luckperms.api.LuckPermsApi;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* The base event interface
* A superinterface for all LuckPerms events.
*
* @since 3.0
*/
@@ -36,6 +41,14 @@ public interface LuckPermsEvent {
*
* @return the api instance
*/
LuckPermsApi getApi();
@NonNull LuckPermsApi getApi();
/**
* Gets the type of the event.
*
* @return the type of the event
* @since 4.4
*/
@NonNull Class<? extends LuckPermsEvent> getEventType();
}
@@ -0,0 +1,49 @@
/*
* 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 me.lucko.luckperms.api.event;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Represents the position of a parameter within an event.
*
* <p>This is an implementation detail and should not be relied upon.</p>
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Param {
/**
* Gets the index of the parameter.
*
* @return the index
*/
int value();
}
@@ -0,0 +1,49 @@
/*
* 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 me.lucko.luckperms.api.event;
import me.lucko.luckperms.api.event.source.Source;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Represents an event with a {@link Source}.
*
* @since 4.1
*/
public interface Sourced {
/**
* Gets the events source.
*
* <p>Never returns null. In situations where the source is unknown, a
* {@link Source} with type {@link Source.Type#UNKNOWN} is returned.</p>
*
* @return the source
*/
@NonNull @Param(-1) Source getSource();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -40,6 +43,6 @@ public enum CreationCause {
/**
* The creation was caused by a LuckPerms internal
*/
INTERNAL;
INTERNAL
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -40,6 +43,6 @@ public enum DeletionCause {
/**
* The deletion was caused by a LuckPerms internal
*/
INTERNAL;
INTERNAL
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -20,18 +23,34 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.event;
package me.lucko.luckperms.api.event.group;
import lombok.Getter;
import lombok.Setter;
import me.lucko.luckperms.api.LuckPermsApi;
import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.api.caching.GroupData;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
public abstract class AbstractEvent implements LuckPermsEvent {
import org.checkerframework.checker.nullness.qual.NonNull;
@Getter
@Setter
private LuckPermsApi api = null;
/**
* Called when a groups {@link GroupData} is loaded.
*
* @since 4.0
*/
public interface GroupCacheLoadEvent extends LuckPermsEvent {
/**
* Gets the group whose data was loaded
*
* @return the group
*/
@NonNull @Param(0) Group getGroup();
/**
* Gets the data that was loaded
*
* @return the loaded data
*/
@NonNull @Param(1) GroupData getLoadedData();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -24,8 +27,11 @@ package me.lucko.luckperms.api.event.group;
import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import me.lucko.luckperms.api.event.cause.CreationCause;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a group is created
*/
@@ -36,13 +42,13 @@ public interface GroupCreateEvent extends LuckPermsEvent {
*
* @return the new group
*/
Group getGroup();
@NonNull @Param(0) Group getGroup();
/**
* Gets the cause of the creation
*
* @return the cause of the creation
*/
CreationCause getCause();
@NonNull @Param(1) CreationCause getCause();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -20,23 +23,34 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.event.impl;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
package me.lucko.luckperms.api.event.group;
import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.api.event.cause.CreationCause;
import me.lucko.luckperms.api.event.group.GroupCreateEvent;
import me.lucko.luckperms.common.event.AbstractEvent;
import me.lucko.luckperms.api.caching.GroupData;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
@Getter
@ToString
@AllArgsConstructor
public class EventGroupCreate extends AbstractEvent implements GroupCreateEvent {
import org.checkerframework.checker.nullness.qual.NonNull;
private final Group group;
private final CreationCause cause;
/**
* Called when a groups cached data is refreshed
*
* @since 4.0
*/
public interface GroupDataRecalculateEvent extends LuckPermsEvent {
/**
* Gets the group whose data was recalculated
*
* @return the group
*/
@NonNull @Param(0) Group getGroup();
/**
* Gets the data that was recalculated
*
* @return the data
*/
@NonNull @Param(1) GroupData getData();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -24,8 +27,11 @@ package me.lucko.luckperms.api.event.group;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import me.lucko.luckperms.api.event.cause.DeletionCause;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Set;
/**
@@ -38,20 +44,20 @@ public interface GroupDeleteEvent extends LuckPermsEvent {
*
* @return the name of the deleted group
*/
String getGroupName();
@NonNull @Param(0) String getGroupName();
/**
* Gets an immutable copy of the groups existing data
*
* @return a copy of the groups existing data
*/
Set<Node> getExistingData();
@NonNull @Param(1) Set<Node> getExistingData();
/**
* Gets the cause of the deletion
*
* @return the cause of the deletion
*/
DeletionCause getCause();
@NonNull @Param(2) DeletionCause getCause();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -24,6 +27,9 @@ package me.lucko.luckperms.api.event.group;
import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a group is loaded into memory from the storage.
@@ -37,6 +43,6 @@ public interface GroupLoadEvent extends LuckPermsEvent {
*
* @return the group that was loaded
*/
Group getGroup();
@NonNull @Param(0) Group getGroup();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -25,6 +28,9 @@ package me.lucko.luckperms.api.event.log;
import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.api.event.Cancellable;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a log entry is about to be sent to notifiable players on the platform
@@ -36,6 +42,37 @@ public interface LogBroadcastEvent extends LuckPermsEvent, Cancellable {
*
* @return the log entry to be broadcasted
*/
LogEntry getEntry();
@NonNull @Param(0) LogEntry getEntry();
/**
* Gets where the log entry originated from.
*
* @return the origin of the log
* @since 3.3
*/
@NonNull @Param(1) Origin getOrigin();
/**
* Represents where a log entry is from
*
* @since 3.3
*/
enum Origin {
/**
* Marks a log entry which originated from the current server instance
*/
LOCAL,
/**
* Marks a log entry which originated from an API call on the current server instance
*/
LOCAL_API,
/**
* Marks a log entry which was sent to this server via the messaging service
*/
REMOTE
}
}
@@ -0,0 +1,58 @@
/*
* 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 me.lucko.luckperms.api.event.log;
import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.api.event.Cancellable;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.UUID;
/**
* Called when a log is about to be published to the network via the MessagingService
*
* @since 3.3
*/
public interface LogNetworkPublishEvent extends LuckPermsEvent, Cancellable {
/**
* Gets the ID of the log entry being published
*
* @return the id of the log entry being published
*/
@NonNull @Param(0) UUID getLogId();
/**
* Gets the log entry to be published
*
* @return the log entry to be published
*/
@NonNull @Param(1) LogEntry getEntry();
}
@@ -0,0 +1,90 @@
/*
* 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 me.lucko.luckperms.api.event.log;
import me.lucko.luckperms.api.Entity;
import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.api.event.Cancellable;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a log entry is about to be sent to specific notifiable object on
* the platform.
*
* <p>This event is not called for players without the notify permission,
* but is called for objects which are ignoring log notifications (called with
* the cancelled flag set to true).</p>
*
* @since 4.1
*/
public interface LogNotifyEvent extends LuckPermsEvent, Cancellable {
/**
* Gets the log entry to be sent
*
* @return the log entry to be sent
*/
@NonNull @Param(0) LogEntry getEntry();
/**
* Gets where the log entry originated from.
*
* @return the origin of the log
*/
@NonNull @Param(1) Origin getOrigin();
/**
* Gets the object to be notified.
*
* @return the object to notify
*/
@NonNull @Param(2) Entity getNotifiable();
/**
* Represents where a log entry is from
*/
enum Origin {
/**
* Marks a log entry which originated from the current server instance
*/
LOCAL,
/**
* Marks a log entry which originated from an API call on the current server instance
*/
LOCAL_API,
/**
* Marks a log entry which was sent to this server via the messaging service
*/
REMOTE
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -25,6 +28,9 @@ package me.lucko.luckperms.api.event.log;
import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.api.event.Cancellable;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a log is about to be published to the storage file/table
@@ -36,6 +42,6 @@ public interface LogPublishEvent extends LuckPermsEvent, Cancellable {
*
* @return the log entry to be published
*/
LogEntry getEntry();
@NonNull @Param(0) LogEntry getEntry();
}
@@ -0,0 +1,57 @@
/*
* 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 me.lucko.luckperms.api.event.log;
import me.lucko.luckperms.api.LogEntry;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.UUID;
/**
* Called when a log entry is received via the MessagingService
*
* @since 3.3
*/
public interface LogReceiveEvent extends LuckPermsEvent {
/**
* Gets the ID of the log entry being received
*
* @return the id of the log entry being received
*/
@NonNull @Param(0) UUID getLogId();
/**
* Gets the log entry being received
*
* @return the log entry being received
*/
@NonNull @Param(1) LogEntry getEntry();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -23,6 +26,9 @@
package me.lucko.luckperms.api.event.node;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a node is added to a holder
@@ -34,6 +40,6 @@ public interface NodeAddEvent extends NodeMutateEvent {
*
* @return the node that was added
*/
Node getNode();
@NonNull @Param(3) Node getNode();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,9 +25,14 @@
package me.lucko.luckperms.api.event.node;
import me.lucko.luckperms.api.Group;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.PermissionHolder;
import me.lucko.luckperms.api.User;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Set;
@@ -38,21 +46,21 @@ public interface NodeMutateEvent extends LuckPermsEvent {
*
* @return the event target
*/
PermissionHolder getTarget();
@NonNull @Param(0) PermissionHolder getTarget();
/**
* Gets an immutable copy of the holders data before the change
*
* @return the data before the change
*/
Set<Node> getDataBefore();
@NonNull @Param(1) Set<Node> getDataBefore();
/**
* Gets an immutable copy of the holders data after the change
*
* @return the data after the change
*/
Set<Node> getDataAfter();
@NonNull @Param(2) Set<Node> getDataAfter();
/**
* Gets whether the target of this event is a {@link me.lucko.luckperms.api.User}
@@ -61,7 +69,9 @@ public interface NodeMutateEvent extends LuckPermsEvent {
*
* @return if the event is targeting a user
*/
boolean isUser();
default boolean isUser() {
return getTarget() instanceof User;
}
/**
* Gets whether the target of this event is a {@link me.lucko.luckperms.api.Group}
@@ -70,6 +80,8 @@ public interface NodeMutateEvent extends LuckPermsEvent {
*
* @return if the event is targeting a group
*/
boolean isGroup();
default boolean isGroup() {
return getTarget() instanceof Group;
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -23,6 +26,9 @@
package me.lucko.luckperms.api.event.node;
import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a node is removed from a holder
@@ -34,6 +40,6 @@ public interface NodeRemoveEvent extends NodeMutateEvent {
*
* @return the node that was removed
*/
Node getNode();
@NonNull @Param(3) Node getNode();
}
@@ -0,0 +1,67 @@
/*
* 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 me.lucko.luckperms.api.event.player;
import me.lucko.luckperms.api.PlayerSaveResult;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import me.lucko.luckperms.api.manager.UserManager;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.UUID;
/**
* Called when player data is saved to the storage.
*
* <p>Data can be saved using {@link UserManager#savePlayerData(UUID, String)}.</p>
*
* @since 4.3
*/
public interface PlayerDataSaveEvent extends LuckPermsEvent {
/**
* Gets the unique ID that was saved.
*
* @return the uuid
*/
@NonNull @Param(0) UUID getUuid();
/**
* Gets the username that was saved.
*
* @return the username
*/
@NonNull @Param(1) String getUsername();
/**
* Gets the result of the operation.
*
* @return the result
*/
@NonNull @Param(2) PlayerSaveResult getResult();
}
@@ -0,0 +1,90 @@
/*
* 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 me.lucko.luckperms.api.event.player;
import me.lucko.luckperms.api.User;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.UUID;
/**
* Called when LuckPerms has finished processing a Player's initial connection.
*
* <p>This event will always execute during the platforms async connection
* event. The LuckPerms platform listener processing the connection will block
* while this event is posted.</p>
*
* <p>This, among other things, allows you to wait until permission data is
* loaded for a User during the BungeeCord 'LoginEvent', as event priorities are
* ignored by the current implementation.</p>
*
* <p>The implementation will make an attempt to ensure this event is called
* for all connections, even if the operation to load User data was not
* successful. Note that LuckPerms will usually cancel the platform connection
* event if data could not be loaded.</p>
*
* @since 4.4
*/
public interface PlayerLoginProcessEvent extends LuckPermsEvent {
/**
* Gets the UUID of the connection which was processed
*
* @return the uuid of the connection which was processed
*/
@NonNull @Param(0) UUID getUuid();
/**
* Gets the username of the connection which was processed
*
* @return the username of the connection which was processed
*/
@NonNull @Param(1) String getUsername();
/**
* Gets if the login was processed successfully.
*
* @return true if the login was successful
*/
default boolean wasSuccessful() {
return getUser() != null;
}
/**
* Gets the resultant User instance which was loaded.
*
* <p>Returns {@code null} if the login was not processed
* {@link #wasSuccessful() successfully.}</p>
*
* @return the user instance
*/
@Nullable @Param(2) User getUser();
}
@@ -0,0 +1,46 @@
/*
* 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 me.lucko.luckperms.api.event.source;
import me.lucko.luckperms.api.Entity;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Represents an {@link Entity} which was the {@link Source} of something.
*
* @since 4.1
*/
public interface EntitySource extends Source {
/**
* Gets the entity.
*
* @return the entity
*/
@NonNull Entity getEntity();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -20,32 +23,44 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.utils;
package me.lucko.luckperms.api.event.source;
import lombok.experimental.UtilityClass;
import me.lucko.luckperms.api.Entity;
import me.lucko.luckperms.common.constants.Patterns;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Utility for checking arguments for consistency
* Represents the source of an event.
*
* <p>Could also be described as the "thing" that caused an event to occur.</p>
*
* @since 4.1
*/
@UtilityClass
public class ArgumentChecker {
public interface Source {
public static boolean checkUsername(String s) {
return (s.length() > 16 || Patterns.NON_USERNAME.matcher(s).find());
}
/**
* Gets the source type
*
* @return the type
*/
@NonNull Type getType();
public static boolean checkName(String s) {
return (s.length() > 36 || Patterns.NON_ALPHA_NUMERIC.matcher(s).find());
}
/**
* Represents a type of source
*/
enum Type {
public static boolean checkNameWithSpace(String s) {
return (s.length() > 36 || Patterns.NON_ALPHA_NUMERIC_SPACE.matcher(s).find());
}
/**
* Represents an {@link Entity} source
*
* @see EntitySource
*/
ENTITY,
public static boolean checkTime(long l) {
return DateUtil.shouldExpire(l);
/**
* Represents an unknown source
*/
UNKNOWN
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -24,11 +27,14 @@ package me.lucko.luckperms.api.event.sync;
import me.lucko.luckperms.api.event.Cancellable;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.UUID;
/**
* Called before a network sync task runs
* Called before a received network sync task runs
*/
public interface PreNetworkSyncEvent extends LuckPermsEvent, Cancellable {
@@ -37,6 +43,6 @@ public interface PreNetworkSyncEvent extends LuckPermsEvent, Cancellable {
*
* @return the id of the sync request
*/
UUID getSyncId();
@NonNull @Param(0) UUID getSyncId();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -24,8 +27,11 @@ package me.lucko.luckperms.api.event.track;
import me.lucko.luckperms.api.Track;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import me.lucko.luckperms.api.event.cause.CreationCause;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a track is created
*/
@@ -36,13 +42,13 @@ public interface TrackCreateEvent extends LuckPermsEvent {
*
* @return the new track
*/
Track getTrack();
@NonNull @Param(0) Track getTrack();
/**
* Gets the cause of the creation
*
* @return the cause of the creation
*/
CreationCause getCause();
@NonNull @Param(1) CreationCause getCause();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -23,8 +26,11 @@
package me.lucko.luckperms.api.event.track;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import me.lucko.luckperms.api.event.cause.DeletionCause;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.List;
/**
@@ -37,20 +43,20 @@ public interface TrackDeleteEvent extends LuckPermsEvent {
*
* @return the name of the deleted track
*/
String getTrackName();
@NonNull @Param(0) String getTrackName();
/**
* Gets an immutable copy of the tracks existing data
*
* @return a copy of the tracks existing data
*/
List<String> getExistingData();
@NonNull @Param(1) List<String> getExistingData();
/**
* Gets the cause of the deletion
*
* @return the cause of the deletion
*/
DeletionCause getCause();
@NonNull @Param(2) DeletionCause getCause();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -24,6 +27,9 @@ package me.lucko.luckperms.api.event.track;
import me.lucko.luckperms.api.Track;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a track is loaded into memory from the storage.
@@ -37,6 +43,6 @@ public interface TrackLoadEvent extends LuckPermsEvent {
*
* @return the track that was loaded
*/
Track getTrack();
@NonNull @Param(0) Track getTrack();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,6 +25,10 @@
package me.lucko.luckperms.api.event.track.mutate;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a group is added to a track
*/
@@ -32,6 +39,6 @@ public interface TrackAddGroupEvent extends TrackMutateEvent {
*
* @return the group that was added
*/
String getGroup();
@NonNull @Param(3) String getGroup();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -24,6 +27,9 @@ package me.lucko.luckperms.api.event.track.mutate;
import me.lucko.luckperms.api.Track;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.List;
@@ -37,20 +43,20 @@ public interface TrackMutateEvent extends LuckPermsEvent {
*
* @return the track that was mutated
*/
Track getTrack();
@NonNull @Param(0) Track getTrack();
/**
* Gets an immutable copy of the tracks data before the change
*
* @return the data before the change
*/
List<String> getDataBefore();
@NonNull @Param(1) List<String> getDataBefore();
/**
* Gets an immutable copy of the tracks data after the change
*
* @return the data after the change
*/
List<String> getDataAfter();
@NonNull @Param(2) List<String> getDataAfter();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,6 +25,10 @@
package me.lucko.luckperms.api.event.track.mutate;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a group is removed from a track
*/
@@ -32,6 +39,6 @@ public interface TrackRemoveGroupEvent extends TrackMutateEvent {
*
* @return the group that was removed
*/
String getGroup();
@NonNull @Param(3) String getGroup();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -25,9 +28,12 @@ package me.lucko.luckperms.api.event.user;
import me.lucko.luckperms.api.User;
import me.lucko.luckperms.api.caching.UserData;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a users {@link me.lucko.luckperms.api.caching.UserData} is loaded.
* Called when a users {@link UserData} is loaded.
*/
public interface UserCacheLoadEvent extends LuckPermsEvent {
@@ -36,13 +42,13 @@ public interface UserCacheLoadEvent extends LuckPermsEvent {
*
* @return the user
*/
User getUser();
@NonNull @Param(0) User getUser();
/**
* Gets the data that was loaded
*
* @return the loaded data
*/
UserData getLoadedData();
@NonNull @Param(1) UserData getLoadedData();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -25,6 +28,9 @@ package me.lucko.luckperms.api.event.user;
import me.lucko.luckperms.api.User;
import me.lucko.luckperms.api.caching.UserData;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a users cached data is refreshed
@@ -36,13 +42,13 @@ public interface UserDataRecalculateEvent extends LuckPermsEvent {
*
* @return the user
*/
User getUser();
@NonNull @Param(0) User getUser();
/**
* Gets the data that was recalculated
*
* @return the data
*/
UserData getData();
@NonNull @Param(1) UserData getData();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -23,6 +26,9 @@
package me.lucko.luckperms.api.event.user;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.UUID;
@@ -44,13 +50,13 @@ public interface UserFirstLoginEvent extends LuckPermsEvent {
*
* @return the uuid of the user
*/
UUID getUuid();
@NonNull @Param(0) UUID getUuid();
/**
* Gets the username of the user
*
* @return the username of the user
*/
String getUsername();
@NonNull @Param(1) String getUsername();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -24,6 +27,9 @@ package me.lucko.luckperms.api.event.user;
import me.lucko.luckperms.api.User;
import me.lucko.luckperms.api.event.LuckPermsEvent;
import me.lucko.luckperms.api.event.Param;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a user is loaded into memory from the storage.
@@ -35,6 +41,6 @@ public interface UserLoadEvent extends LuckPermsEvent {
*
* @return the user that was loaded
*/
User getUser();
@NonNull @Param(0) User getUser();
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -35,6 +38,6 @@ public enum TrackAction {
/**
* The user was demoted down a track
*/
DEMOTION;
DEMOTION
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,6 +25,8 @@
package me.lucko.luckperms.api.event.user.track;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a user is demoted down a track.
*
@@ -29,4 +34,8 @@ package me.lucko.luckperms.api.event.user.track;
*/
public interface UserDemoteEvent extends UserTrackEvent {
@Override
default @NonNull TrackAction getAction() {
return TrackAction.DEMOTION;
}
}
@@ -1,5 +1,8 @@
/*
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
* 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
@@ -22,6 +25,8 @@
package me.lucko.luckperms.api.event.user.track;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Called when a user is promoted up a track.
*
@@ -29,4 +34,8 @@ package me.lucko.luckperms.api.event.user.track;
*/
public interface UserPromoteEvent extends UserTrackEvent {
@Override
default @NonNull TrackAction getAction() {
return TrackAction.PROMOTION;
}
}
Loaded 100 of 893 files, more files were not shown because too many files have changed in this diff. Show more