mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2026-11-25 09:54:21 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5577e3f590 | ||
|
|
ffe6c24b53 | ||
|
|
4e4982a98d | ||
|
|
7f4f9bb917 | ||
|
|
8d8024ba5e | ||
|
|
2e16b15b0e | ||
|
|
1ebed37297 | ||
|
|
ff37ad176b | ||
|
|
d0c5d89e91 | ||
|
|
f49446011a | ||
|
|
d762a0aaa6 | ||
|
|
2dc211a91e | ||
|
|
2c62de9658 | ||
|
|
494ab6787f | ||
|
|
b81e8a40a4 | ||
|
|
2fd2f4fedb | ||
|
|
493e5d08be | ||
|
|
62a834e145 | ||
|
|
241f13c8f1 | ||
|
|
98ea255667 | ||
|
|
420ec2bf1a | ||
|
|
364a494ac6 | ||
|
|
821d1cb8dd | ||
|
|
544ffbad19 | ||
|
|
4fa6cd2577 | ||
|
|
37d1f5efab | ||
|
|
7cd8e8bf5b | ||
|
|
8eed4558f4 | ||
|
|
62ca2d9c79 | ||
|
|
c7a0d7026c | ||
|
|
ce74813ce5 | ||
|
|
d1511e43f2 | ||
|
|
6ef749c76a | ||
|
|
8846932cb6 | ||
|
|
12b861db3f | ||
|
|
0a50df6557 | ||
|
|
3726f6de41 | ||
|
|
d1ca7684d6 | ||
|
|
512b621a7a | ||
|
|
2cf919a17a | ||
|
|
46072eb465 | ||
|
|
ae63a42c2e | ||
|
|
8773ec07ab | ||
|
|
287cc308d6 | ||
|
|
beeb4fa169 | ||
|
|
4ef3d50965 | ||
|
|
dae64fc8c4 | ||
|
|
215031a1f3 | ||
|
|
85d2f0b51f | ||
|
|
d91355e4d6 | ||
|
|
1a690dabd7 | ||
|
|
526448ce40 | ||
|
|
43d04a97f5 | ||
|
|
307614e704 | ||
|
|
f6c0794691 | ||
|
|
83db00aef8 | ||
|
|
22252fa46d | ||
|
|
7b8426977a | ||
|
|
d9912cb93f | ||
|
|
5db999f995 | ||
|
|
b744e35ad8 | ||
|
|
b6769811a2 | ||
|
|
1d9fc568e4 | ||
|
|
3c0d1ba7a1 | ||
|
|
78a74510cf | ||
|
|
d3ae3324fa | ||
|
|
4b97c9419e | ||
|
|
db830a0bef | ||
|
|
797c195424 | ||
|
|
4788290615 | ||
|
|
d0c016f6b7 | ||
|
|
9b1c73ed23 | ||
|
|
048768007d | ||
|
|
ec7a5321a6 | ||
|
|
c396323308 | ||
|
|
6fc2321fad | ||
|
|
a0d04790a5 | ||
|
|
c4154c09da | ||
|
|
8eed3131f2 | ||
|
|
e5c4b710f6 | ||
|
|
2ccffc6e6d | ||
|
|
fc69002c86 | ||
|
|
e3a6db5f97 | ||
|
|
6d8077ffd0 | ||
|
|
784161d66d | ||
|
|
115f793733 | ||
|
|
2cb5e437fd | ||
|
|
8c57c2b46d | ||
|
|
879a88a398 | ||
|
|
7e50c3c777 | ||
|
|
4b1cf51530 | ||
|
|
de24817d9c | ||
|
|
085e7af681 | ||
|
|
1aabd7610e | ||
|
|
ef31db1431 | ||
|
|
757e9d6be6 | ||
|
|
b3a028e3ca | ||
|
|
e222e4e98c | ||
|
|
1213e58240 | ||
|
|
b7ff0824b9 | ||
|
|
7b5917660c | ||
|
|
1544487e92 | ||
|
|
c19ef84116 | ||
|
|
e8c4a55dc3 | ||
|
|
97d6aaed5c | ||
|
|
fe77834cef | ||
|
|
2da6298c53 | ||
|
|
e111270aed | ||
|
|
e07f8c0fbe | ||
|
|
90246afd03 | ||
|
|
9809e591ad | ||
|
|
26973461e7 | ||
|
|
759ec5d499 | ||
|
|
58ab3c325c | ||
|
|
44c8c67803 | ||
|
|
acb56d683a | ||
|
|
5dda522a62 | ||
|
|
79091c726b | ||
|
|
e5be06e07b | ||
|
|
f63992e209 | ||
|
|
9988011308 | ||
|
|
8584a9b72c | ||
|
|
42c8cb1354 | ||
|
|
aaeaf5cfa0 | ||
|
|
45b4e1463f | ||
|
|
be92a67544 | ||
|
|
5e0b8ebdf6 | ||
|
|
9d4ccd33e1 | ||
|
|
f5c42c70e5 | ||
|
|
dcc4656e5e | ||
|
|
ee2de3cff1 | ||
|
|
f96518b8e4 | ||
|
|
dac59966aa | ||
|
|
8115fbaa98 | ||
|
|
8b97439ffc | ||
|
|
fa83986250 | ||
|
|
e1b16465f8 | ||
|
|
57619dacb1 | ||
|
|
64e54d89eb | ||
|
|
aa4139f0b7 | ||
|
|
e2f1c1e16b | ||
|
|
1e7ef15e54 | ||
|
|
1cc156d6f6 | ||
|
|
1445a3faec | ||
|
|
1cf90692cf | ||
|
|
5656bea3f9 | ||
|
|
8e344cea76 | ||
|
|
5b1229c882 | ||
|
|
834649b390 | ||
|
|
d28170cc3f | ||
|
|
04e511026d | ||
|
|
11a3ecbba0 | ||
|
|
51b7bb93e2 | ||
|
|
9fd2028d9f | ||
|
|
75f0f40d70 | ||
|
|
3941c77826 | ||
|
|
4987ca3ba2 | ||
|
|
5fa481337a | ||
|
|
dd78e0e271 | ||
|
|
3c773e6823 | ||
|
|
54a9ff9256 | ||
|
|
eca6b09b18 | ||
|
|
b7f8ca6658 | ||
|
|
ffdeadac8a | ||
|
|
9e769904bf | ||
|
|
8d79ec6b07 | ||
|
|
3a123f9fa1 | ||
|
|
f0c0328919 | ||
|
|
274286032a | ||
|
|
76517374a2 | ||
|
|
2da027f3b5 | ||
|
|
fd712f131f | ||
|
|
38613e5f03 | ||
|
|
ec9060ba80 | ||
|
|
502d57e744 | ||
|
|
c59f2ab37a | ||
|
|
066189b486 | ||
|
|
37d4f92c33 | ||
|
|
55220e9d10 | ||
|
|
bd41286076 | ||
|
|
d84484c81c | ||
|
|
fec87d4c6a | ||
|
|
68ec6e2a37 | ||
|
|
a784ad435f | ||
|
|
cc9bb34873 | ||
|
|
2ddae5a96c | ||
|
|
40ad489c56 | ||
|
|
56c55d71fe | ||
|
|
56df15caf8 | ||
|
|
03720665b3 | ||
|
|
445429b510 | ||
|
|
c698587d53 | ||
|
|
b8466beee5 | ||
|
|
efa666445f | ||
|
|
59c7d77525 | ||
|
|
553da9baf6 | ||
|
|
486ddb3d42 | ||
|
|
381922fc02 | ||
|
|
4c891f0819 | ||
|
|
4b3d11ccab | ||
|
|
b1ab465991 | ||
|
|
952e41ad3d | ||
|
|
ae3adf23c8 | ||
|
|
c3cdf387c2 | ||
|
|
054f0c2c19 | ||
|
|
2f7fce2109 | ||
|
|
07469599bc | ||
|
|
08869da96e | ||
|
|
7540a6eb70 | ||
|
|
fa2d9357b8 | ||
|
|
247a40b65f | ||
|
|
01ffe6ad5a | ||
|
|
da3c2a073a | ||
|
|
c16630c32b | ||
|
|
bf64f465a8 | ||
|
|
c1e0b874d8 | ||
|
|
c780266139 | ||
|
|
08454d58d0 | ||
|
|
ee13540d78 | ||
|
|
b4ff54ffc8 | ||
|
|
6f96d9c7d1 | ||
|
|
5b66436519 | ||
|
|
379eb00b69 | ||
|
|
2036127612 | ||
|
|
957a918bd6 | ||
|
|
6b305972ac | ||
|
|
b8c06904ab | ||
|
|
6baa472567 | ||
|
|
9c449def57 | ||
|
|
e4acc133a9 | ||
|
|
8b181b877b | ||
|
|
194790110d | ||
|
|
c0cd197bd0 | ||
|
|
30ce269873 | ||
|
|
4d7be13c16 | ||
|
|
8cf0f7da5f | ||
|
|
bcb4e5ca64 | ||
|
|
07b003c77a | ||
|
|
f4e4f727dd | ||
|
|
644c53a074 | ||
|
|
c66622bd09 | ||
|
|
adf0589184 | ||
|
|
b7de0e6901 | ||
|
|
a90e59ec97 | ||
|
|
f4882c1c14 | ||
|
|
ed3b5a3cf1 | ||
|
|
45e2b7b12f | ||
|
|
1e73986c60 | ||
|
|
20f992110d | ||
|
|
18f09f9862 | ||
|
|
a0be1c7c48 | ||
|
|
5d34661a15 | ||
|
|
1639879106 | ||
|
|
a927ca659f | ||
|
|
804c884d8b | ||
|
|
51f215b8ac |
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
patreon: luckperms
|
||||||
+22
-107
@@ -1,40 +1,12 @@
|
|||||||
# Created by https://www.gitignore.io/
|
|
||||||
|
|
||||||
### Intellij ###
|
### 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/
|
.idea/
|
||||||
*.iws
|
*.iws
|
||||||
/out/
|
/out/
|
||||||
*.iml
|
*.iml
|
||||||
.idea_modules/
|
.idea_modules/
|
||||||
|
|
||||||
# JIRA plugin
|
|
||||||
atlassian-ide-plugin.xml
|
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 ###
|
### Eclipse ###
|
||||||
|
|
||||||
.metadata
|
.metadata
|
||||||
bin/
|
bin/
|
||||||
tmp/
|
tmp/
|
||||||
@@ -46,73 +18,27 @@ local.properties
|
|||||||
.settings/
|
.settings/
|
||||||
.loadpath
|
.loadpath
|
||||||
.recommenders
|
.recommenders
|
||||||
|
|
||||||
# Eclipse Core
|
|
||||||
.project
|
|
||||||
|
|
||||||
# External tool builders
|
|
||||||
.externalToolBuilders/
|
.externalToolBuilders/
|
||||||
|
|
||||||
# Locally stored "Eclipse launch configurations"
|
|
||||||
*.launch
|
*.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
|
.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/
|
.recommenders/
|
||||||
|
.apt_generated/
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
|
||||||
### Linux ###
|
### Linux ###
|
||||||
*~
|
*~
|
||||||
|
|
||||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
|
||||||
.fuse_hidden*
|
.fuse_hidden*
|
||||||
|
|
||||||
# KDE directory preferences
|
|
||||||
.directory
|
.directory
|
||||||
|
|
||||||
# Linux trash folder which might appear on any partition or disk
|
|
||||||
.Trash-*
|
.Trash-*
|
||||||
|
|
||||||
# .nfs files are created when an open file is removed but is still being accessed
|
|
||||||
.nfs*
|
.nfs*
|
||||||
|
|
||||||
|
|
||||||
### macOS ###
|
### macOS ###
|
||||||
*.DS_Store
|
.DS_Store
|
||||||
.AppleDouble
|
.AppleDouble
|
||||||
.LSOverride
|
.LSOverride
|
||||||
|
|
||||||
# Icon must end with two \r
|
|
||||||
Icon
|
Icon
|
||||||
# Thumbnails
|
|
||||||
._*
|
._*
|
||||||
# Files that might appear in the root of a volume
|
|
||||||
.DocumentRevisions-V100
|
.DocumentRevisions-V100
|
||||||
.fseventsd
|
.fseventsd
|
||||||
.Spotlight-V100
|
.Spotlight-V100
|
||||||
@@ -120,45 +46,34 @@ Icon
|
|||||||
.Trashes
|
.Trashes
|
||||||
.VolumeIcon.icns
|
.VolumeIcon.icns
|
||||||
.com.apple.timemachine.donotpresent
|
.com.apple.timemachine.donotpresent
|
||||||
# Directories potentially created on remote AFP share
|
|
||||||
.AppleDB
|
.AppleDB
|
||||||
.AppleDesktop
|
.AppleDesktop
|
||||||
Network Trash Folder
|
Network Trash Folder
|
||||||
Temporary Items
|
Temporary Items
|
||||||
.apdisk
|
.apdisk
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
nbproject/private/
|
||||||
|
build/
|
||||||
|
nbbuild/
|
||||||
|
dist/
|
||||||
|
nbdist/
|
||||||
|
.nb-gradle/
|
||||||
|
|
||||||
### Windows ###
|
### Windows ###
|
||||||
# Windows image file caches
|
# Windows thumbnail cache files
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
ehthumbs.db
|
ehthumbs.db
|
||||||
|
ehthumbs_vista.db
|
||||||
# Folder config file
|
*.stackdump
|
||||||
Desktop.ini
|
[Dd]esktop.ini
|
||||||
|
|
||||||
# Recycle Bin used on file shares
|
|
||||||
$RECYCLE.BIN/
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
# Windows Installer files
|
|
||||||
*.cab
|
|
||||||
*.msi
|
|
||||||
*.msm
|
|
||||||
*.msp
|
|
||||||
|
|
||||||
# Windows shortcuts
|
|
||||||
*.lnk
|
*.lnk
|
||||||
|
|
||||||
|
### Gradle ###
|
||||||
### Java ###
|
.gradle
|
||||||
*.class
|
/build/
|
||||||
|
/out/
|
||||||
# Mobile Tools for Java (J2ME)
|
gradle-app.setting
|
||||||
.mtj.tmp/
|
!gradle-wrapper.jar
|
||||||
|
.gradletasknamecache
|
||||||
# Package Files #
|
|
||||||
*.jar
|
|
||||||
*.war
|
|
||||||
*.ear
|
|
||||||
|
|
||||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
|
||||||
hs_err_pid*
|
|
||||||
+2
-2
@@ -19,8 +19,8 @@ LuckPerms loosely follows the [Google Java Style Guide](https://google.github.io
|
|||||||
If you're considering submitting a substantial pull request, please open an issue so we can discuss the change before starting work on the contribution. Most pull requests are happily accepted, but larger changes may have an inpact on the maintainability of the project, and require more consideration.
|
If you're considering submitting a substantial pull request, please open an issue so we can discuss the change before starting work on the contribution. Most pull requests are happily accepted, but larger changes may have an inpact on the maintainability of the project, and require more consideration.
|
||||||
|
|
||||||
#### Project Layout
|
#### Project Layout
|
||||||
The project is split up into 5 seperate modules.
|
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.
|
* **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.
|
* **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** - Each use the common module to implement plugins on the respective server platforms.
|
* **Bukkit, BungeeCord, Sponge, Nukkit & Velocity** - Each use the common module to implement plugins on the respective server platforms.
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
|
||||||
|
Copyright (c) lucko (Luck) <[email protected]>
|
||||||
|
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.
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
The MIT License.
|
MIT License
|
||||||
|
|
||||||
Copyright (c) lucko (Luck) <[email protected]>
|
Copyright (c) lucko (Luck) <[email protected]>
|
||||||
Copyright (c) contributors
|
Copyright (c) contributors
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||

|

|
||||||
# LuckPerms [](https://ci.lucko.me/job/LuckPerms/) [](https://javadoc.io/doc/me.lucko.luckperms/luckperms-api) [](https://maven-badges.herokuapp.com/maven-central/me.lucko.luckperms/luckperms-api)
|
# LuckPerms
|
||||||
|
[](https://ci.lucko.me/job/LuckPerms/)
|
||||||
|
[](https://javadoc.io/doc/me.lucko.luckperms/luckperms-api)
|
||||||
|
[](https://search.maven.org/artifact/me.lucko.luckperms/luckperms-api)
|
||||||
|
[](https://discord.gg/luckperms)
|
||||||
|
|
||||||
LuckPerms is an advanced permissions implementation aiming to be a fast, reliable and flexible alternative to existing permission plugins. The project's main goals are centered around high performance and a wide feature set, filling the gaps of functionality and building upon existing features found in other plugins.
|
LuckPerms is 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.
|
||||||
|
|
||||||
@@ -14,21 +18,20 @@ The latest **downloads** can be found on the [project's homepage](https://luckpe
|
|||||||
More information about the project & how to use the plugin can be found in the [wiki](https://github.com/lucko/LuckPerms/wiki).
|
More information about the project & how to use the plugin can be found in the [wiki](https://github.com/lucko/LuckPerms/wiki).
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
LuckPerms uses Maven to handle dependencies.
|
LuckPerms uses Gradle to handle dependencies & building.
|
||||||
|
|
||||||
#### Requirements
|
#### Requirements
|
||||||
* Java 8 JDK or newer
|
* Java 8 JDK or newer
|
||||||
* Maven 3.3.x or newer (the older versions will not work.)
|
|
||||||
* Git
|
* Git
|
||||||
|
|
||||||
#### Compiling from source
|
#### Compiling from source
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/lucko/LuckPerms.git
|
git clone https://github.com/lucko/LuckPerms.git
|
||||||
cd LuckPerms/
|
cd LuckPerms/
|
||||||
mvn clean package
|
./gradlew build
|
||||||
```
|
```
|
||||||
|
|
||||||
You can find the output jars in the `target` directories.
|
You can find the output jars in the `build/libs` directories.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
#### Pull Requests
|
#### Pull Requests
|
||||||
@@ -37,14 +40,11 @@ If you make any changes or improvements to the plugin which you think would be b
|
|||||||
LuckPerms loosely follows the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). Generally, try to copy the style of code found in the class you're editing.
|
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
|
#### Project Layout
|
||||||
The project is split up into 5 seperate modules.
|
The project is split up into a few separate modules.
|
||||||
|
|
||||||
* **API** - The public, semantically versioned API used by other plugins wishing to integrate with and retrieve data from LuckPerms. This module (for the most part) does not contain any implementation itself, and is provided by the plugin.
|
* **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.
|
* **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** - Each use the common module to implement plugins on the respective server platforms.
|
* **Bukkit, BungeeCord, Sponge, Nukkit & Velocity** - Each use the common module to implement plugins on the respective server platforms.
|
||||||
|
|
||||||
## License
|
## 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 is licensed under the permissive MIT license. Please see [`LICENSE.txt`](https://github.com/lucko/LuckPerms/blob/master/LICENSE.txt) for more info.
|
||||||
|
|
||||||
## Thanks
|
|
||||||
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").
|
|
||||||
@@ -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 '[email protected]'
|
||||||
|
url 'https://github.com/lucko'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scm {
|
||||||
|
connection 'scm:git:https://github.com/lucko/LuckPerms.git'
|
||||||
|
developerConnection 'scm:git:[email protected]: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'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
-96
@@ -1,96 +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>4.2-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>luckperms-api</artifactId>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<finalName>LuckPerms-API-${release.version}</finalName>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>../</directory>
|
|
||||||
<filtering>false</filtering>
|
|
||||||
<includes>
|
|
||||||
<include>LICENSE.txt</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>${compiler.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<source>1.8</source>
|
|
||||||
<target>1.8</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>deployment</id>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
|
||||||
<version>3.0.1</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>attach-sources</id>
|
|
||||||
<goals>
|
|
||||||
<goal>jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>attach-javadocs</id>
|
|
||||||
<goals>
|
|
||||||
<goal>jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<links>
|
|
||||||
<link>https://google.github.io/guava/releases/21.0/api/docs/</link>
|
|
||||||
</links>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- guava -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.guava</groupId>
|
|
||||||
<artifactId>guava</artifactId>
|
|
||||||
<version>19.0</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- jsr305 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.code.findbugs</groupId>
|
|
||||||
<artifactId>jsr305</artifactId>
|
|
||||||
<version>3.0.2</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -27,9 +27,9 @@ package me.lucko.luckperms;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.LuckPermsApi;
|
import me.lucko.luckperms.api.LuckPermsApi;
|
||||||
|
|
||||||
import java.util.Optional;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides static access to the {@link LuckPermsApi}.
|
* Provides static access to the {@link LuckPermsApi}.
|
||||||
@@ -49,8 +49,7 @@ public final class LuckPerms {
|
|||||||
* @return an api instance
|
* @return an api instance
|
||||||
* @throws IllegalStateException if the api is not loaded
|
* @throws IllegalStateException if the api is not loaded
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull LuckPermsApi getApi() {
|
||||||
public static LuckPermsApi getApi() {
|
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
throw new IllegalStateException("API is not loaded.");
|
throw new IllegalStateException("API is not loaded.");
|
||||||
}
|
}
|
||||||
@@ -66,8 +65,7 @@ public final class LuckPerms {
|
|||||||
*
|
*
|
||||||
* @return an optional api instance
|
* @return an optional api instance
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull Optional<LuckPermsApi> getApiSafe() {
|
||||||
public static Optional<LuckPermsApi> getApiSafe() {
|
|
||||||
return Optional.ofNullable(instance);
|
return Optional.ofNullable(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the object responsible for handling action logging.
|
* Represents the object responsible for handling action logging.
|
||||||
@@ -41,8 +41,7 @@ public interface ActionLogger {
|
|||||||
*
|
*
|
||||||
* @return a new builder
|
* @return a new builder
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
LogEntry.@NonNull Builder newEntryBuilder();
|
||||||
LogEntry.Builder newEntryBuilder();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a {@link Log} instance from the plugin storage.
|
* Gets a {@link Log} instance from the plugin storage.
|
||||||
@@ -50,8 +49,7 @@ public interface ActionLogger {
|
|||||||
* @return a log instance
|
* @return a log instance
|
||||||
* @see Storage#getLog()
|
* @see Storage#getLog()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Log> getLog();
|
||||||
CompletableFuture<Log> getLog();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submits a log entry to the plugin to be handled.
|
* Submits a log entry to the plugin to be handled.
|
||||||
@@ -69,8 +67,7 @@ public interface ActionLogger {
|
|||||||
* @param entry the entry to submit
|
* @param entry the entry to submit
|
||||||
* @return a future which will complete when the action is done
|
* @return a future which will complete when the action is done
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Void> submit(@NonNull LogEntry entry);
|
||||||
CompletableFuture<Void> submit(@Nonnull LogEntry entry);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submits a log entry to the plugins storage handler.
|
* Submits a log entry to the plugins storage handler.
|
||||||
@@ -80,8 +77,7 @@ public interface ActionLogger {
|
|||||||
* @param entry the entry to submit
|
* @param entry the entry to submit
|
||||||
* @return a future which will complete when the action is done
|
* @return a future which will complete when the action is done
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Void> submitToStorage(@NonNull LogEntry entry);
|
||||||
CompletableFuture<Void> submitToStorage(@Nonnull LogEntry entry);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submits a log entry to the plugins log broadcasting handler.
|
* Submits a log entry to the plugins log broadcasting handler.
|
||||||
@@ -92,7 +88,6 @@ public interface ActionLogger {
|
|||||||
* @param entry the entry to submit
|
* @param entry the entry to submit
|
||||||
* @return a future which will complete when the action is done
|
* @return a future which will complete when the action is done
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Void> broadcastAction(@NonNull LogEntry entry);
|
||||||
CompletableFuture<Void> broadcastAction(@Nonnull LogEntry entry);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,12 +25,12 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a type of chat meta
|
* Represents a type of chat meta
|
||||||
*
|
*
|
||||||
@@ -43,13 +43,12 @@ public enum ChatMetaType {
|
|||||||
*/
|
*/
|
||||||
PREFIX("prefix") {
|
PREFIX("prefix") {
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(@Nonnull Node node) {
|
public boolean matches(@NonNull Node node) {
|
||||||
return Objects.requireNonNull(node, "node").isPrefix();
|
return Objects.requireNonNull(node, "node").isPrefix();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public Map.Entry<Integer, String> getEntry(@Nonnull Node node) {
|
public Map.@NonNull Entry<Integer, String> getEntry(@NonNull Node node) {
|
||||||
return Objects.requireNonNull(node, "node").getPrefix();
|
return Objects.requireNonNull(node, "node").getPrefix();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -59,13 +58,12 @@ public enum ChatMetaType {
|
|||||||
*/
|
*/
|
||||||
SUFFIX("suffix") {
|
SUFFIX("suffix") {
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(@Nonnull Node node) {
|
public boolean matches(@NonNull Node node) {
|
||||||
return Objects.requireNonNull(node, "node").isSuffix();
|
return Objects.requireNonNull(node, "node").isSuffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public Map.Entry<Integer, String> getEntry(@Nonnull Node node) {
|
public Map.@NonNull Entry<Integer, String> getEntry(@NonNull Node node) {
|
||||||
return Objects.requireNonNull(node, "node").getSuffix();
|
return Objects.requireNonNull(node, "node").getSuffix();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -82,7 +80,7 @@ public enum ChatMetaType {
|
|||||||
* @param node the node to test
|
* @param node the node to test
|
||||||
* @return true if the node has the same type
|
* @return true if the node has the same type
|
||||||
*/
|
*/
|
||||||
public abstract boolean matches(@Nonnull Node node);
|
public abstract boolean matches(@NonNull Node node);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the passed node should be ignored when searching for meta of this type
|
* Returns if the passed node should be ignored when searching for meta of this type
|
||||||
@@ -90,7 +88,7 @@ public enum ChatMetaType {
|
|||||||
* @param node the node to test
|
* @param node the node to test
|
||||||
* @return true if the node does not share the same type
|
* @return true if the node does not share the same type
|
||||||
*/
|
*/
|
||||||
public boolean shouldIgnore(@Nonnull Node node) {
|
public boolean shouldIgnore(@NonNull Node node) {
|
||||||
return !matches(node);
|
return !matches(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,8 +99,7 @@ public enum ChatMetaType {
|
|||||||
* @return the entry
|
* @return the entry
|
||||||
* @throws IllegalStateException if the node does not share the same type
|
* @throws IllegalStateException if the node does not share the same type
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public abstract Map.@NonNull Entry<Integer, String> getEntry(@NonNull Node node);
|
||||||
public abstract Map.Entry<Integer, String> getEntry(@Nonnull Node node);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
@@ -116,8 +113,7 @@ public enum ChatMetaType {
|
|||||||
* @return the parsed chat meta type
|
* @return the parsed chat meta type
|
||||||
* @since 3.4
|
* @since 3.4
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull Optional<ChatMetaType> ofNode(@NonNull Node node) {
|
||||||
public static Optional<ChatMetaType> ofNode(@Nonnull Node node) {
|
|
||||||
if (node.isPrefix()) {
|
if (node.isPrefix()) {
|
||||||
return Optional.of(PREFIX);
|
return Optional.of(PREFIX);
|
||||||
} else if (node.isSuffix()) {
|
} else if (node.isSuffix()) {
|
||||||
|
|||||||
@@ -25,18 +25,14 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates the {@link ContextSet contexts} and {@link LookupSetting settings} for
|
* Encapsulates the {@link ContextSet contexts} and {@link LookupSetting settings} for
|
||||||
* a permission or meta lookup.
|
* a permission or meta lookup.
|
||||||
@@ -45,7 +41,6 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
*
|
*
|
||||||
* @since 2.11
|
* @since 2.11
|
||||||
*/
|
*/
|
||||||
@Immutable
|
|
||||||
public class Contexts {
|
public class Contexts {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,9 +54,9 @@ public class Contexts {
|
|||||||
public static final String WORLD_KEY = "world";
|
public static final String WORLD_KEY = "world";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default {@link LookupSetting}s.
|
* The default {@link LookupSetting}s as a flag.
|
||||||
*/
|
*/
|
||||||
private static final EnumSet<LookupSetting> DEFAULT_SETTINGS = EnumSet.of(
|
private static final byte DEFAULT_SETTINGS_FLAG = LookupSetting.createFlag(
|
||||||
LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER,
|
LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER,
|
||||||
LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD,
|
LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD,
|
||||||
LookupSetting.RESOLVE_INHERITANCE,
|
LookupSetting.RESOLVE_INHERITANCE,
|
||||||
@@ -75,15 +70,14 @@ public class Contexts {
|
|||||||
* <p>Formed of an empty {@link ContextSet} and all inclusion and
|
* <p>Formed of an empty {@link ContextSet} and all inclusion and
|
||||||
* inheritance {@link LookupSetting}s applied.</p>
|
* inheritance {@link LookupSetting}s applied.</p>
|
||||||
*/
|
*/
|
||||||
private static final Contexts GLOBAL = new Contexts(ImmutableContextSet.empty(), ImmutableSet.copyOf(DEFAULT_SETTINGS));
|
private static final Contexts GLOBAL = new Contexts(ImmutableContextSet.empty(), DEFAULT_SETTINGS_FLAG);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link FullySatisfiedContexts} instance.
|
* Gets the {@link FullySatisfiedContexts} instance.
|
||||||
*
|
*
|
||||||
* @return a context that will satisfy all contextual requirements.
|
* @return a context that will satisfy all contextual requirements.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull Contexts allowAll() {
|
||||||
public static Contexts allowAll() {
|
|
||||||
return FullySatisfiedContexts.getInstance();
|
return FullySatisfiedContexts.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,8 +90,7 @@ public class Contexts {
|
|||||||
* @return the global contexts
|
* @return the global contexts
|
||||||
* @since 3.3
|
* @since 3.3
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull Contexts global() {
|
||||||
public static Contexts global() {
|
|
||||||
return GLOBAL;
|
return GLOBAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,10 +106,9 @@ public class Contexts {
|
|||||||
* @param isOp the value of {@link LookupSetting#IS_OP}
|
* @param isOp the value of {@link LookupSetting#IS_OP}
|
||||||
* @return a new instance
|
* @return a new instance
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull Contexts of(@NonNull ContextSet contextSet, boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) {
|
||||||
public static Contexts of(@Nonnull ContextSet contextSet, boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) {
|
|
||||||
Objects.requireNonNull(contextSet, "contextSet");
|
Objects.requireNonNull(contextSet, "contextSet");
|
||||||
EnumSet<LookupSetting> settings = formSettings(
|
byte settingsFlag = LookupSetting.createFlag(
|
||||||
includeNodesSetWithoutServer,
|
includeNodesSetWithoutServer,
|
||||||
includeNodesSetWithoutWorld,
|
includeNodesSetWithoutWorld,
|
||||||
resolveInheritance,
|
resolveInheritance,
|
||||||
@@ -124,10 +116,10 @@ public class Contexts {
|
|||||||
applyParentsWithoutWorld,
|
applyParentsWithoutWorld,
|
||||||
isOp
|
isOp
|
||||||
);
|
);
|
||||||
if (contextSet.isEmpty() && DEFAULT_SETTINGS.equals(settings)) {
|
if (contextSet.isEmpty() && DEFAULT_SETTINGS_FLAG == settingsFlag) {
|
||||||
return GLOBAL;
|
return GLOBAL;
|
||||||
}
|
}
|
||||||
return new Contexts(contextSet.makeImmutable(), ImmutableSet.copyOf(settings));
|
return new Contexts(contextSet.makeImmutable(), settingsFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,16 +129,16 @@ public class Contexts {
|
|||||||
* @param settings the settings
|
* @param settings the settings
|
||||||
* @return a new instance
|
* @return a new instance
|
||||||
*/
|
*/
|
||||||
public static Contexts of(@Nonnull ContextSet contextSet, @Nonnull Set<LookupSetting> settings) {
|
public static Contexts of(@NonNull ContextSet contextSet, @NonNull Set<LookupSetting> settings) {
|
||||||
Objects.requireNonNull(contextSet, "contextSet");
|
Objects.requireNonNull(contextSet, "contextSet");
|
||||||
Objects.requireNonNull(settings, "settings");
|
Objects.requireNonNull(settings, "settings");
|
||||||
|
|
||||||
EnumSet<LookupSetting> settingsCopy = EnumSet.copyOf(settings);
|
byte settingsFlag = LookupSetting.createFlag(settings);
|
||||||
if (contextSet.isEmpty() && DEFAULT_SETTINGS.equals(settingsCopy)) {
|
if (contextSet.isEmpty() && DEFAULT_SETTINGS_FLAG == settingsFlag) {
|
||||||
return GLOBAL;
|
return GLOBAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Contexts(contextSet.makeImmutable(), ImmutableSet.copyOf(settingsCopy));
|
return new Contexts(contextSet.makeImmutable(), settingsFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -157,7 +149,7 @@ public class Contexts {
|
|||||||
/**
|
/**
|
||||||
* The settings for this lookup
|
* The settings for this lookup
|
||||||
*/
|
*/
|
||||||
private final ImmutableSet<LookupSetting> settings;
|
private final byte settingsFlag;
|
||||||
|
|
||||||
// cache hashcode - this class is immutable, and is used as an index in the permission cache.
|
// cache hashcode - this class is immutable, and is used as an index in the permission cache.
|
||||||
private final int hashCode;
|
private final int hashCode;
|
||||||
@@ -175,45 +167,81 @@ public class Contexts {
|
|||||||
* @deprecated in favour of {@link #of(ContextSet, boolean, boolean, boolean, boolean, boolean, boolean)}
|
* @deprecated in favour of {@link #of(ContextSet, boolean, boolean, boolean, boolean, boolean, boolean)}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Contexts(@Nonnull ContextSet contextSet, boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) {
|
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.contextSet = Objects.requireNonNull(contextSet, "contextSet").makeImmutable();
|
||||||
this.settings = ImmutableSet.copyOf(formSettings(
|
this.settingsFlag = LookupSetting.createFlag(
|
||||||
includeNodesSetWithoutServer,
|
includeNodesSetWithoutServer,
|
||||||
includeNodesSetWithoutWorld,
|
includeNodesSetWithoutWorld,
|
||||||
resolveInheritance,
|
resolveInheritance,
|
||||||
applyParentsWithoutServer,
|
applyParentsWithoutServer,
|
||||||
applyParentsWithoutWorld,
|
applyParentsWithoutWorld,
|
||||||
isOp
|
isOp
|
||||||
));
|
);
|
||||||
this.hashCode = calculateHashCode();
|
this.hashCode = calculateHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Contexts(@Nonnull ImmutableContextSet contextSet, @Nonnull ImmutableSet<LookupSetting> settings) {
|
protected Contexts(@NonNull ImmutableContextSet contextSet, byte settingsFlag) {
|
||||||
this.contextSet = contextSet;
|
this.contextSet = contextSet;
|
||||||
this.settings = settings;
|
this.settingsFlag = settingsFlag;
|
||||||
this.hashCode = calculateHashCode();
|
this.hashCode = calculateHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link ContextSet} which represent these {@link Contexts}.
|
* Gets the {@link ContextSet set of context pairs} for this {@link Contexts} instance.
|
||||||
*
|
*
|
||||||
* @return an immutable context from this instance
|
* @return an immutable context from this instance
|
||||||
* @since 2.13
|
* @since 2.13
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public @NonNull ContextSet getContexts() {
|
||||||
public ContextSet getContexts() {
|
|
||||||
return this.contextSet;
|
return this.contextSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the set of {@link LookupSetting}s which represent these {@link Contexts}.
|
* Gets the set of {@link LookupSetting}s for this {@link Contexts} instance.
|
||||||
*
|
*
|
||||||
* @return the settings
|
* @return the settings
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public @NonNull Set<LookupSetting> getSettings() {
|
||||||
public Set<LookupSetting> getSettings() {
|
return LookupSetting.createSetFromFlag(this.settingsFlag);
|
||||||
return this.settings;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -223,8 +251,8 @@ public class Contexts {
|
|||||||
* @return the value
|
* @return the value
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
public boolean hasSetting(@Nonnull LookupSetting setting) {
|
public boolean hasSetting(@NonNull LookupSetting setting) {
|
||||||
return this.settings.contains(setting);
|
return LookupSetting.isSet(this.settingsFlag, setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -299,10 +327,9 @@ public class Contexts {
|
|||||||
return hasSetting(LookupSetting.APPLY_PARENTS_SET_WITHOUT_WORLD);
|
return hasSetting(LookupSetting.APPLY_PARENTS_SET_WITHOUT_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public @NonNull String toString() {
|
||||||
return "Contexts(contextSet=" + this.contextSet + ", settings=" + this.settings + ")";
|
return "Contexts(contextSet=" + this.contextSet + ", settings=" + LookupSetting.createSetFromFlag(this.settingsFlag) + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -311,14 +338,14 @@ public class Contexts {
|
|||||||
if (o == allowAll()) return false;
|
if (o == allowAll()) return false;
|
||||||
if (!(o instanceof Contexts)) return false;
|
if (!(o instanceof Contexts)) return false;
|
||||||
final Contexts that = (Contexts) o;
|
final Contexts that = (Contexts) o;
|
||||||
return this.contextSet.equals(that.contextSet) && this.settings.equals(that.settings);
|
return this.contextSet.equals(that.contextSet) && this.settingsFlag == that.settingsFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calculateHashCode() {
|
private int calculateHashCode() {
|
||||||
final int PRIME = 59;
|
final int PRIME = 59;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = result * PRIME + this.contextSet.hashCode();
|
result = result * PRIME + this.contextSet.hashCode();
|
||||||
result = result * PRIME + this.settings.hashCode();
|
result = result * PRIME + this.settingsFlag;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,27 +354,4 @@ public class Contexts {
|
|||||||
return this.hashCode;
|
return this.hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static EnumSet<LookupSetting> formSettings(boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) {
|
|
||||||
EnumSet<LookupSetting> settings = EnumSet.noneOf(LookupSetting.class);
|
|
||||||
if (includeNodesSetWithoutServer) {
|
|
||||||
settings.add(LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER);
|
|
||||||
}
|
|
||||||
if (includeNodesSetWithoutWorld) {
|
|
||||||
settings.add(LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD);
|
|
||||||
}
|
|
||||||
if (resolveInheritance) {
|
|
||||||
settings.add(LookupSetting.RESOLVE_INHERITANCE);
|
|
||||||
}
|
|
||||||
if (applyParentsWithoutServer) {
|
|
||||||
settings.add(LookupSetting.APPLY_PARENTS_SET_WITHOUT_SERVER);
|
|
||||||
}
|
|
||||||
if (applyParentsWithoutWorld) {
|
|
||||||
settings.add(LookupSetting.APPLY_PARENTS_SET_WITHOUT_WORLD);
|
|
||||||
}
|
|
||||||
if (isOp) {
|
|
||||||
settings.add(LookupSetting.IS_OP);
|
|
||||||
}
|
|
||||||
return settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import java.util.Optional;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates the result of {@link User}s demotion along a {@link Track}.
|
* Encapsulates the result of {@link User}s demotion along a {@link Track}.
|
||||||
@@ -41,8 +41,7 @@ public interface DemotionResult extends MutateResult {
|
|||||||
*
|
*
|
||||||
* @return the status
|
* @return the status
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Status getStatus();
|
||||||
Status getStatus();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default boolean wasSuccess() {
|
default boolean wasSuccess() {
|
||||||
@@ -60,8 +59,7 @@ public interface DemotionResult extends MutateResult {
|
|||||||
*
|
*
|
||||||
* @return the group the user was demoted from.
|
* @return the group the user was demoted from.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Optional<String> getGroupFrom();
|
||||||
Optional<String> getGroupFrom();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the name of the group the user was demoted from, if applicable.
|
* Gets the name of the group the user was demoted from, if applicable.
|
||||||
@@ -71,8 +69,7 @@ public interface DemotionResult extends MutateResult {
|
|||||||
*
|
*
|
||||||
* @return the group the user was demoted to.
|
* @return the group the user was demoted to.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Optional<String> getGroupTo();
|
||||||
Optional<String> getGroupTo();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The result status
|
* The result status
|
||||||
|
|||||||
@@ -25,10 +25,10 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import java.util.UUID;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.UUID;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an entity on the server.
|
* Represents an entity on the server.
|
||||||
@@ -49,24 +49,21 @@ public interface Entity {
|
|||||||
*
|
*
|
||||||
* @return the uuid of the object, if available
|
* @return the uuid of the object, if available
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable UUID getUniqueId();
|
||||||
UUID getUniqueId();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the name of the object
|
* Gets the name of the object
|
||||||
*
|
*
|
||||||
* @return the object name
|
* @return the object name
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getName();
|
||||||
String getName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the entities type.
|
* Gets the entities type.
|
||||||
*
|
*
|
||||||
* @return the type
|
* @return the type
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Type getType();
|
||||||
Type getType();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The different types of {@link Entity}
|
* The different types of {@link Entity}
|
||||||
|
|||||||
@@ -25,13 +25,11 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.api.caching.CachedData;
|
import me.lucko.luckperms.api.caching.CachedData;
|
||||||
import me.lucko.luckperms.api.caching.MetaContexts;
|
import me.lucko.luckperms.api.caching.MetaContexts;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A special instance of {@link Contexts}, which when passed to:
|
* A special instance of {@link Contexts}, which when passed to:
|
||||||
@@ -54,18 +52,16 @@ public final class FullySatisfiedContexts extends Contexts {
|
|||||||
// singleton
|
// singleton
|
||||||
private static final FullySatisfiedContexts INSTANCE = new FullySatisfiedContexts();
|
private static final FullySatisfiedContexts INSTANCE = new FullySatisfiedContexts();
|
||||||
|
|
||||||
@Nonnull
|
public static @NonNull Contexts getInstance() {
|
||||||
public static Contexts getInstance() {
|
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FullySatisfiedContexts() {
|
private FullySatisfiedContexts() {
|
||||||
super(ImmutableContextSet.empty(), ImmutableSet.copyOf(Contexts.global().getSettings()));
|
super(ImmutableContextSet.empty(), LookupSetting.createFlag(Contexts.global().getSettings()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public @NonNull String toString() {
|
||||||
return "FullySatisfiedContexts()";
|
return "FullySatisfiedContexts()";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,11 +26,13 @@
|
|||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.caching.GroupData;
|
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.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An inheritable holder of permission data.
|
* An inheritable holder of permission data.
|
||||||
*/
|
*/
|
||||||
@@ -41,8 +43,32 @@ public interface Group extends PermissionHolder {
|
|||||||
*
|
*
|
||||||
* @return the name of the group
|
* @return the name of the group
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getName();
|
||||||
String getName();
|
|
||||||
|
/**
|
||||||
|
* Gets the groups "display name", if it has one that differs from it's actual name.
|
||||||
|
*
|
||||||
|
* <p>The lookup is made using the current servers active context.</p>
|
||||||
|
*
|
||||||
|
* <p>Will return <code>null</code> if the groups display name is equal to it's
|
||||||
|
* {@link #getName() actual name}.</p>
|
||||||
|
*
|
||||||
|
* @return the display name
|
||||||
|
* @since 4.3
|
||||||
|
*/
|
||||||
|
@Nullable String getDisplayName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the groups "display name", if it has one that differs from it's actual name.
|
||||||
|
*
|
||||||
|
* <p>Will return <code>null</code> if the groups display name is equal to it's
|
||||||
|
* {@link #getName() actual name}.</p>
|
||||||
|
*
|
||||||
|
* @param contextSet the contexts to lookup in
|
||||||
|
* @return the display name
|
||||||
|
* @since 4.3
|
||||||
|
*/
|
||||||
|
@Nullable String getDisplayName(@NonNull ContextSet contextSet);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the weight of this group, if present.
|
* Gets the weight of this group, if present.
|
||||||
@@ -50,8 +76,7 @@ public interface Group extends PermissionHolder {
|
|||||||
* @return the group weight
|
* @return the group weight
|
||||||
* @since 2.17
|
* @since 2.17
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull OptionalInt getWeight();
|
||||||
OptionalInt getWeight();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the groups's {@link GroupData} cache.
|
* Gets the groups's {@link GroupData} cache.
|
||||||
@@ -59,8 +84,7 @@ public interface Group extends PermissionHolder {
|
|||||||
* @return the groups cached data.
|
* @return the groups cached data.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
GroupData getCachedData();
|
@NonNull GroupData getCachedData();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,19 +27,17 @@ package me.lucko.luckperms.api;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.OptionalLong;
|
import java.util.OptionalLong;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A relationship between a {@link PermissionHolder} and a permission.
|
* A relationship between a {@link PermissionHolder} and a permission.
|
||||||
*
|
*
|
||||||
* @param <T> the identifier type of the holder
|
* @param <T> the identifier type of the holder
|
||||||
* @since 2.17
|
* @since 2.17
|
||||||
*/
|
*/
|
||||||
@Immutable
|
|
||||||
public interface HeldPermission<T> {
|
public interface HeldPermission<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,16 +45,14 @@ public interface HeldPermission<T> {
|
|||||||
*
|
*
|
||||||
* @return the holder
|
* @return the holder
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull T getHolder();
|
||||||
T getHolder();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the permission being held
|
* Gets the permission being held
|
||||||
*
|
*
|
||||||
* @return the permission
|
* @return the permission
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getPermission();
|
||||||
String getPermission();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the permission
|
* Gets the value of the permission
|
||||||
@@ -70,37 +66,34 @@ public interface HeldPermission<T> {
|
|||||||
*
|
*
|
||||||
* @return the server
|
* @return the server
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Optional<String> getServer();
|
||||||
Optional<String> getServer();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the world where the permission is held
|
* Gets the world where the permission is held
|
||||||
*
|
*
|
||||||
* @return the world
|
* @return the world
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Optional<String> getWorld();
|
||||||
Optional<String> getWorld();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the time in unix time when the permission will expire
|
* Gets the time in unix time when the permission will expire
|
||||||
*
|
*
|
||||||
* @return the expiry time
|
* @return the expiry time
|
||||||
*/
|
*/
|
||||||
OptionalLong getExpiry();
|
@NonNull OptionalLong getExpiry();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the extra context for the permission.
|
* Gets the extra context for the permission.
|
||||||
*
|
*
|
||||||
* @return the extra context
|
* @return the extra context
|
||||||
*/
|
*/
|
||||||
ContextSet getContexts();
|
@NonNull ContextSet getContexts();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts this permission into a Node
|
* Converts this permission into a Node
|
||||||
*
|
*
|
||||||
* @return a Node copy of this permission
|
* @return a Node copy of this permission
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Node asNode();
|
||||||
Node asNode();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import java.util.Map;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper around parts of the LuckPerms configuration file
|
* Wrapper around parts of the LuckPerms configuration file
|
||||||
@@ -39,8 +39,7 @@ public interface LPConfiguration {
|
|||||||
*
|
*
|
||||||
* @return the name of this server
|
* @return the name of this server
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getServer();
|
||||||
String getServer();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets 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
|
||||||
@@ -78,8 +77,7 @@ public interface LPConfiguration {
|
|||||||
*
|
*
|
||||||
* @return the storage method string from the configuration
|
* @return the storage method string from the configuration
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getStorageMethod();
|
||||||
String getStorageMethod();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets true if split storage is enabled
|
* Gets true if split storage is enabled
|
||||||
@@ -96,11 +94,9 @@ public interface LPConfiguration {
|
|||||||
* method. For example: key = user, value = json
|
* method. For example: key = user, value = json
|
||||||
* @since 2.7
|
* @since 2.7
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Map<String, String> getSplitStorageOptions();
|
||||||
Map<String, String> getSplitStorageOptions();
|
|
||||||
|
|
||||||
@Nonnull
|
@NonNull Unsafe unsafe();
|
||||||
Unsafe unsafe();
|
|
||||||
|
|
||||||
interface Unsafe {
|
interface Unsafe {
|
||||||
|
|
||||||
@@ -115,8 +111,7 @@ public interface LPConfiguration {
|
|||||||
* @return the corresponding object, if one is present
|
* @return the corresponding object, if one is present
|
||||||
* @throws IllegalArgumentException if the key isn't known
|
* @throws IllegalArgumentException if the key isn't known
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Object getObject(String key);
|
||||||
Object getObject(String key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,32 +25,36 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A node with a traceable origin
|
* An extension of {@link Node}, providing information about
|
||||||
|
* where the node originated from.
|
||||||
*
|
*
|
||||||
* @since 2.11
|
* @since 2.11
|
||||||
*/
|
*/
|
||||||
@Immutable
|
|
||||||
public interface LocalizedNode extends Node {
|
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
|
* @return the node this instance is representing
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Node getNode();
|
||||||
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.
|
* <p>The resultant string is the {@link PermissionHolder#getObjectName() object name} of the
|
||||||
* @see PermissionHolder#getObjectName()
|
* 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.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getLocation();
|
||||||
String getLocation();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,13 +25,11 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import java.util.SortedMap;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the internal LuckPerms log.
|
* Represents the internal LuckPerms log.
|
||||||
*
|
*
|
||||||
@@ -42,73 +40,22 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
*
|
*
|
||||||
* <p>All methods are thread safe, and return immutable and thread safe collections.</p>
|
* <p>All methods are thread safe, and return immutable and thread safe collections.</p>
|
||||||
*/
|
*/
|
||||||
@Immutable
|
|
||||||
public interface Log {
|
public interface Log {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the content of the log
|
* Gets the {@link LogEntry}s that make up this log.
|
||||||
*
|
*
|
||||||
* @return a {@link SortedSet} of all of the {@link LogEntry} objects in this {@link Log}
|
* @return the content
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull SortedSet<LogEntry> getContent();
|
||||||
SortedSet<LogEntry> getContent();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the content of the log
|
* Gets the entries in the log performed by the given actor.
|
||||||
*
|
|
||||||
* @return all content in this log
|
|
||||||
*/
|
|
||||||
@Nonnull
|
|
||||||
SortedSet<LogEntry> getRecent();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the recent content separated by page
|
|
||||||
*
|
|
||||||
* @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()}
|
|
||||||
*/
|
|
||||||
@Nonnull
|
|
||||||
SortedMap<Integer, LogEntry> getRecent(int pageNo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the max page number for the recent pages.
|
|
||||||
*
|
|
||||||
* @return the max page number allowed in the {@link #getRecent(int)} method
|
|
||||||
*/
|
|
||||||
int getRecentMaxPages();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the recent content for a given actor
|
|
||||||
*
|
*
|
||||||
* @param actor the uuid of the actor to filter by
|
* @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
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull SortedSet<LogEntry> getContent(@NonNull UUID actor);
|
||||||
SortedSet<LogEntry> getRecent(@Nonnull UUID actor);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the recent content for a given actor, separated by page
|
|
||||||
*
|
|
||||||
* @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)}
|
|
||||||
*/
|
|
||||||
@Nonnull
|
|
||||||
SortedMap<Integer, LogEntry> getRecent(int pageNo, @Nonnull UUID actor);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the max page number for the recent pages.
|
|
||||||
*
|
|
||||||
* @param actor the actor to filter by
|
|
||||||
* @return the max page number allowed in the {@link #getRecent(int, UUID)} method
|
|
||||||
*/
|
|
||||||
int getRecentMaxPages(@Nonnull UUID actor);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the log content for a given user
|
* Gets the log content for a given user
|
||||||
@@ -116,29 +63,7 @@ public interface Log {
|
|||||||
* @param uuid the uuid to filter by
|
* @param uuid the uuid to filter by
|
||||||
* @return all content in this log where the user = uuid
|
* @return all content in this log where the user = uuid
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull SortedSet<LogEntry> getUserHistory(@NonNull UUID uuid);
|
||||||
SortedSet<LogEntry> getUserHistory(@Nonnull UUID uuid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the log content for a given user, separated by page
|
|
||||||
*
|
|
||||||
* @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)}
|
|
||||||
*/
|
|
||||||
@Nonnull
|
|
||||||
SortedMap<Integer, LogEntry> getUserHistory(int pageNo, @Nonnull UUID uuid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the max page number for the user history pages.
|
|
||||||
*
|
|
||||||
* @param uuid the uuid to filter by
|
|
||||||
* @return the max page number allowed in the {@link #getUserHistory(int, UUID)} method
|
|
||||||
*/
|
|
||||||
int getUserHistoryMaxPages(@Nonnull UUID uuid);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the log content for a given group
|
* Gets the log content for a given group
|
||||||
@@ -146,29 +71,7 @@ public interface Log {
|
|||||||
* @param name the name to filter by
|
* @param name the name to filter by
|
||||||
* @return all content in this log where the group = name
|
* @return all content in this log where the group = name
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull SortedSet<LogEntry> getGroupHistory(@NonNull String name);
|
||||||
SortedSet<LogEntry> getGroupHistory(@Nonnull String name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the log content for a given group, separated by page
|
|
||||||
*
|
|
||||||
* @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)}
|
|
||||||
*/
|
|
||||||
@Nonnull
|
|
||||||
SortedMap<Integer, LogEntry> getGroupHistory(int pageNo, @Nonnull String name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the max page number for the group history pages.
|
|
||||||
*
|
|
||||||
* @param name the name to filter by
|
|
||||||
* @return the max page number allowed in the {@link #getGroupHistory(int, String)} method
|
|
||||||
*/
|
|
||||||
int getGroupHistoryMaxPages(@Nonnull String name);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the log content for a given track
|
* Gets the log content for a given track
|
||||||
@@ -176,57 +79,6 @@ public interface Log {
|
|||||||
* @param name the name to filter by
|
* @param name the name to filter by
|
||||||
* @return all content in this log where the track = name
|
* @return all content in this log where the track = name
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull SortedSet<LogEntry> getTrackHistory(@NonNull String name);
|
||||||
SortedSet<LogEntry> getTrackHistory(@Nonnull String name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the log content for a given track, separated by page
|
|
||||||
*
|
|
||||||
* @param pageNo the page number
|
|
||||||
* @param name the name of the acted track 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 #getTrackHistoryMaxPages(String)}
|
|
||||||
*/
|
|
||||||
@Nonnull
|
|
||||||
SortedMap<Integer, LogEntry> getTrackHistory(int pageNo, @Nonnull String name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the max page number for the track history pages.
|
|
||||||
*
|
|
||||||
* @param name the name to filter by
|
|
||||||
* @return the max page number allowed in the {@link #getTrackHistory(int, String)} method
|
|
||||||
*/
|
|
||||||
int getTrackHistoryMaxPages(@Nonnull String name);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the log content for a given search query
|
|
||||||
*
|
|
||||||
* @param query the query to filter by
|
|
||||||
* @return all content in this log where the content matches query
|
|
||||||
*/
|
|
||||||
@Nonnull
|
|
||||||
SortedSet<LogEntry> getSearch(@Nonnull String query);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the log content for a given search query, separated by page
|
|
||||||
*
|
|
||||||
* @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)}}
|
|
||||||
*/
|
|
||||||
@Nonnull
|
|
||||||
SortedMap<Integer, LogEntry> getSearch(int pageNo, @Nonnull String query);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the max page number for the search query pages.
|
|
||||||
*
|
|
||||||
* @param query the query to filter by
|
|
||||||
* @return the max page number allowed in the {@link #getSearch(int, String)} method
|
|
||||||
*/
|
|
||||||
int getSearchMaxPages(@Nonnull String query);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,19 +25,17 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
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.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a logged action.
|
* Represents a logged action.
|
||||||
*
|
*
|
||||||
* @see ActionLogger#newEntryBuilder() for creating an instance
|
* @see ActionLogger#newEntryBuilder() for creating an instance
|
||||||
*/
|
*/
|
||||||
@Immutable
|
|
||||||
public interface LogEntry extends Comparable<LogEntry> {
|
public interface LogEntry extends Comparable<LogEntry> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,24 +52,21 @@ public interface LogEntry extends Comparable<LogEntry> {
|
|||||||
*
|
*
|
||||||
* @return the actor id
|
* @return the actor id
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull UUID getActor();
|
||||||
UUID getActor();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the name describing the actor.
|
* Gets the name describing the actor.
|
||||||
*
|
*
|
||||||
* @return the name of the actor
|
* @return the name of the actor
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getActorName();
|
||||||
String getActorName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the type of action.
|
* Gets the type of action.
|
||||||
*
|
*
|
||||||
* @return the action type
|
* @return the action type
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Type getType();
|
||||||
Type getType();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the uuid of the object which was acted upon.
|
* Gets the uuid of the object which was acted upon.
|
||||||
@@ -80,16 +75,14 @@ public interface LogEntry extends Comparable<LogEntry> {
|
|||||||
*
|
*
|
||||||
* @return the uuid of acted object
|
* @return the uuid of acted object
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Optional<UUID> getActed();
|
||||||
Optional<UUID> getActed();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the name describing the object which was acted upon
|
* Gets the name describing the object which was acted upon
|
||||||
*
|
*
|
||||||
* @return the name of the acted object
|
* @return the name of the acted object
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getActedName();
|
||||||
String getActedName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string describing the action which took place.
|
* Returns a string describing the action which took place.
|
||||||
@@ -99,8 +92,7 @@ public interface LogEntry extends Comparable<LogEntry> {
|
|||||||
*
|
*
|
||||||
* @return the action
|
* @return the action
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getAction();
|
||||||
String getAction();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the type of a {@link LogEntry}.
|
* Represents the type of a {@link LogEntry}.
|
||||||
@@ -108,22 +100,38 @@ public interface LogEntry extends Comparable<LogEntry> {
|
|||||||
* @since 3.3
|
* @since 3.3
|
||||||
*/
|
*/
|
||||||
enum Type {
|
enum Type {
|
||||||
USER('U'),
|
USER('U'), GROUP('G'), TRACK('T');
|
||||||
GROUP('G'),
|
|
||||||
TRACK('T');
|
|
||||||
|
|
||||||
private final char code;
|
/**
|
||||||
|
* Parses a {@link Type} from a string.
|
||||||
Type(char code) {
|
*
|
||||||
this.code = code;
|
* @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
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return valueOf(type.charAt(0));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Unknown type: " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public char getCode() {
|
/**
|
||||||
return this.code;
|
* Returns a {@link Type} by its code.
|
||||||
}
|
*
|
||||||
|
* @param code the code - see {@link Type#getCode()}.
|
||||||
@Nonnull
|
* @return a type
|
||||||
public static Type valueOf(char code) {
|
* @throws IllegalArgumentException if a type could not be resolved
|
||||||
|
*/
|
||||||
|
public static @NonNull Type valueOf(char code) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 'U':
|
case 'U':
|
||||||
case 'u':
|
case 'u':
|
||||||
@@ -138,6 +146,16 @@ public interface LogEntry extends Comparable<LogEntry> {
|
|||||||
throw new IllegalArgumentException("Unknown code: " + code);
|
throw new IllegalArgumentException("Unknown code: " + code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final char code;
|
||||||
|
|
||||||
|
Type(char code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getCode() {
|
||||||
|
return this.code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,8 +170,7 @@ public interface LogEntry extends Comparable<LogEntry> {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
* @see LogEntry#getTimestamp()
|
* @see LogEntry#getTimestamp()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder setTimestamp(long timestamp);
|
||||||
Builder setTimestamp(long timestamp);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the actor of the entry.
|
* Sets the actor of the entry.
|
||||||
@@ -162,8 +179,7 @@ public interface LogEntry extends Comparable<LogEntry> {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
* @see LogEntry#getActor()
|
* @see LogEntry#getActor()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder setActor(@NonNull UUID actor);
|
||||||
Builder setActor(@Nonnull UUID actor);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the actor name of the entry.
|
* Sets the actor name of the entry.
|
||||||
@@ -172,8 +188,7 @@ public interface LogEntry extends Comparable<LogEntry> {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
* @see LogEntry#getActorName()
|
* @see LogEntry#getActorName()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder setActorName(@NonNull String actorName);
|
||||||
Builder setActorName(@Nonnull String actorName);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the type of the entry.
|
* Sets the type of the entry.
|
||||||
@@ -182,8 +197,7 @@ public interface LogEntry extends Comparable<LogEntry> {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
* @see LogEntry#getType()
|
* @see LogEntry#getType()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder setType(@NonNull Type type);
|
||||||
Builder setType(@Nonnull Type type);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the acted object for the entry.
|
* Sets the acted object for the entry.
|
||||||
@@ -192,8 +206,7 @@ public interface LogEntry extends Comparable<LogEntry> {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
* @see LogEntry#getActed()
|
* @see LogEntry#getActed()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder setActed(@Nullable UUID acted);
|
||||||
Builder setActed(@Nullable UUID acted);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the acted name for the entry.
|
* Sets the acted name for the entry.
|
||||||
@@ -202,8 +215,7 @@ public interface LogEntry extends Comparable<LogEntry> {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
* @see LogEntry#getActedName()
|
* @see LogEntry#getActedName()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder setActedName(@NonNull String actedName);
|
||||||
Builder setActedName(@Nonnull String actedName);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the action of the entry.
|
* Sets the action of the entry.
|
||||||
@@ -212,16 +224,14 @@ public interface LogEntry extends Comparable<LogEntry> {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
* @see LogEntry#getAction()
|
* @see LogEntry#getAction()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder setAction(@NonNull String action);
|
||||||
Builder setAction(@Nonnull String action);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link LogEntry} instance from the builder.
|
* Creates a {@link LogEntry} instance from the builder.
|
||||||
*
|
*
|
||||||
* @return a new log entry instance
|
* @return a new log entry instance
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull LogEntry build();
|
||||||
LogEntry build();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The various lookup setting flags for {@link Contexts}.
|
* The various lookup setting flags for {@link Contexts}.
|
||||||
*
|
*
|
||||||
@@ -60,5 +63,62 @@ public enum LookupSetting {
|
|||||||
/**
|
/**
|
||||||
* If global or non-world-specific group memberships should be applied
|
* If global or non-world-specific group memberships should be applied
|
||||||
*/
|
*/
|
||||||
APPLY_PARENTS_SET_WITHOUT_WORLD
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -26,10 +26,12 @@
|
|||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import me.lucko.luckperms.LuckPerms;
|
import me.lucko.luckperms.LuckPerms;
|
||||||
|
import me.lucko.luckperms.api.caching.CachedData;
|
||||||
import me.lucko.luckperms.api.context.ContextCalculator;
|
import me.lucko.luckperms.api.context.ContextCalculator;
|
||||||
import me.lucko.luckperms.api.context.ContextManager;
|
import me.lucko.luckperms.api.context.ContextManager;
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.api.event.EventBus;
|
import me.lucko.luckperms.api.event.EventBus;
|
||||||
|
import me.lucko.luckperms.api.manager.CachedDataManager;
|
||||||
import me.lucko.luckperms.api.manager.GroupManager;
|
import me.lucko.luckperms.api.manager.GroupManager;
|
||||||
import me.lucko.luckperms.api.manager.TrackManager;
|
import me.lucko.luckperms.api.manager.TrackManager;
|
||||||
import me.lucko.luckperms.api.manager.UserManager;
|
import me.lucko.luckperms.api.manager.UserManager;
|
||||||
@@ -37,14 +39,15 @@ import me.lucko.luckperms.api.messenger.MessengerProvider;
|
|||||||
import me.lucko.luckperms.api.metastacking.MetaStackFactory;
|
import me.lucko.luckperms.api.metastacking.MetaStackFactory;
|
||||||
import me.lucko.luckperms.api.platform.PlatformInfo;
|
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.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The LuckPerms API.
|
* The LuckPerms API.
|
||||||
*
|
*
|
||||||
@@ -62,8 +65,7 @@ public interface LuckPermsApi {
|
|||||||
* @return the platform info
|
* @return the platform info
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull PlatformInfo getPlatformInfo();
|
||||||
PlatformInfo getPlatformInfo();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link UserManager}, responsible for managing
|
* Gets the {@link UserManager}, responsible for managing
|
||||||
@@ -78,8 +80,7 @@ public interface LuckPermsApi {
|
|||||||
* @return the user manager
|
* @return the user manager
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull UserManager getUserManager();
|
||||||
UserManager getUserManager();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link GroupManager}, responsible for managing
|
* Gets the {@link GroupManager}, responsible for managing
|
||||||
@@ -94,8 +95,7 @@ public interface LuckPermsApi {
|
|||||||
* @return the group manager
|
* @return the group manager
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull GroupManager getGroupManager();
|
||||||
GroupManager getGroupManager();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link TrackManager}, responsible for managing
|
* Gets the {@link TrackManager}, responsible for managing
|
||||||
@@ -110,8 +110,16 @@ public interface LuckPermsApi {
|
|||||||
* @return the track manager
|
* @return the track manager
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull TrackManager getTrackManager();
|
||||||
TrackManager getTrackManager();
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link CachedDataManager}, responsible for managing
|
||||||
|
* {@link CachedData} instances.
|
||||||
|
*
|
||||||
|
* @return the cached data manager
|
||||||
|
* @since 4.5
|
||||||
|
*/
|
||||||
|
@NonNull CachedDataManager getCachedDataManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedules the execution of an update task, and returns an encapsulation
|
* Schedules the execution of an update task, and returns an encapsulation
|
||||||
@@ -125,8 +133,7 @@ public interface LuckPermsApi {
|
|||||||
* @return a future
|
* @return a future
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Void> runUpdateTask();
|
||||||
CompletableFuture<Void> runUpdateTask();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link EventBus}, used for subscribing to internal LuckPerms
|
* Gets the {@link EventBus}, used for subscribing to internal LuckPerms
|
||||||
@@ -135,16 +142,14 @@ public interface LuckPermsApi {
|
|||||||
* @return the event bus
|
* @return the event bus
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull EventBus getEventBus();
|
||||||
EventBus getEventBus();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a representation of the plugins configuration
|
* Gets a representation of the plugins configuration
|
||||||
*
|
*
|
||||||
* @return the configuration
|
* @return the configuration
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull LPConfiguration getConfiguration();
|
||||||
LPConfiguration getConfiguration();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an object representing the plugins primary {@link Storage} backend.
|
* Gets an object representing the plugins primary {@link Storage} backend.
|
||||||
@@ -155,8 +160,7 @@ public interface LuckPermsApi {
|
|||||||
* @return a storage instance
|
* @return a storage instance
|
||||||
* @since 2.14
|
* @since 2.14
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Storage getStorage();
|
||||||
Storage getStorage();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link MessagingService}, if present.
|
* Gets the {@link MessagingService}, if present.
|
||||||
@@ -170,8 +174,7 @@ public interface LuckPermsApi {
|
|||||||
*
|
*
|
||||||
* @return the messaging service instance, if present.
|
* @return the messaging service instance, if present.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Optional<MessagingService> getMessagingService();
|
||||||
Optional<MessagingService> getMessagingService();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a {@link MessengerProvider} for use by the platform.
|
* Registers a {@link MessengerProvider} for use by the platform.
|
||||||
@@ -182,7 +185,7 @@ public interface LuckPermsApi {
|
|||||||
* @param messengerProvider the messenger provider.
|
* @param messengerProvider the messenger provider.
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
void registerMessengerProvider(@Nonnull MessengerProvider messengerProvider);
|
void registerMessengerProvider(@NonNull MessengerProvider messengerProvider);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link ActionLogger}.
|
* Gets the {@link ActionLogger}.
|
||||||
@@ -193,7 +196,7 @@ public interface LuckPermsApi {
|
|||||||
* @return the action logger
|
* @return the action logger
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
ActionLogger getActionLogger();
|
@NonNull ActionLogger getActionLogger();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a {@link UuidCache}.
|
* Gets a {@link UuidCache}.
|
||||||
@@ -203,11 +206,10 @@ public interface LuckPermsApi {
|
|||||||
*
|
*
|
||||||
* @return the uuid cache
|
* @return the uuid cache
|
||||||
* @deprecated this feature is now handled internally - and the API returns a
|
* @deprecated this feature is now handled internally - and the API returns a
|
||||||
* No-op implementation of this class.
|
* No-op implementation of this class.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
UuidCache getUuidCache();
|
@NonNull UuidCache getUuidCache();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link ContextManager}.
|
* Gets the {@link ContextManager}.
|
||||||
@@ -218,7 +220,15 @@ public interface LuckPermsApi {
|
|||||||
* @return the context manager
|
* @return the context manager
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
ContextManager getContextManager();
|
@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}.
|
* Gets the {@link NodeFactory}.
|
||||||
@@ -227,8 +237,7 @@ public interface LuckPermsApi {
|
|||||||
*
|
*
|
||||||
* @return the node factory
|
* @return the node factory
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull NodeFactory getNodeFactory();
|
||||||
NodeFactory getNodeFactory();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link MetaStackFactory}.
|
* Gets the {@link MetaStackFactory}.
|
||||||
@@ -240,8 +249,7 @@ public interface LuckPermsApi {
|
|||||||
* @return the meta stack factory
|
* @return the meta stack factory
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull MetaStackFactory getMetaStackFactory();
|
||||||
MetaStackFactory getMetaStackFactory();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -263,8 +271,7 @@ public interface LuckPermsApi {
|
|||||||
* @return a {@link User} object, if one matching the uuid is loaded, or null if not
|
* @return a {@link User} object, if one matching the uuid is loaded, or null if not
|
||||||
* @throws NullPointerException if the uuid is null
|
* @throws NullPointerException if the uuid is null
|
||||||
*/
|
*/
|
||||||
@Nullable
|
default @Nullable User getUser(@NonNull UUID uuid) {
|
||||||
default User getUser(@Nonnull UUID uuid) {
|
|
||||||
return getUserManager().getUser(uuid);
|
return getUserManager().getUser(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,8 +282,7 @@ public interface LuckPermsApi {
|
|||||||
* @return an optional {@link User} object
|
* @return an optional {@link User} object
|
||||||
* @throws NullPointerException if the uuid is null
|
* @throws NullPointerException if the uuid is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull Optional<User> getUserSafe(@NonNull UUID uuid) {
|
||||||
default Optional<User> getUserSafe(@Nonnull UUID uuid) {
|
|
||||||
return getUserManager().getUserOpt(uuid);
|
return getUserManager().getUserOpt(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,8 +293,7 @@ public interface LuckPermsApi {
|
|||||||
* @return a {@link User} object, if one matching the uuid is loaded, or null if not
|
* @return a {@link User} object, if one matching the uuid is loaded, or null if not
|
||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
*/
|
*/
|
||||||
@Nullable
|
default @Nullable User getUser(@NonNull String name) {
|
||||||
default User getUser(@Nonnull String name) {
|
|
||||||
return getUserManager().getUser(name);
|
return getUserManager().getUser(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,8 +304,7 @@ public interface LuckPermsApi {
|
|||||||
* @return an optional {@link User} object
|
* @return an optional {@link User} object
|
||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull Optional<User> getUserSafe(@NonNull String name) {
|
||||||
default Optional<User> getUserSafe(@Nonnull String name) {
|
|
||||||
return getUserManager().getUserOpt(name);
|
return getUserManager().getUserOpt(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,8 +313,7 @@ public interface LuckPermsApi {
|
|||||||
*
|
*
|
||||||
* @return a {@link Set} of {@link User} objects
|
* @return a {@link Set} of {@link User} objects
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull Set<User> getUsers() {
|
||||||
default Set<User> getUsers() {
|
|
||||||
return getUserManager().getLoadedUsers();
|
return getUserManager().getLoadedUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,7 +324,7 @@ public interface LuckPermsApi {
|
|||||||
* @return true if the user is loaded
|
* @return true if the user is loaded
|
||||||
* @throws NullPointerException if the uuid is null
|
* @throws NullPointerException if the uuid is null
|
||||||
*/
|
*/
|
||||||
default boolean isUserLoaded(@Nonnull UUID uuid) {
|
default boolean isUserLoaded(@NonNull UUID uuid) {
|
||||||
return getUserManager().isLoaded(uuid);
|
return getUserManager().isLoaded(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,7 +334,7 @@ public interface LuckPermsApi {
|
|||||||
* @param user the user to unload
|
* @param user the user to unload
|
||||||
* @throws NullPointerException if the user is null
|
* @throws NullPointerException if the user is null
|
||||||
*/
|
*/
|
||||||
default void cleanupUser(@Nonnull User user) {
|
default void cleanupUser(@NonNull User user) {
|
||||||
getUserManager().cleanupUser(user);
|
getUserManager().cleanupUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,8 +345,7 @@ public interface LuckPermsApi {
|
|||||||
* @return a {@link Group} object, if one matching the name exists, or null if not
|
* @return a {@link Group} object, if one matching the name exists, or null if not
|
||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
*/
|
*/
|
||||||
@Nullable
|
default @Nullable Group getGroup(@NonNull String name) {
|
||||||
default Group getGroup(@Nonnull String name) {
|
|
||||||
return getGroupManager().getGroup(name);
|
return getGroupManager().getGroup(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,8 +358,7 @@ public interface LuckPermsApi {
|
|||||||
* @return an optional {@link Group} object
|
* @return an optional {@link Group} object
|
||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull Optional<Group> getGroupSafe(@NonNull String name) {
|
||||||
default Optional<Group> getGroupSafe(@Nonnull String name) {
|
|
||||||
return getGroupManager().getGroupOpt(name);
|
return getGroupManager().getGroupOpt(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,8 +367,7 @@ public interface LuckPermsApi {
|
|||||||
*
|
*
|
||||||
* @return a {@link Set} of {@link Group} objects
|
* @return a {@link Set} of {@link Group} objects
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull Set<Group> getGroups() {
|
||||||
default Set<Group> getGroups() {
|
|
||||||
return getGroupManager().getLoadedGroups();
|
return getGroupManager().getLoadedGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,7 +378,7 @@ public interface LuckPermsApi {
|
|||||||
* @return true if the group is loaded
|
* @return true if the group is loaded
|
||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
*/
|
*/
|
||||||
default boolean isGroupLoaded(@Nonnull String name) {
|
default boolean isGroupLoaded(@NonNull String name) {
|
||||||
return getGroupManager().isLoaded(name);
|
return getGroupManager().isLoaded(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,8 +390,7 @@ public interface LuckPermsApi {
|
|||||||
* if not
|
* if not
|
||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
*/
|
*/
|
||||||
@Nullable
|
default @Nullable Track getTrack(@NonNull String name) {
|
||||||
default Track getTrack(@Nonnull String name) {
|
|
||||||
return getTrackManager().getTrack(name);
|
return getTrackManager().getTrack(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,8 +403,7 @@ public interface LuckPermsApi {
|
|||||||
* @return an optional {@link Track} object
|
* @return an optional {@link Track} object
|
||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull Optional<Track> getTrackSafe(@NonNull String name) {
|
||||||
default Optional<Track> getTrackSafe(@Nonnull String name) {
|
|
||||||
return getTrackManager().getTrackOpt(name);
|
return getTrackManager().getTrackOpt(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,8 +412,7 @@ public interface LuckPermsApi {
|
|||||||
*
|
*
|
||||||
* @return a {@link Set} of {@link Track} objects
|
* @return a {@link Set} of {@link Track} objects
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull Set<Track> getTracks() {
|
||||||
default Set<Track> getTracks() {
|
|
||||||
return getTrackManager().getLoadedTracks();
|
return getTrackManager().getLoadedTracks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,7 +423,7 @@ public interface LuckPermsApi {
|
|||||||
* @return true if the track is loaded
|
* @return true if the track is loaded
|
||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
*/
|
*/
|
||||||
default boolean isTrackLoaded(@Nonnull String name) {
|
default boolean isTrackLoaded(@NonNull String name) {
|
||||||
return getTrackManager().isLoaded(name);
|
return getTrackManager().isLoaded(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,8 +433,7 @@ public interface LuckPermsApi {
|
|||||||
* @return a new builder
|
* @return a new builder
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default LogEntry.@NonNull Builder newLogEntryBuilder() {
|
||||||
default LogEntry.Builder newLogEntryBuilder() {
|
|
||||||
return getActionLogger().newEntryBuilder();
|
return getActionLogger().newEntryBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -450,8 +446,7 @@ public interface LuckPermsApi {
|
|||||||
* @throws NullPointerException if the permission is null
|
* @throws NullPointerException if the permission is null
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default Node.@NonNull Builder buildNode(@NonNull String permission) throws IllegalArgumentException {
|
||||||
default Node.Builder buildNode(@Nonnull String permission) throws IllegalArgumentException {
|
|
||||||
return getNodeFactory().newBuilder(permission);
|
return getNodeFactory().newBuilder(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,7 +456,7 @@ public interface LuckPermsApi {
|
|||||||
* @param calculator 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.
|
* @throws ClassCastException if the type is not the player class of the platform.
|
||||||
*/
|
*/
|
||||||
default void registerContextCalculator(@Nonnull ContextCalculator<?> calculator) {
|
default void registerContextCalculator(@NonNull ContextCalculator<?> calculator) {
|
||||||
getContextManager().registerCalculator(calculator);
|
getContextManager().registerCalculator(calculator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,8 +468,7 @@ public interface LuckPermsApi {
|
|||||||
* @param user the user to get contexts for
|
* @param user the user to get contexts for
|
||||||
* @return an optional containing contexts. Will return empty if the user is not online.
|
* @return an optional containing contexts. Will return empty if the user is not online.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull Optional<Contexts> getContextForUser(@NonNull User user) {
|
||||||
default Optional<Contexts> getContextForUser(@Nonnull User user) {
|
|
||||||
return getContextManager().lookupApplicableContexts(user);
|
return getContextManager().lookupApplicableContexts(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,8 +479,7 @@ public interface LuckPermsApi {
|
|||||||
* @return a set of contexts.
|
* @return a set of contexts.
|
||||||
* @since 2.17
|
* @since 2.17
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull ContextSet getContextForPlayer(@NonNull Object player) {
|
||||||
default ContextSet getContextForPlayer(@Nonnull Object player) {
|
|
||||||
return getContextManager().getApplicableContext(player);
|
return getContextManager().getApplicableContext(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,8 +490,7 @@ public interface LuckPermsApi {
|
|||||||
* @return a set of contexts.
|
* @return a set of contexts.
|
||||||
* @since 3.3
|
* @since 3.3
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull Contexts getContextsForPlayer(@NonNull Object player) {
|
||||||
default Contexts getContextsForPlayer(@Nonnull Object player) {
|
|
||||||
return getContextManager().getApplicableContexts(player);
|
return getContextManager().getApplicableContexts(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A means to push changes to other servers using the platforms networking
|
* A means to push changes to other servers using the platforms networking
|
||||||
@@ -71,6 +71,6 @@ public interface MessagingService {
|
|||||||
* @param user the user to push the update for
|
* @param user the user to push the update for
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
void pushUserUpdate(@Nonnull User user);
|
void pushUserUpdate(@NonNull User user);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -37,6 +37,9 @@ import me.lucko.luckperms.api.nodetype.types.PrefixType;
|
|||||||
import me.lucko.luckperms.api.nodetype.types.SuffixType;
|
import me.lucko.luckperms.api.nodetype.types.SuffixType;
|
||||||
import me.lucko.luckperms.api.nodetype.types.WeightType;
|
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.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -46,10 +49,6 @@ import java.util.Set;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a LuckPerms "node".
|
* Represents a LuckPerms "node".
|
||||||
*
|
*
|
||||||
@@ -71,13 +70,13 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
* <p>Nodes have the following attributes:</p>
|
* <p>Nodes have the following attributes:</p>
|
||||||
* <p></p>
|
* <p></p>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@link #getPermission() permission} - the actual permission string</li>
|
* <li>{@link #getPermission() permission} - the actual permission string</li>
|
||||||
* <li>{@link #getValue() value} - the value of the node (false for negated)</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 #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 #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 #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 #getContexts() context} - the additional contexts required for this node to apply </li>
|
||||||
* <li>{@link #getExpiry() expiry} - the time when this node should expire</li>
|
* <li>{@link #getExpiry() expiry} - the time when this node should expire</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* <p>The 'permission' property of a {@link Node} is also used in some cases to represent state
|
* <p>The 'permission' property of a {@link Node} is also used in some cases to represent state
|
||||||
@@ -90,13 +89,13 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
* <p>The current types are:</p>
|
* <p>The current types are:</p>
|
||||||
* <p></p>
|
* <p></p>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>normal - just a regular permission</li>
|
* <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 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 PrefixType} - represents an assigned prefix</li>
|
||||||
* <li>{@link SuffixType} - represents an assigned suffix</li>
|
* <li>{@link SuffixType} - represents an assigned suffix</li>
|
||||||
* <li>{@link MetaType} - represents an assigned meta option</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 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>
|
* <li>{@link DisplayNameType} - marks the display name of the object holding this node</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* <p>The core node state must be immutable in all implementations.</p>
|
* <p>The core node state must be immutable in all implementations.</p>
|
||||||
@@ -104,7 +103,6 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
* @see NodeFactory for obtaining and constructing instances.
|
* @see NodeFactory for obtaining and constructing instances.
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
@Immutable
|
|
||||||
public interface Node {
|
public interface Node {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,8 +113,7 @@ public interface Node {
|
|||||||
*
|
*
|
||||||
* @return the actual permission node
|
* @return the actual permission node
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getPermission();
|
||||||
String getPermission();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the node.
|
* Gets the value of the node.
|
||||||
@@ -132,8 +129,7 @@ public interface Node {
|
|||||||
*
|
*
|
||||||
* @return the value of this node as a Tristate
|
* @return the value of this node as a Tristate
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull Tristate getTristate() {
|
||||||
default Tristate getTristate() {
|
|
||||||
return Tristate.fromBoolean(getValue());
|
return Tristate.fromBoolean(getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,16 +159,14 @@ public interface Node {
|
|||||||
*
|
*
|
||||||
* @return an {@link Optional} containing the server, if one is defined
|
* @return an {@link Optional} containing the server, if one is defined
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Optional<String> getServer();
|
||||||
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
|
* @return an {@link Optional} containing the world, if one is defined
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Optional<String> getWorld();
|
||||||
Optional<String> getWorld();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if this node is server specific.
|
* Gets if this node is server specific.
|
||||||
@@ -211,7 +205,7 @@ public interface Node {
|
|||||||
* @return true if the node should apply
|
* @return true if the node should apply
|
||||||
* @since 2.13
|
* @since 2.13
|
||||||
*/
|
*/
|
||||||
boolean shouldApplyWithContext(@Nonnull ContextSet contextSet);
|
boolean shouldApplyWithContext(@NonNull ContextSet contextSet);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves any shorthand parts of this node and returns the full list of
|
* Resolves any shorthand parts of this node and returns the full list of
|
||||||
@@ -221,8 +215,7 @@ public interface Node {
|
|||||||
*
|
*
|
||||||
* @return a list of full nodes
|
* @return a list of full nodes
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull List<String> resolveShorthand();
|
||||||
List<String> resolveShorthand();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if this node is assigned temporarily.
|
* Gets if this node is assigned temporarily.
|
||||||
@@ -254,8 +247,7 @@ public interface Node {
|
|||||||
* @return the {@link Date} when this node will expire
|
* @return the {@link Date} when this node will expire
|
||||||
* @throws IllegalStateException if the node is not temporary
|
* @throws IllegalStateException if the node is not temporary
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Date getExpiry() throws IllegalStateException;
|
||||||
Date getExpiry() throws IllegalStateException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of seconds until this permission will expire.
|
* Gets the number of seconds until this permission will expire.
|
||||||
@@ -282,20 +274,18 @@ public interface Node {
|
|||||||
* @return the extra contexts required for this node to apply
|
* @return the extra contexts required for this node to apply
|
||||||
* @since 2.13
|
* @since 2.13
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull ContextSet getContexts();
|
||||||
ContextSet getContexts();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The same as {@link #getContexts()}, but also includes context pairs for
|
* The same as {@link #getContexts()}, but also includes context pairs for
|
||||||
* "server" and "world" keys if present.
|
* "server" and "world" keys if present.
|
||||||
*
|
*
|
||||||
* @return the full contexts required for this node to apply
|
* @return the full contexts required for this node to apply
|
||||||
* @since 3.1
|
|
||||||
* @see Contexts#SERVER_KEY
|
* @see Contexts#SERVER_KEY
|
||||||
* @see Contexts#WORLD_KEY
|
* @see Contexts#WORLD_KEY
|
||||||
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull ContextSet getFullContexts();
|
||||||
ContextSet getFullContexts();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if this node is a wildcard permission.
|
* Gets if this node is a wildcard permission.
|
||||||
@@ -347,10 +337,7 @@ public interface Node {
|
|||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
default <T extends NodeType> T typeData(NodeTypeKey<T> key) throws IllegalStateException {
|
default <T extends NodeType> T typeData(NodeTypeKey<T> key) throws IllegalStateException {
|
||||||
return getTypeData(key)
|
return getTypeData(key).orElseThrow(() -> new IllegalStateException("Node '" + getPermission() + "' does not have the '" + key.getTypeName() + "' type."));
|
||||||
.orElseThrow(() ->
|
|
||||||
new IllegalStateException("Node '" + getPermission() + "' does not have the '" + key.getTypeName() + "' type.")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -369,8 +356,7 @@ public interface Node {
|
|||||||
* @return the name of the group
|
* @return the name of the group
|
||||||
* @throws IllegalStateException if this node doesn't have {@link InheritanceType} data
|
* @throws IllegalStateException if this node doesn't have {@link InheritanceType} data
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull String getGroupName() throws IllegalStateException {
|
||||||
default String getGroupName() throws IllegalStateException {
|
|
||||||
return typeData(InheritanceType.KEY).getGroupName();
|
return typeData(InheritanceType.KEY).getGroupName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,8 +376,7 @@ public interface Node {
|
|||||||
* @return the meta entry
|
* @return the meta entry
|
||||||
* @throws IllegalStateException if this node doesn't have {@link MetaType} data
|
* @throws IllegalStateException if this node doesn't have {@link MetaType} data
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default Map.@NonNull Entry<String, String> getMeta() throws IllegalStateException {
|
||||||
default Map.Entry<String, String> getMeta() throws IllegalStateException {
|
|
||||||
return typeData(MetaType.KEY);
|
return typeData(MetaType.KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,8 +396,7 @@ public interface Node {
|
|||||||
* @return the meta entry
|
* @return the meta entry
|
||||||
* @throws IllegalStateException if this node doesn't have {@link PrefixType} data
|
* @throws IllegalStateException if this node doesn't have {@link PrefixType} data
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default Map.@NonNull Entry<Integer, String> getPrefix() throws IllegalStateException {
|
||||||
default Map.Entry<Integer, String> getPrefix() throws IllegalStateException {
|
|
||||||
return typeData(PrefixType.KEY).getAsEntry();
|
return typeData(PrefixType.KEY).getAsEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,8 +416,7 @@ public interface Node {
|
|||||||
* @return the meta entry
|
* @return the meta entry
|
||||||
* @throws IllegalStateException if this node doesn't have {@link SuffixType} data
|
* @throws IllegalStateException if this node doesn't have {@link SuffixType} data
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default Map.@NonNull Entry<Integer, String> getSuffix() throws IllegalStateException {
|
||||||
default Map.Entry<Integer, String> getSuffix() throws IllegalStateException {
|
|
||||||
return typeData(SuffixType.KEY).getAsEntry();
|
return typeData(SuffixType.KEY).getAsEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,29 +430,16 @@ public interface Node {
|
|||||||
@Override
|
@Override
|
||||||
boolean equals(Object obj);
|
boolean equals(Object obj);
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets if this Node is equal to another node as defined by the given
|
|
||||||
* {@link StandardNodeEquality} predicate.
|
|
||||||
*
|
|
||||||
* @param other the other node
|
|
||||||
* @param equalityPredicate the predicate
|
|
||||||
* @return true if this node is considered equal
|
|
||||||
* @since 4.1
|
|
||||||
*/
|
|
||||||
boolean standardEquals(Node other, StandardNodeEquality equalityPredicate);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if this Node is equal to another node as defined by the given
|
* Gets if this Node is equal to another node as defined by the given
|
||||||
* {@link NodeEqualityPredicate}.
|
* {@link NodeEqualityPredicate}.
|
||||||
*
|
*
|
||||||
* @param other the other node
|
* @param other the other node
|
||||||
* @param equalityPredicate the predicate
|
* @param equalityPredicate the predicate
|
||||||
* @return true if this node is considered equal
|
* @return true if this node is considered equal
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
default boolean equals(Node other, NodeEqualityPredicate equalityPredicate) {
|
boolean equals(Node other, NodeEqualityPredicate equalityPredicate);
|
||||||
return equalityPredicate.areEqual(this, other);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to {@link Node#equals(Object)}, except doesn't take note of the
|
* Similar to {@link Node#equals(Object)}, except doesn't take note of the
|
||||||
@@ -477,11 +447,11 @@ public interface Node {
|
|||||||
*
|
*
|
||||||
* @param other the other node
|
* @param other the other node
|
||||||
* @return true if the two nodes are almost equal
|
* @return true if the two nodes are almost equal
|
||||||
* @deprecated in favour of {@link #equals(Node, NodeEqualityPredicate)}
|
|
||||||
* @see StandardNodeEquality#IGNORE_VALUE
|
* @see StandardNodeEquality#IGNORE_VALUE
|
||||||
|
* @deprecated in favour of {@link #equals(Node, NodeEqualityPredicate)}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
default boolean equalsIgnoringValue(@Nonnull Node other) {
|
default boolean equalsIgnoringValue(@NonNull Node other) {
|
||||||
return equals(other, StandardNodeEquality.IGNORE_VALUE);
|
return equals(other, StandardNodeEquality.IGNORE_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,11 +461,11 @@ public interface Node {
|
|||||||
*
|
*
|
||||||
* @param other the other node
|
* @param other the other node
|
||||||
* @return true if the two nodes are almost equal
|
* @return true if the two nodes are almost equal
|
||||||
* @deprecated in favour of {@link #equals(Node, NodeEqualityPredicate)}
|
|
||||||
* @see StandardNodeEquality#IGNORE_EXPIRY_TIME_AND_VALUE
|
* @see StandardNodeEquality#IGNORE_EXPIRY_TIME_AND_VALUE
|
||||||
|
* @deprecated in favour of {@link #equals(Node, NodeEqualityPredicate)}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
default boolean almostEquals(@Nonnull Node other) {
|
default boolean almostEquals(@NonNull Node other) {
|
||||||
return equals(other, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
return equals(other, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -505,12 +475,12 @@ public interface Node {
|
|||||||
*
|
*
|
||||||
* @param other the other node
|
* @param other the other node
|
||||||
* @return true if the two nodes are almost equal
|
* @return true if the two nodes are almost equal
|
||||||
|
* @see StandardNodeEquality#IGNORE_VALUE_OR_IF_TEMPORARY
|
||||||
* @since 2.8
|
* @since 2.8
|
||||||
* @deprecated in favour of {@link #equals(Node, NodeEqualityPredicate)}
|
* @deprecated in favour of {@link #equals(Node, NodeEqualityPredicate)}
|
||||||
* @see StandardNodeEquality#IGNORE_VALUE_OR_IF_TEMPORARY
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
default boolean equalsIgnoringValueOrTemp(@Nonnull Node other) {
|
default boolean equalsIgnoringValueOrTemp(@NonNull Node other) {
|
||||||
return equals(other, StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY);
|
return equals(other, StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,7 +509,7 @@ public interface Node {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
Builder copyFrom(@Nonnull Node node);
|
Builder copyFrom(@NonNull Node node);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of negated for the node.
|
* Sets the value of negated for the node.
|
||||||
@@ -548,8 +518,7 @@ public interface Node {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
* @see Node#isNegated()
|
* @see Node#isNegated()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder setNegated(boolean negated);
|
||||||
Builder setNegated(boolean negated);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of the node.
|
* Sets the value of the node.
|
||||||
@@ -558,8 +527,7 @@ public interface Node {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
* @see Node#getValue()
|
* @see Node#getValue()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder setValue(boolean value);
|
||||||
Builder setValue(boolean value);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the override property for the node.
|
* Sets the override property for the node.
|
||||||
@@ -571,8 +539,7 @@ public interface Node {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
* @see Node#isOverride()
|
* @see Node#isOverride()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder setOverride(boolean override);
|
||||||
Builder setOverride(boolean override);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the time when the node should expire.
|
* Sets the time when the node should expire.
|
||||||
@@ -584,8 +551,7 @@ public interface Node {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
* @see Node#getExpiryUnixTime()
|
* @see Node#getExpiryUnixTime()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder setExpiry(long expiryUnixTimestamp);
|
||||||
Builder setExpiry(long expiryUnixTimestamp);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the time when the node should expire.
|
* Sets the time when the node should expire.
|
||||||
@@ -594,12 +560,11 @@ public interface Node {
|
|||||||
* system time.</p>
|
* system time.</p>
|
||||||
*
|
*
|
||||||
* @param duration how long the node should be added for
|
* @param duration how long the node should be added for
|
||||||
* @param unit the unit <code>duration</code> is measured in
|
* @param unit the unit <code>duration</code> is measured in
|
||||||
* @return the builder
|
* @return the builder
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull Builder setExpiry(long duration, TimeUnit unit) {
|
||||||
default Builder setExpiry(long duration, TimeUnit unit) {
|
|
||||||
Preconditions.checkArgument(duration > 0, "duration must be positive");
|
Preconditions.checkArgument(duration > 0, "duration must be positive");
|
||||||
long seconds = Objects.requireNonNull(unit, "unit").toSeconds(duration);
|
long seconds = Objects.requireNonNull(unit, "unit").toSeconds(duration);
|
||||||
long timeNow = System.currentTimeMillis() / 1000L;
|
long timeNow = System.currentTimeMillis() / 1000L;
|
||||||
@@ -612,8 +577,7 @@ public interface Node {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder clearExpiry();
|
||||||
Builder clearExpiry();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the world value for the node.
|
* Sets the world value for the node.
|
||||||
@@ -622,8 +586,7 @@ public interface Node {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
* @see Node#getWorld()
|
* @see Node#getWorld()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder setWorld(@Nullable String world);
|
||||||
Builder setWorld(@Nullable String world);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the server value for the node.
|
* Sets the server value for the node.
|
||||||
@@ -632,20 +595,18 @@ public interface Node {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
* @see Node#getServer()
|
* @see Node#getServer()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder setServer(@Nullable String server);
|
||||||
Builder setServer(@Nullable String server);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends an extra context onto the node.
|
* Appends an extra context onto the node.
|
||||||
*
|
*
|
||||||
* @param key the context key
|
* @param key the context key
|
||||||
* @param value the context value
|
* @param value the context value
|
||||||
* @return the builder
|
* @return the builder
|
||||||
* @see ContextSet
|
* @see ContextSet
|
||||||
* @see Node#getContexts()
|
* @see Node#getContexts()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder withExtraContext(@NonNull String key, @NonNull String value);
|
||||||
Builder withExtraContext(@Nonnull String key, @Nonnull String value);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends extra contexts onto the node.
|
* Appends extra contexts onto the node.
|
||||||
@@ -655,8 +616,7 @@ public interface Node {
|
|||||||
* @see ContextSet
|
* @see ContextSet
|
||||||
* @see Node#getContexts()
|
* @see Node#getContexts()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder withExtraContext(@NonNull Map<String, String> map);
|
||||||
Builder withExtraContext(@Nonnull Map<String, String> map);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends extra contexts onto the node.
|
* Appends extra contexts onto the node.
|
||||||
@@ -666,8 +626,7 @@ public interface Node {
|
|||||||
* @see ContextSet
|
* @see ContextSet
|
||||||
* @see Node#getContexts()
|
* @see Node#getContexts()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder withExtraContext(@NonNull Set<Map.Entry<String, String>> context);
|
||||||
Builder withExtraContext(@Nonnull Set<Map.Entry<String, String>> context);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends an extra context onto the node.
|
* Appends an extra context onto the node.
|
||||||
@@ -677,8 +636,7 @@ public interface Node {
|
|||||||
* @see ContextSet
|
* @see ContextSet
|
||||||
* @see Node#getContexts()
|
* @see Node#getContexts()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder withExtraContext(Map.@NonNull Entry<String, String> entry);
|
||||||
Builder withExtraContext(@Nonnull Map.Entry<String, String> entry);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends extra contexts onto the node.
|
* Appends extra contexts onto the node.
|
||||||
@@ -688,8 +646,7 @@ public interface Node {
|
|||||||
* @see ContextSet
|
* @see ContextSet
|
||||||
* @see Node#getContexts()
|
* @see Node#getContexts()
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder withExtraContext(@NonNull ContextSet contextSet);
|
||||||
Builder withExtraContext(@Nonnull ContextSet contextSet);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the extra contexts for the node.
|
* Sets the extra contexts for the node.
|
||||||
@@ -700,16 +657,14 @@ public interface Node {
|
|||||||
* @see Node#getContexts()
|
* @see Node#getContexts()
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Builder setExtraContext(@NonNull ContextSet contextSet);
|
||||||
Builder setExtraContext(@Nonnull ContextSet contextSet);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link Node} instance from the builder.
|
* Creates a {@link Node} instance from the builder.
|
||||||
*
|
*
|
||||||
* @return a new node instance
|
* @return a new node instance
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Node build();
|
||||||
Node build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A rule for determining if two nodes are equal.
|
* A rule for determining if two nodes are equal.
|
||||||
@@ -33,8 +33,7 @@ import javax.annotation.Nonnull;
|
|||||||
* <p>Generally, individual instances of this interface should fulfil the same
|
* <p>Generally, individual instances of this interface should fulfil the same
|
||||||
* requirements as the {@link Object#equals(Object)} contract.</p>
|
* requirements as the {@link Object#equals(Object)} contract.</p>
|
||||||
*
|
*
|
||||||
* <p>Some standard implementations are provided by
|
* <p>Some standard implementations are provided by {@link StandardNodeEquality}.</p>
|
||||||
* {@link StandardNodeEquality}.</p>
|
|
||||||
*
|
*
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@@ -42,12 +41,15 @@ import javax.annotation.Nonnull;
|
|||||||
public interface NodeEqualityPredicate {
|
public interface NodeEqualityPredicate {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the two nodes are equal
|
* 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 o1 the first node
|
||||||
* @param o2 the second node
|
* @param o2 the second node
|
||||||
* @return true if equal
|
* @return true if equal
|
||||||
*/
|
*/
|
||||||
boolean areEqual(@Nonnull Node o1, @Nonnull Node o2);
|
boolean areEqual(@NonNull Node o1, @NonNull Node o2);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assists with constructing {@link Node} instances.
|
* Assists with constructing {@link Node} instances.
|
||||||
@@ -41,8 +41,7 @@ public interface NodeFactory {
|
|||||||
* @return a node builder instance
|
* @return a node builder instance
|
||||||
* @throws NullPointerException if the permission is null
|
* @throws NullPointerException if the permission is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
Node.@NonNull Builder newBuilder(@NonNull String permission);
|
||||||
Node.Builder newBuilder(@Nonnull String permission);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a node builder instance from an existing node
|
* Creates a node builder instance from an existing node
|
||||||
@@ -51,8 +50,7 @@ public interface NodeFactory {
|
|||||||
* @return a node builder instance
|
* @return a node builder instance
|
||||||
* @throws NullPointerException if the other node is null
|
* @throws NullPointerException if the other node is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
Node.@NonNull Builder newBuilderFromExisting(@NonNull Node other);
|
||||||
Node.Builder newBuilderFromExisting(@Nonnull Node other);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,19 +62,17 @@ public interface NodeFactory {
|
|||||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
Node.@NonNull Builder makeGroupNode(@NonNull Group group);
|
||||||
Node.Builder makeGroupNode(@Nonnull Group group);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a node builder from a group
|
* Creates a node builder from a group
|
||||||
*
|
*
|
||||||
* @param groupName the name of the group
|
* @param groupName the name of the group
|
||||||
* @return a node builder instance
|
* @return a node builder instance
|
||||||
* @throws NullPointerException if the groupName is null
|
* @throws NullPointerException if the groupName is null
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
Node.@NonNull Builder makeGroupNode(@NonNull String groupName);
|
||||||
Node.Builder makeGroupNode(@Nonnull String groupName);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a node builder from a key value pair
|
* Creates a node builder from a key value pair
|
||||||
@@ -86,21 +82,19 @@ public interface NodeFactory {
|
|||||||
* @return a node builder instance
|
* @return a node builder instance
|
||||||
* @throws NullPointerException if the key or value is null
|
* @throws NullPointerException if the key or value is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
Node.@NonNull Builder makeMetaNode(@NonNull String key, @NonNull String value);
|
||||||
Node.Builder makeMetaNode(@Nonnull String key, @Nonnull String value);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a node builder for the given chat meta type
|
* Creates a node builder for the given chat meta type
|
||||||
*
|
*
|
||||||
* @param type the type
|
* @param type the type
|
||||||
* @param priority the priority
|
* @param priority the priority
|
||||||
* @param value the value for the prefix/suffix
|
* @param value the value for the prefix/suffix
|
||||||
* @return a node builder instance
|
* @return a node builder instance
|
||||||
* @throws NullPointerException if the type or value is null
|
* @throws NullPointerException if the type or value is null
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
Node.@NonNull Builder makeChatMetaNode(@NonNull ChatMetaType type, int priority, @NonNull String value);
|
||||||
Node.Builder makeChatMetaNode(@Nonnull ChatMetaType type, int priority, @Nonnull String value);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a node builder from a prefix string and priority
|
* Creates a node builder from a prefix string and priority
|
||||||
@@ -110,8 +104,7 @@ public interface NodeFactory {
|
|||||||
* @return a node builder instance
|
* @return a node builder instance
|
||||||
* @throws NullPointerException if the prefix is null
|
* @throws NullPointerException if the prefix is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
Node.@NonNull Builder makePrefixNode(int priority, @NonNull String prefix);
|
||||||
Node.Builder makePrefixNode(int priority, @Nonnull String prefix);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a node builder from a prefix string and priority
|
* Creates a node builder from a prefix string and priority
|
||||||
@@ -121,7 +114,6 @@ public interface NodeFactory {
|
|||||||
* @return a node builder instance
|
* @return a node builder instance
|
||||||
* @throws NullPointerException if the suffix is null
|
* @throws NullPointerException if the suffix is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
Node.@NonNull Builder makeSuffixNode(int priority, @NonNull String suffix);
|
||||||
Node.Builder makeSuffixNode(int priority, @Nonnull String suffix);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -31,46 +31,61 @@ import com.google.common.collect.Multimap;
|
|||||||
import me.lucko.luckperms.api.caching.CachedData;
|
import me.lucko.luckperms.api.caching.CachedData;
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
|
import me.lucko.luckperms.api.manager.GroupManager;
|
||||||
|
import me.lucko.luckperms.api.manager.UserManager;
|
||||||
|
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 org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object which holds permissions.
|
* Generic superinterface for an object which holds permissions.
|
||||||
*
|
|
||||||
* <p>Any changes made to permission holding objects will be lost unless the
|
|
||||||
* instance is saved back to the {@link Storage}.</p>
|
|
||||||
*/
|
*/
|
||||||
public interface PermissionHolder {
|
public interface PermissionHolder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the objects name.
|
* Gets the objects generic name.
|
||||||
*
|
*
|
||||||
* <p>{@link User#getUuid()}, {@link User#getName()} or {@link Group#getName()} should normally be used instead of
|
* <p>The result of this method is guaranteed to be a unique identifier for distinct instances
|
||||||
* this method.</p>
|
* of the same type of object.</p>
|
||||||
|
*
|
||||||
|
* <p>For {@link User}s, this method returns a {@link UUID#toString() string} representation of
|
||||||
|
* the users {@link User#getUuid() unique id}.</p>
|
||||||
|
*
|
||||||
|
* <p>For {@link Group}s, this method returns the {@link Group#getName() group name}.</p>
|
||||||
|
*
|
||||||
|
* <p>The {@link User#getUuid()}, {@link User#getName()} and {@link Group#getName()} methods
|
||||||
|
* define a "tighter" specification for obtaining object identifiers.</p>
|
||||||
*
|
*
|
||||||
* @return the identifier for this object. Either a uuid string or name.
|
* @return the identifier for this object. Either a uuid string or name.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getObjectName();
|
||||||
String getObjectName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a friendly name for this holder, to be displayed in command output, etc.
|
* Gets a friendly name for this holder, to be displayed in command output, etc.
|
||||||
*
|
*
|
||||||
* <p>This will <strong>always</strong> return a value, eventually falling back to {@link #getObjectName()} if no
|
* <p>This will <strong>always</strong> return a value, eventually falling back to
|
||||||
* other "friendlier" identifiers are present.</p>
|
* {@link #getObjectName()} if no other "friendlier" identifiers are present.</p>
|
||||||
|
*
|
||||||
|
* <p>For {@link User}s, this method will attempt to return the {@link User#getName() username},
|
||||||
|
* before falling back to {@link #getObjectName()}.</p>
|
||||||
|
*
|
||||||
|
* <p>For {@link Group}s, this method will attempt to return the groups display name, before
|
||||||
|
* falling back to {@link #getObjectName()}.</p>
|
||||||
*
|
*
|
||||||
* @return a friendly identifier for this holder
|
* @return a friendly identifier for this holder
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getFriendlyName();
|
||||||
String getFriendlyName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the holders {@link CachedData} cache.
|
* Gets the holders {@link CachedData} cache.
|
||||||
@@ -78,8 +93,7 @@ public interface PermissionHolder {
|
|||||||
* @return the holders cached data.
|
* @return the holders cached data.
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CachedData getCachedData();
|
||||||
CachedData getCachedData();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refreshes and applies any changes to the cached holder data.
|
* Refreshes and applies any changes to the cached holder data.
|
||||||
@@ -90,8 +104,7 @@ public interface PermissionHolder {
|
|||||||
* @return the task future
|
* @return the task future
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Void> refreshCachedData();
|
||||||
CompletableFuture<Void> refreshCachedData();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the backing multimap containing every permission this holder has.
|
* Gets the backing multimap containing every permission this holder has.
|
||||||
@@ -102,8 +115,7 @@ public interface PermissionHolder {
|
|||||||
* @return the holders own permissions
|
* @return the holders own permissions
|
||||||
* @since 3.3
|
* @since 3.3
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull ImmutableSetMultimap<ImmutableContextSet, Node> getNodes();
|
||||||
ImmutableSetMultimap<ImmutableContextSet, Node> getNodes();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the backing multimap containing every transient permission this holder has.
|
* Gets the backing multimap containing every transient permission this holder has.
|
||||||
@@ -115,8 +127,7 @@ public interface PermissionHolder {
|
|||||||
* @return the holders own permissions
|
* @return the holders own permissions
|
||||||
* @since 3.3
|
* @since 3.3
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull ImmutableSetMultimap<ImmutableContextSet, Node> getTransientNodes();
|
||||||
ImmutableSetMultimap<ImmutableContextSet, Node> getTransientNodes();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a flattened/squashed view of the holders permissions.
|
* Gets a flattened/squashed view of the holders permissions.
|
||||||
@@ -128,60 +139,90 @@ public interface PermissionHolder {
|
|||||||
*
|
*
|
||||||
* <p>Use {@link #getPermissions()} for a view without duplicates.</p>
|
* <p>Use {@link #getPermissions()} for a view without duplicates.</p>
|
||||||
*
|
*
|
||||||
|
* <p>This method <b>does not</b> resolve inheritance rules.</p>
|
||||||
|
*
|
||||||
* @return a list of the holders own nodes.
|
* @return a list of the holders own nodes.
|
||||||
* @since 3.3
|
* @since 3.3
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull List<Node> getOwnNodes();
|
||||||
List<Node> getOwnNodes();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a sorted set of all held permissions.
|
* Gets a sorted set of all held permissions.
|
||||||
*
|
*
|
||||||
|
* <p>Effectively a sorted version of {@link #getOwnNodes()}, without duplicates. Use the
|
||||||
|
* aforementioned method if you don't require either of these attributes.</p>
|
||||||
|
*
|
||||||
|
* <p>This method <b>does not</b> resolve inheritance rules.</p>
|
||||||
|
*
|
||||||
|
* <p>Although this method is named getPermissions, it will actually return all types of node.</p>
|
||||||
|
*
|
||||||
* @return an immutable set of permissions in priority order
|
* @return an immutable set of permissions in priority order
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull SortedSet<? extends Node> getPermissions();
|
||||||
SortedSet<? extends Node> getPermissions();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to {@link #getPermissions()}, except without transient permissions.
|
* Similar to {@link #getPermissions()}, except only including permissions from the enduring
|
||||||
|
* node map. (See {@link #getNodes()})
|
||||||
*
|
*
|
||||||
* <p>Unlike transient permissions, enduring permissions will be saved to storage, and exist after the session.</p>
|
* <p>Unlike transient permissions, enduring permissions will be saved to storage, and exist
|
||||||
|
* after the session.</p>
|
||||||
|
*
|
||||||
|
* <p>This method <b>does not</b> resolve inheritance rules.</p>
|
||||||
|
*
|
||||||
|
* <p>Although this method is named getEnduringPermissions, it will actually return all types
|
||||||
|
* of node.</p>
|
||||||
*
|
*
|
||||||
* @return a set of nodes
|
* @return a set of nodes
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Set<? extends Node> getEnduringPermissions();
|
||||||
Set<? extends Node> getEnduringPermissions();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to {@link #getPermissions()}, except without enduring permissions.
|
* Similar to {@link #getPermissions()}, except only including permissions from the enduring
|
||||||
|
* node map. (See {@link #getTransientNodes()})
|
||||||
*
|
*
|
||||||
* <p>Transient permissions only exist for the duration of the session.</p>
|
* <p>Transient permissions only exist for the duration of the session.</p>
|
||||||
*
|
*
|
||||||
|
* <p>This method <b>does not</b> resolve inheritance rules.</p>
|
||||||
|
*
|
||||||
|
* <p>Although this method is named getTransientPermissions, it will actually return all types
|
||||||
|
* of node.</p>
|
||||||
|
*
|
||||||
* @return a set of nodes
|
* @return a set of nodes
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Set<? extends Node> getTransientPermissions();
|
||||||
Set<? extends Node> getTransientPermissions();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes the nodes and returns the non-temporary ones.
|
* A filtered view of this holders nodes, only including permanent entries.
|
||||||
|
*
|
||||||
|
* <p>Data is sourced from {@link #getOwnNodes()}, filtered, and then collected to a set.</p>
|
||||||
|
*
|
||||||
|
* <p>This method <b>does not</b> resolve inheritance rules.</p>
|
||||||
|
*
|
||||||
|
* <p>Although this method is named getPermanentPermissionNodes, it will actually return all types
|
||||||
|
* of node.</p>
|
||||||
*
|
*
|
||||||
* @return a set of permanent nodes
|
* @return a set of permanent nodes
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Set<Node> getPermanentPermissionNodes();
|
||||||
Set<Node> getPermanentPermissionNodes();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes the nodes and returns the temporary ones.
|
* A filtered view of this holders nodes, only including temporary entries.
|
||||||
|
*
|
||||||
|
* <p>Data is sourced from {@link #getOwnNodes()}, filtered, and then collected to a set.</p>
|
||||||
|
*
|
||||||
|
* <p>This method <b>does not</b> resolve inheritance rules.</p>
|
||||||
|
*
|
||||||
|
* <p>Although this method is named getTemporaryPermissionNodes, it will actually return all types
|
||||||
|
* of node.</p>
|
||||||
*
|
*
|
||||||
* @return a set of temporary nodes
|
* @return a set of temporary nodes
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Set<Node> getTemporaryPermissionNodes();
|
||||||
Set<Node> getTemporaryPermissionNodes();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively resolves this holders permissions.
|
* Recursively resolves this holders permissions.
|
||||||
@@ -191,12 +232,15 @@ public interface PermissionHolder {
|
|||||||
*
|
*
|
||||||
* <p>This means the list will contain duplicates.</p>
|
* <p>This means the list will contain duplicates.</p>
|
||||||
*
|
*
|
||||||
|
* <p>Inheritance is performed according to the platforms rules, and the order will vary
|
||||||
|
* depending on the accumulation order. By default, the holders own nodes are first in the list,
|
||||||
|
* with the entries from the end of the inheritance tree appearing last.</p>
|
||||||
|
*
|
||||||
* @param contexts the contexts for the lookup
|
* @param contexts the contexts for the lookup
|
||||||
* @return a list of nodes
|
* @return a list of nodes
|
||||||
* @since 3.3
|
* @since 3.3
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull List<LocalizedNode> resolveInheritances(@NonNull Contexts contexts);
|
||||||
List<LocalizedNode> resolveInheritances(Contexts contexts);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively resolves this holders permissions.
|
* Recursively resolves this holders permissions.
|
||||||
@@ -209,142 +253,157 @@ public interface PermissionHolder {
|
|||||||
* <p>Unlike {@link #resolveInheritances(Contexts)}, this method does not
|
* <p>Unlike {@link #resolveInheritances(Contexts)}, this method does not
|
||||||
* filter by context, at all.</p>
|
* filter by context, at all.</p>
|
||||||
*
|
*
|
||||||
|
* <p>Inheritance is performed according to the platforms rules, and the order will vary
|
||||||
|
* depending on the accumulation order. By default, the holders own nodes are first in the list,
|
||||||
|
* with the entries from the end of the inheritance tree appearing last.</p>
|
||||||
|
*
|
||||||
* @return a list of nodes
|
* @return a list of nodes
|
||||||
* @since 3.3
|
* @since 3.3
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull List<LocalizedNode> resolveInheritances();
|
||||||
List<LocalizedNode> resolveInheritances();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a mutable sorted set of the nodes that this object has and inherits, filtered by context
|
* Gets a mutable sorted set of the nodes that this object has and inherits, filtered by context
|
||||||
*
|
*
|
||||||
* <p>Unlike {@link #getAllNodesFiltered(Contexts)}, this method will not filter individual nodes. The context is only
|
* <p>Unlike {@link #getAllNodesFiltered(Contexts)}, this method will not filter individual
|
||||||
* used to determine which groups should apply.</p>
|
* nodes by context. The context is only used to determine which groups should apply.</p>
|
||||||
*
|
*
|
||||||
* <p>Nodes are sorted into priority order.</p>
|
* <p>Nodes are sorted into priority order. The order of inheritance is only important during
|
||||||
|
* the process of flattening inherited entries.</p>
|
||||||
*
|
*
|
||||||
* @param contexts the context for the lookup
|
* @param contexts the context for the lookup
|
||||||
* @return a mutable sorted set of permissions
|
* @return an immutable sorted set of permissions
|
||||||
* @throws NullPointerException if the context is null
|
* @throws NullPointerException if the context is null
|
||||||
* @since 2.11
|
* @since 2.11
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull SortedSet<LocalizedNode> getAllNodes(@NonNull Contexts contexts);
|
||||||
SortedSet<LocalizedNode> getAllNodes(@Nonnull Contexts contexts);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a mutable sorted set of the nodes that this object has and inherits.
|
* Gets a mutable sorted set of the nodes that this object has and inherits.
|
||||||
*
|
*
|
||||||
* <p>Unlike {@link #getAllNodes(Contexts)}, this method does not filter by context, at all.</p>
|
* <p>Unlike {@link #getAllNodes(Contexts)}, this method does not filter by context, at all.</p>
|
||||||
*
|
*
|
||||||
* <p>Nodes are sorted into priority order.</p>
|
* <p>Nodes are sorted into priority order. The order of inheritance is only important during
|
||||||
|
* the process of flattening inherited entries.</p>
|
||||||
*
|
*
|
||||||
* @return a mutable sorted set of permissions
|
* @return an immutable sorted set of permissions
|
||||||
* @throws NullPointerException if the context is null
|
* @throws NullPointerException if the context is null
|
||||||
* @since 3.3
|
* @since 3.3
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull SortedSet<LocalizedNode> getAllNodes();
|
||||||
SortedSet<LocalizedNode> getAllNodes();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a mutable set of the nodes that this object has and inherits, filtered by context.
|
* Gets a mutable set of the nodes that this object has and inherits, filtered by context.
|
||||||
*
|
*
|
||||||
* <p>Unlike {@link #getAllNodes(Contexts)}, this method WILL filter individual nodes, and only return ones that fully
|
* <p>Unlike {@link #getAllNodes(Contexts)}, this method WILL filter individual nodes,
|
||||||
* meet the context provided.</p>
|
* and only return ones that fully meet the context provided.</p>
|
||||||
*
|
*
|
||||||
* @param contexts the context for the lookup
|
* @param contexts the context for the lookup
|
||||||
* @return a mutable set of permissions
|
* @return a mutable set of permissions
|
||||||
* @throws NullPointerException if the context is null
|
* @throws NullPointerException if the context is null
|
||||||
* @since 2.11
|
* @since 2.11
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Set<LocalizedNode> getAllNodesFiltered(@NonNull Contexts contexts);
|
||||||
Set<LocalizedNode> getAllNodesFiltered(@Nonnull Contexts contexts);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the output of {@link #getAllNodesFiltered(Contexts)}, and expands shorthand permissions.
|
* Converts the output of {@link #getAllNodesFiltered(Contexts)} into string and boolean form,
|
||||||
|
* and expands shorthand permissions.
|
||||||
*
|
*
|
||||||
* @param contexts the context for the lookup
|
* @param contexts the context for the lookup
|
||||||
* @param lowerCase if the keys should be made lowercase whilst being exported
|
* @param convertToLowercase if the keys should be made lowercase whilst being exported
|
||||||
* @return a mutable map of permissions
|
* @return a mutable map of permissions
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Map<String, Boolean> exportNodes(@NonNull Contexts contexts, boolean convertToLowercase);
|
||||||
Map<String, Boolean> exportNodes(@Nonnull Contexts contexts, boolean lowerCase);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes temporary permissions that have expired
|
* Removes any temporary permissions that have expired.
|
||||||
|
*
|
||||||
|
* <p>This method is called periodically by the platform, so it is only necessary to run
|
||||||
|
* if you want to guarentee that the current data is totally up-to-date.</p>
|
||||||
*/
|
*/
|
||||||
void auditTemporaryPermissions();
|
void auditTemporaryPermissions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if the object has a certain permission
|
* Checks to see if the object has a certain permission.
|
||||||
*
|
*
|
||||||
* @param node the node to check for
|
* <p>Although this method is named hasPermission, it can be used for all node types.</p>
|
||||||
|
*
|
||||||
|
* @param node the node to check for
|
||||||
* @param equalityPredicate how to determine if a node matches
|
* @param equalityPredicate how to determine if a node matches
|
||||||
* @return a Tristate for the holders permission status for the node
|
* @return a Tristate for the holders permission status for the node
|
||||||
* @throws NullPointerException if the node is null
|
* @throws NullPointerException if the node is null
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Tristate hasPermission(@NonNull Node node, @NonNull NodeEqualityPredicate equalityPredicate);
|
||||||
Tristate hasPermission(@Nonnull Node node, @Nonnull NodeEqualityPredicate equalityPredicate);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if the object has a certain permission
|
* Checks to see if the object has a certain permission.
|
||||||
*
|
*
|
||||||
* @param node the node to check for
|
* <p>Although this method is named hasTransientPermission, it can be used for all node types.</p>
|
||||||
|
*
|
||||||
|
* @param node the node to check for
|
||||||
* @param equalityPredicate how to determine if a node matches
|
* @param equalityPredicate how to determine if a node matches
|
||||||
* @return a Tristate for the holders permission status for the node
|
* @return a Tristate for the holders permission status for the node
|
||||||
* @throws NullPointerException if the node is null
|
* @throws NullPointerException if the node is null
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Tristate hasTransientPermission(@NonNull Node node, @NonNull NodeEqualityPredicate equalityPredicate);
|
||||||
Tristate hasTransientPermission(@Nonnull Node node, @Nonnull NodeEqualityPredicate equalityPredicate);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if the object inherits a certain permission
|
* Checks to see if the object inherits a certain permission.
|
||||||
*
|
*
|
||||||
* @param node the node to check for
|
* <p>Although this method is named inheritsPermission, it can be used for all node types.</p>
|
||||||
|
*
|
||||||
|
* @param node the node to check for
|
||||||
* @param equalityPredicate how to determine if a node matches
|
* @param equalityPredicate how to determine if a node matches
|
||||||
* @return a Tristate for the holders inheritance status for the node
|
* @return a Tristate for the holders inheritance status for the node
|
||||||
* @throws NullPointerException if the node is null
|
* @throws NullPointerException if the node is null
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Tristate inheritsPermission(@NonNull Node node, @NonNull NodeEqualityPredicate equalityPredicate);
|
||||||
Tristate inheritsPermission(@Nonnull Node node, @Nonnull NodeEqualityPredicate equalityPredicate);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if the object has a certain permission
|
* Checks to see if the object has a certain permission.
|
||||||
|
*
|
||||||
|
* <p>Although this method is named hasPermission, it can be used for all node types.</p>
|
||||||
*
|
*
|
||||||
* @param node the node to check for
|
* @param node the node to check for
|
||||||
* @return a Tristate for the holders permission status for the node
|
* @return a Tristate for the holders permission status for the node
|
||||||
* @throws NullPointerException if the node is null
|
* @throws NullPointerException if the node is null
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Tristate hasPermission(@NonNull Node node);
|
||||||
Tristate hasPermission(@Nonnull Node node);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if the object has a certain permission
|
* Checks to see if the object has a certain permission.
|
||||||
|
*
|
||||||
|
* <p>Although this method is named hasTransientPermission, it can be used for all node types.</p>
|
||||||
*
|
*
|
||||||
* @param node the node to check for
|
* @param node the node to check for
|
||||||
* @return a Tristate for the holders permission status for the node
|
* @return a Tristate for the holders permission status for the node
|
||||||
* @throws NullPointerException if the node is null
|
* @throws NullPointerException if the node is null
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Tristate hasTransientPermission(@NonNull Node node);
|
||||||
Tristate hasTransientPermission(@Nonnull Node node);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if the object inherits a certain permission
|
* Checks to see if the object inherits a certain permission.
|
||||||
|
*
|
||||||
|
* <p>Although this method is named inheritsPermission, it can be used for all node types.</p>
|
||||||
*
|
*
|
||||||
* @param node the node to check for
|
* @param node the node to check for
|
||||||
* @return a Tristate for the holders inheritance status for the node
|
* @return a Tristate for the holders inheritance status for the node
|
||||||
* @throws NullPointerException if the node is null
|
* @throws NullPointerException if the node is null
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Tristate inheritsPermission(@NonNull Node node);
|
||||||
Tristate inheritsPermission(@Nonnull Node node);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if this holder inherits another group directly
|
* Check to see if this holder inherits another group in the global context.
|
||||||
|
*
|
||||||
|
* <p>"Global context" simply means an empty context set.</p>
|
||||||
|
*
|
||||||
|
* <p>This method only checks for direct inheritance - one hop up the inheritance tree.</p>
|
||||||
*
|
*
|
||||||
* @param group The group to check membership of
|
* @param group The group to check membership of
|
||||||
* @return true if the group inherits the other group
|
* @return true if the group inherits the other group
|
||||||
@@ -352,141 +411,315 @@ public interface PermissionHolder {
|
|||||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
boolean inheritsGroup(@Nonnull Group group);
|
boolean inheritsGroup(@NonNull Group group);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if this holder inherits another group directly
|
* Check to see if this holder inherits another group.
|
||||||
*
|
*
|
||||||
* @param group The group to check membership of
|
* <p>This method only checks for direct inheritance - one hop up the inheritance tree.</p>
|
||||||
|
*
|
||||||
|
* @param group The group to check membership of
|
||||||
* @param contextSet the context set to filter by
|
* @param contextSet the context set to filter by
|
||||||
* @return true if the group inherits the other group
|
* @return true if the group inherits the other group
|
||||||
* @throws NullPointerException if the group is null
|
* @throws NullPointerException if the group is null
|
||||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
boolean inheritsGroup(@Nonnull Group group, @Nonnull ContextSet contextSet);
|
boolean inheritsGroup(@NonNull Group group, @NonNull ContextSet contextSet);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a permission for the object
|
* Sets a permission node for the permission holder.
|
||||||
|
*
|
||||||
|
* <p>Although this method is named setPermission, it can be used for all node types.</p>
|
||||||
|
*
|
||||||
|
* <p>The effect of this mutate operation will not persist in storage unless changes are
|
||||||
|
* explicitly saved. If changes are not saved, the effect will only be observed until the next
|
||||||
|
* time the holders permission data is (re)loaded. Changes to {@link User}s should be saved
|
||||||
|
* using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved
|
||||||
|
* using {@link GroupManager#saveGroup(Group)}.</p>
|
||||||
|
*
|
||||||
|
* <p>Before making changes to a user or group, it may be a good idea to load a fresh copy of
|
||||||
|
* the backing data from the storage if you haven't done so already, to avoid overwriting changes
|
||||||
|
* made already. This can be done via {@link UserManager#loadUser(UUID)} or
|
||||||
|
* {@link GroupManager#loadGroup(String)} respectively.</p>
|
||||||
*
|
*
|
||||||
* @param node The node to be set
|
* @param node The node to be set
|
||||||
* @return the result of the operation
|
* @return the result of the operation
|
||||||
* @throws NullPointerException if the node is null
|
* @throws NullPointerException if the node is null
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull DataMutateResult setPermission(@NonNull Node node);
|
||||||
DataMutateResult setPermission(@Nonnull Node node);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a transient permission for the object
|
* Sets a permission node for the permission holder.
|
||||||
|
*
|
||||||
|
* <p>Although this method is named setPermission, it can be used for all node types.</p>
|
||||||
|
*
|
||||||
|
* <p>The effect of this mutate operation will not persist in storage unless changes are
|
||||||
|
* explicitly saved. If changes are not saved, the effect will only be observed until the next
|
||||||
|
* time the holders permission data is (re)loaded. Changes to {@link User}s should be saved
|
||||||
|
* using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved
|
||||||
|
* using {@link GroupManager#saveGroup(Group)}.</p>
|
||||||
|
*
|
||||||
|
* <p>Before making changes to a user or group, it may be a good idea to load a fresh copy of
|
||||||
|
* the backing data from the storage if you haven't done so already, to avoid overwriting changes
|
||||||
|
* made already. This can be done via {@link UserManager#loadUser(UUID)} or
|
||||||
|
* {@link GroupManager#loadGroup(String)} respectively.</p>
|
||||||
|
*
|
||||||
|
* @param node The node to be set
|
||||||
|
* @param temporaryMergeBehaviour The behaviour used to merge temporary permission entries
|
||||||
|
* @return the result of the operation
|
||||||
|
* @throws NullPointerException if the node is null
|
||||||
|
* @since 4.3
|
||||||
|
*/
|
||||||
|
@NonNull TemporaryDataMutateResult setPermission(@NonNull Node node, @NonNull TemporaryMergeBehaviour temporaryMergeBehaviour);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a transient permission for the permission holder.
|
||||||
*
|
*
|
||||||
* <p>A transient node is a permission that does not persist.
|
* <p>A transient node is a permission that does not persist.
|
||||||
* Whenever a user logs out of the server, or the server restarts, this permission will disappear.
|
* Whenever a user logs out of the server, or the server restarts, this permission will
|
||||||
* It is never saved to the datastore, and therefore will not apply on other servers.</p>
|
* disappear. It is never saved to the datastore, and therefore will not apply on other
|
||||||
|
* servers.</p>
|
||||||
*
|
*
|
||||||
* <p>This is useful if you want to temporarily set a permission for a user while they're online, but don't
|
* <p>This is useful if you want to temporarily set a permission for a user while they're
|
||||||
* want it to persist, and have to worry about removing it when they log out.</p>
|
* online, but don't want it to persist, and have to worry about removing it when they log
|
||||||
|
* out.</p>
|
||||||
*
|
*
|
||||||
* <p>For unsetting a transient permission, see {@link #unsetTransientPermission(Node)}</p>
|
* <p>For unsetting a transient permission, see {@link #unsetTransientPermission(Node)}.</p>
|
||||||
|
*
|
||||||
|
* <p>Although this method is named setTransientPermission, it can be used for all node types.</p>
|
||||||
*
|
*
|
||||||
* @param node The node to be set
|
* @param node The node to be set
|
||||||
* @return the result of the operation
|
* @return the result of the operation
|
||||||
* @throws NullPointerException if the node is null
|
* @throws NullPointerException if the node is null
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull DataMutateResult setTransientPermission(@NonNull Node node);
|
||||||
DataMutateResult setTransientPermission(@Nonnull Node node);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsets a permission for the object
|
* Sets a transient permission for the permission holder.
|
||||||
|
*
|
||||||
|
* <p>A transient node is a permission that does not persist.
|
||||||
|
* Whenever a user logs out of the server, or the server restarts, this permission will
|
||||||
|
* disappear. It is never saved to the datastore, and therefore will not apply on other
|
||||||
|
* servers.</p>
|
||||||
|
*
|
||||||
|
* <p>This is useful if you want to temporarily set a permission for a user while they're
|
||||||
|
* online, but don't want it to persist, and have to worry about removing it when they log
|
||||||
|
* out.</p>
|
||||||
|
*
|
||||||
|
* <p>For unsetting a transient permission, see {@link #unsetTransientPermission(Node)}.</p>
|
||||||
|
*
|
||||||
|
* <p>Although this method is named setTransientPermission, it can be used for all node types.</p>
|
||||||
|
*
|
||||||
|
* @param node The node to be se
|
||||||
|
* @param temporaryMergeBehaviour The behaviour used to merge temporary permission entries
|
||||||
|
* @return the result of the operation
|
||||||
|
* @throws NullPointerException if the node is null
|
||||||
|
* @since 4.3
|
||||||
|
*/
|
||||||
|
@NonNull TemporaryDataMutateResult setTransientPermission(@NonNull Node node, @NonNull TemporaryMergeBehaviour temporaryMergeBehaviour);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unsets a permission for the permission holder.
|
||||||
|
*
|
||||||
|
* <p>Although this method is named unsetPermission, it can be used for all node types.</p>
|
||||||
|
*
|
||||||
|
* <p>The effect of this mutate operation will not persist in storage unless changes are
|
||||||
|
* explicitly saved. If changes are not saved, the effect will only be observed until the next
|
||||||
|
* time the holders permission data is (re)loaded. Changes to {@link User}s should be saved
|
||||||
|
* using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved
|
||||||
|
* using {@link GroupManager#saveGroup(Group)}.</p>
|
||||||
|
*
|
||||||
|
* <p>Before making changes to a user or group, it may be a good idea to load a fresh copy of
|
||||||
|
* the backing data from the storage if you haven't done so already, to avoid overwriting changes
|
||||||
|
* made already. This can be done via {@link UserManager#loadUser(UUID)} or
|
||||||
|
* {@link GroupManager#loadGroup(String)} respectively.</p>
|
||||||
*
|
*
|
||||||
* @param node The node to be unset
|
* @param node The node to be unset
|
||||||
* @return the result of the operation
|
* @return the result of the operation
|
||||||
* @throws NullPointerException if the node is null
|
* @throws NullPointerException if the node is null
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull DataMutateResult unsetPermission(@NonNull Node node);
|
||||||
DataMutateResult unsetPermission(@Nonnull Node node);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsets a transient permission for the object
|
* Unsets a transient permission for the permission holder.
|
||||||
|
*
|
||||||
|
* <p>Although this method is named unsetTransientPermission, it can be used for all node types.</p>
|
||||||
*
|
*
|
||||||
* @param node The node to be unset
|
* @param node The node to be unset
|
||||||
* @return the result of the operation
|
* @return the result of the operation
|
||||||
* @throws NullPointerException if the node is null
|
* @throws NullPointerException if the node is null
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull DataMutateResult unsetTransientPermission(@NonNull Node node);
|
||||||
DataMutateResult unsetTransientPermission(@Nonnull Node node);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears any nodes from the holder which pass the predicate
|
* Clears any nodes from the holder which pass the predicate.
|
||||||
|
*
|
||||||
|
* <p>This method only targets enduring data.</p>
|
||||||
|
*
|
||||||
|
* <p>The effect of this mutate operation will not persist in storage unless changes are
|
||||||
|
* explicitly saved. If changes are not saved, the effect will only be observed until the next
|
||||||
|
* time the holders permission data is (re)loaded. Changes to {@link User}s should be saved
|
||||||
|
* using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved
|
||||||
|
* using {@link GroupManager#saveGroup(Group)}.</p>
|
||||||
|
*
|
||||||
|
* <p>Before making changes to a user or group, it may be a good idea to load a fresh copy of
|
||||||
|
* the backing data from the storage if you haven't done so already, to avoid overwriting changes
|
||||||
|
* made already. This can be done via {@link UserManager#loadUser(UUID)} or
|
||||||
|
* {@link GroupManager#loadGroup(String)} respectively.</p>
|
||||||
*
|
*
|
||||||
* @param test the predicate to test for nodes which should be removed
|
* @param test the predicate to test for nodes which should be removed
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
void clearMatching(@Nonnull Predicate<Node> test);
|
void clearMatching(@NonNull Predicate<Node> test);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears any transient nodes from the holder which pass the predicate
|
* Clears any transient nodes from the holder which pass the predicate.
|
||||||
|
*
|
||||||
|
* <p>The effect of this mutate operation will not persist in storage unless changes are
|
||||||
|
* explicitly saved. If changes are not saved, the effect will only be observed until the next
|
||||||
|
* time the holders permission data is (re)loaded. Changes to {@link User}s should be saved
|
||||||
|
* using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved
|
||||||
|
* using {@link GroupManager#saveGroup(Group)}.</p>
|
||||||
|
*
|
||||||
|
* <p>Before making changes to a user or group, it may be a good idea to load a fresh copy of
|
||||||
|
* the backing data from the storage if you haven't done so already, to avoid overwriting changes
|
||||||
|
* made already. This can be done via {@link UserManager#loadUser(UUID)} or
|
||||||
|
* {@link GroupManager#loadGroup(String)} respectively.</p>
|
||||||
*
|
*
|
||||||
* @param test the predicate to test for nodes which should be removed
|
* @param test the predicate to test for nodes which should be removed
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
void clearMatchingTransient(@Nonnull Predicate<Node> test);
|
void clearMatchingTransient(@NonNull Predicate<Node> test);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all nodes held by the object
|
* Clears all nodes held by the permission holder.
|
||||||
|
*
|
||||||
|
* <p>The effect of this mutate operation will not persist in storage unless changes are
|
||||||
|
* explicitly saved. If changes are not saved, the effect will only be observed until the next
|
||||||
|
* time the holders permission data is (re)loaded. Changes to {@link User}s should be saved
|
||||||
|
* using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved
|
||||||
|
* using {@link GroupManager#saveGroup(Group)}.</p>
|
||||||
|
*
|
||||||
|
* <p>Before making changes to a user or group, it may be a good idea to load a fresh copy of
|
||||||
|
* the backing data from the storage if you haven't done so already, to avoid overwriting changes
|
||||||
|
* made already. This can be done via {@link UserManager#loadUser(UUID)} or
|
||||||
|
* {@link GroupManager#loadGroup(String)} respectively.</p>
|
||||||
*
|
*
|
||||||
* @since 2.17
|
* @since 2.17
|
||||||
*/
|
*/
|
||||||
void clearNodes();
|
void clearNodes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all nodes held by the object in a specific context
|
* Clears all nodes held by the permission holder in a specific context.
|
||||||
|
*
|
||||||
|
* <p>The effect of this mutate operation will not persist in storage unless changes are
|
||||||
|
* explicitly saved. If changes are not saved, the effect will only be observed until the next
|
||||||
|
* time the holders permission data is (re)loaded. Changes to {@link User}s should be saved
|
||||||
|
* using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved
|
||||||
|
* using {@link GroupManager#saveGroup(Group)}.</p>
|
||||||
|
*
|
||||||
|
* <p>Before making changes to a user or group, it may be a good idea to load a fresh copy of
|
||||||
|
* the backing data from the storage if you haven't done so already, to avoid overwriting changes
|
||||||
|
* made already. This can be done via {@link UserManager#loadUser(UUID)} or
|
||||||
|
* {@link GroupManager#loadGroup(String)} respectively.</p>
|
||||||
*
|
*
|
||||||
* @param contextSet the contexts to filter by
|
* @param contextSet the contexts to filter by
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
void clearNodes(@Nonnull ContextSet contextSet);
|
void clearNodes(@NonNull ContextSet contextSet);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all parent groups
|
* Clears all parent groups.
|
||||||
|
*
|
||||||
|
* <p>The effect of this mutate operation will not persist in storage unless changes are
|
||||||
|
* explicitly saved. If changes are not saved, the effect will only be observed until the next
|
||||||
|
* time the holders permission data is (re)loaded. Changes to {@link User}s should be saved
|
||||||
|
* using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved
|
||||||
|
* using {@link GroupManager#saveGroup(Group)}.</p>
|
||||||
|
*
|
||||||
|
* <p>Before making changes to a user or group, it may be a good idea to load a fresh copy of
|
||||||
|
* the backing data from the storage if you haven't done so already, to avoid overwriting changes
|
||||||
|
* made already. This can be done via {@link UserManager#loadUser(UUID)} or
|
||||||
|
* {@link GroupManager#loadGroup(String)} respectively.</p>
|
||||||
*
|
*
|
||||||
* @since 2.17
|
* @since 2.17
|
||||||
*/
|
*/
|
||||||
void clearParents();
|
void clearParents();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all parent groups in a specific context
|
* Clears all parent groups in a specific context.
|
||||||
|
*
|
||||||
|
* <p>The effect of this mutate operation will not persist in storage unless changes are
|
||||||
|
* explicitly saved. If changes are not saved, the effect will only be observed until the next
|
||||||
|
* time the holders permission data is (re)loaded. Changes to {@link User}s should be saved
|
||||||
|
* using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved
|
||||||
|
* using {@link GroupManager#saveGroup(Group)}.</p>
|
||||||
|
*
|
||||||
|
* <p>Before making changes to a user or group, it may be a good idea to load a fresh copy of
|
||||||
|
* the backing data from the storage if you haven't done so already, to avoid overwriting changes
|
||||||
|
* made already. This can be done via {@link UserManager#loadUser(UUID)} or
|
||||||
|
* {@link GroupManager#loadGroup(String)} respectively.</p>
|
||||||
*
|
*
|
||||||
* @param contextSet the contexts to filter by
|
* @param contextSet the contexts to filter by
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
void clearParents(@Nonnull ContextSet contextSet);
|
void clearParents(@NonNull ContextSet contextSet);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all meta held by the object
|
* Clears all meta held by the permission holder.
|
||||||
|
*
|
||||||
|
* <p>Meta nodes in this case, are any nodes which have a {@link MetaType}, {@link PrefixType}
|
||||||
|
* or {@link SuffixType} type.</p>
|
||||||
|
*
|
||||||
|
* <p>The effect of this mutate operation will not persist in storage unless changes are
|
||||||
|
* explicitly saved. If changes are not saved, the effect will only be observed until the next
|
||||||
|
* time the holders permission data is (re)loaded. Changes to {@link User}s should be saved
|
||||||
|
* using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved
|
||||||
|
* using {@link GroupManager#saveGroup(Group)}.</p>
|
||||||
|
*
|
||||||
|
* <p>Before making changes to a user or group, it may be a good idea to load a fresh copy of
|
||||||
|
* the backing data from the storage if you haven't done so already, to avoid overwriting changes
|
||||||
|
* made already. This can be done via {@link UserManager#loadUser(UUID)} or
|
||||||
|
* {@link GroupManager#loadGroup(String)} respectively.</p>
|
||||||
*
|
*
|
||||||
* @since 2.17
|
* @since 2.17
|
||||||
*/
|
*/
|
||||||
void clearMeta();
|
void clearMeta();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all meta held by the object in a specific context
|
* Clears all meta held by the permission holder in a specific context.
|
||||||
|
*
|
||||||
|
* <p>Meta nodes in this case, are any nodes which have a {@link MetaType}, {@link PrefixType}
|
||||||
|
* or {@link SuffixType} type.</p>
|
||||||
|
*
|
||||||
|
* <p>The effect of this mutate operation will not persist in storage unless changes are
|
||||||
|
* explicitly saved. If changes are not saved, the effect will only be observed until the next
|
||||||
|
* time the holders permission data is (re)loaded. Changes to {@link User}s should be saved
|
||||||
|
* using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved
|
||||||
|
* using {@link GroupManager#saveGroup(Group)}.</p>
|
||||||
|
*
|
||||||
|
* <p>Before making changes to a user or group, it may be a good idea to load a fresh copy of
|
||||||
|
* the backing data from the storage if you haven't done so already, to avoid overwriting changes
|
||||||
|
* made already. This can be done via {@link UserManager#loadUser(UUID)} or
|
||||||
|
* {@link GroupManager#loadGroup(String)} respectively.</p>
|
||||||
*
|
*
|
||||||
* @param contextSet the contexts to filter by
|
* @param contextSet the contexts to filter by
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
void clearMeta(@Nonnull ContextSet contextSet);
|
void clearMeta(@NonNull ContextSet contextSet);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all transient permissions the holder has.
|
* Clears all transient nodes the permission holder has.
|
||||||
*/
|
*/
|
||||||
void clearTransientNodes();
|
void clearTransientNodes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a permission for the object
|
* Sets a permission for the permission holder.
|
||||||
*
|
*
|
||||||
* @param node The node to be set
|
* @param node The node to be set
|
||||||
* @return the result of the operation
|
* @return the result of the operation
|
||||||
@@ -494,14 +727,13 @@ public interface PermissionHolder {
|
|||||||
* @since 3.1
|
* @since 3.1
|
||||||
* @deprecated now forwards to {@link #setPermission(Node)}.
|
* @deprecated now forwards to {@link #setPermission(Node)}.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
default DataMutateResult setPermissionUnchecked(@Nonnull Node node) {
|
default @NonNull DataMutateResult setPermissionUnchecked(@NonNull Node node) {
|
||||||
return setPermission(node);
|
return setPermission(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a transient permission for the object
|
* Sets a transient permission for the permission holder.
|
||||||
*
|
*
|
||||||
* @param node The node to be set
|
* @param node The node to be set
|
||||||
* @return the result of the operation
|
* @return the result of the operation
|
||||||
@@ -509,39 +741,36 @@ public interface PermissionHolder {
|
|||||||
* @since 3.1
|
* @since 3.1
|
||||||
* @deprecated now forwards to {@link #setTransientPermission(Node)}
|
* @deprecated now forwards to {@link #setTransientPermission(Node)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
default DataMutateResult setTransientPermissionUnchecked(@Nonnull Node node) {
|
default @NonNull DataMutateResult setTransientPermissionUnchecked(@NonNull Node node) {
|
||||||
return setTransientPermission(node);
|
return setTransientPermission(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsets a permission for the object
|
* Unsets a permission for the permission holder.
|
||||||
*
|
*
|
||||||
* @param node The node to be unset
|
* @param node The node to be unset
|
||||||
* @throws NullPointerException if the node is null
|
|
||||||
* @return the result of the operation
|
* @return the result of the operation
|
||||||
|
* @throws NullPointerException if the node is null
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
* @deprecated now forwards to {@link #unsetPermission(Node)}
|
* @deprecated now forwards to {@link #unsetPermission(Node)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
default DataMutateResult unsetPermissionUnchecked(@Nonnull Node node) {
|
default @NonNull DataMutateResult unsetPermissionUnchecked(@NonNull Node node) {
|
||||||
return unsetPermission(node);
|
return unsetPermission(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsets a transient permission for the object
|
* Unsets a transient permission for the permission holder.
|
||||||
*
|
*
|
||||||
* @param node The node to be unset
|
* @param node The node to be unset
|
||||||
* @throws NullPointerException if the node is null
|
|
||||||
* @return the result of the operation
|
* @return the result of the operation
|
||||||
|
* @throws NullPointerException if the node is null
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
* @deprecated now forwards to {@link #unsetTransientPermission(Node)}
|
* @deprecated now forwards to {@link #unsetTransientPermission(Node)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
default DataMutateResult unsetTransientPermissionUnchecked(@Nonnull Node node) {
|
default @NonNull DataMutateResult unsetTransientPermissionUnchecked(@NonNull Node node) {
|
||||||
return unsetTransientPermission(node);
|
return unsetTransientPermission(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,15 +25,21 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
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.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates the result of an operation to save uuid data about a player.
|
* 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
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
public interface PlayerSaveResult {
|
public interface PlayerSaveResult {
|
||||||
@@ -43,8 +49,7 @@ public interface PlayerSaveResult {
|
|||||||
*
|
*
|
||||||
* @return the status
|
* @return the status
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Set<Status> getStatus();
|
||||||
Set<Status> getStatus();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if the result includes a certain status code.
|
* Gets if the result includes a certain status code.
|
||||||
@@ -52,25 +57,32 @@ public interface PlayerSaveResult {
|
|||||||
* @param status the status to check for
|
* @param status the status to check for
|
||||||
* @return if the result includes the status
|
* @return if the result includes the status
|
||||||
*/
|
*/
|
||||||
boolean includes(@Nonnull Status status);
|
default boolean includes(@NonNull Status status) {
|
||||||
|
Objects.requireNonNull(status, "status");
|
||||||
|
return getStatus().contains(status);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the old username involved in the result
|
* 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
|
* @return the old username
|
||||||
* @see Status#USERNAME_UPDATED
|
* @see Status#USERNAME_UPDATED
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable String getOldUsername();
|
||||||
String getOldUsername();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the other uuids involved in the result
|
* 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
|
* @return the other uuids
|
||||||
* @see Status#OTHER_UUIDS_PRESENT_FOR_USERNAME
|
* @see Status#OTHER_UUIDS_PRESENT_FOR_USERNAME
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable Set<UUID> getOtherUuids();
|
||||||
Set<UUID> getOtherUuids();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The various states the result can take
|
* The various states the result can take
|
||||||
|
|||||||
@@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import java.util.Optional;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates the result of {@link User}s promotion along a {@link Track}.
|
* Encapsulates the result of {@link User}s promotion along a {@link Track}.
|
||||||
@@ -41,8 +41,7 @@ public interface PromotionResult extends MutateResult {
|
|||||||
*
|
*
|
||||||
* @return the status
|
* @return the status
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Status getStatus();
|
||||||
Status getStatus();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default boolean wasSuccess() {
|
default boolean wasSuccess() {
|
||||||
@@ -57,8 +56,7 @@ public interface PromotionResult extends MutateResult {
|
|||||||
*
|
*
|
||||||
* @return the group the user was promoted from.
|
* @return the group the user was promoted from.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Optional<String> getGroupFrom();
|
||||||
Optional<String> getGroupFrom();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the name of the group the user was promoted from, if applicable.
|
* Gets the name of the group the user was promoted from, if applicable.
|
||||||
@@ -71,8 +69,7 @@ public interface PromotionResult extends MutateResult {
|
|||||||
*
|
*
|
||||||
* @return the group the user was promoted to.
|
* @return the group the user was promoted to.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Optional<String> getGroupTo();
|
||||||
Optional<String> getGroupTo();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The result status
|
* The result status
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard {@link NodeEqualityPredicate}s.
|
* Standard {@link NodeEqualityPredicate}s.
|
||||||
@@ -72,7 +72,7 @@ public enum StandardNodeEquality implements NodeEqualityPredicate {
|
|||||||
IGNORE_VALUE_OR_IF_TEMPORARY;
|
IGNORE_VALUE_OR_IF_TEMPORARY;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean areEqual(@Nonnull Node o1, @Nonnull Node o2) {
|
public boolean areEqual(@NonNull Node o1, @NonNull Node o2) {
|
||||||
return o1.standardEquals(o2, this);
|
return o1.equals(o2, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,15 +29,15 @@ import me.lucko.luckperms.api.manager.GroupManager;
|
|||||||
import me.lucko.luckperms.api.manager.TrackManager;
|
import me.lucko.luckperms.api.manager.TrackManager;
|
||||||
import me.lucko.luckperms.api.manager.UserManager;
|
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.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A means of loading and saving permission data to/from the backend.
|
* A means of loading and saving permission data to/from the backend.
|
||||||
*
|
*
|
||||||
@@ -50,8 +50,7 @@ public interface Storage {
|
|||||||
*
|
*
|
||||||
* @return the name of the implementation
|
* @return the name of the implementation
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getName();
|
||||||
String getName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets whether the storage instance is allowing logins on the platform.
|
* Gets whether the storage instance is allowing logins on the platform.
|
||||||
@@ -70,9 +69,8 @@ public interface Storage {
|
|||||||
* @throws NullPointerException if entry is null
|
* @throws NullPointerException if entry is null
|
||||||
* @deprecated in favour of {@link ActionLogger#submit(LogEntry)}.
|
* @deprecated in favour of {@link ActionLogger#submit(LogEntry)}.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<Boolean> logAction(@Nonnull LogEntry entry);
|
@NonNull CompletableFuture<Boolean> logAction(@NonNull LogEntry entry);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads and returns the entire log from storage
|
* Loads and returns the entire log from storage
|
||||||
@@ -80,9 +78,8 @@ public interface Storage {
|
|||||||
* @return a log instance, could be null if loading failed
|
* @return a log instance, could be null if loading failed
|
||||||
* @deprecated in favour of {@link ActionLogger#getLog()}
|
* @deprecated in favour of {@link ActionLogger#getLog()}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<Log> getLog();
|
@NonNull CompletableFuture<Log> getLog();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a user's data from the main storage into the plugins local storage.
|
* Loads a user's data from the main storage into the plugins local storage.
|
||||||
@@ -93,9 +90,8 @@ public interface Storage {
|
|||||||
* @throws NullPointerException if uuid is null
|
* @throws NullPointerException if uuid is null
|
||||||
* @deprecated in favour of {@link UserManager#loadUser(UUID, String)}
|
* @deprecated in favour of {@link UserManager#loadUser(UUID, String)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<Boolean> loadUser(@Nonnull UUID uuid, @Nullable String username);
|
@NonNull CompletableFuture<Boolean> loadUser(@NonNull UUID uuid, @Nullable String username);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a user's data from the main storage into the plugins local storage.
|
* Loads a user's data from the main storage into the plugins local storage.
|
||||||
@@ -105,9 +101,8 @@ public interface Storage {
|
|||||||
* @throws NullPointerException if uuid is null
|
* @throws NullPointerException if uuid is null
|
||||||
* @deprecated in favour of {@link UserManager#loadUser(UUID)}
|
* @deprecated in favour of {@link UserManager#loadUser(UUID)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
default CompletableFuture<Boolean> loadUser(@Nonnull UUID uuid) {
|
default @NonNull CompletableFuture<Boolean> loadUser(@NonNull UUID uuid) {
|
||||||
return loadUser(uuid, null);
|
return loadUser(uuid, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,9 +117,8 @@ public interface Storage {
|
|||||||
* @throws IllegalStateException if the user instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the user instance was not obtained from LuckPerms.
|
||||||
* @deprecated in favour of {@link UserManager#saveUser(User)}
|
* @deprecated in favour of {@link UserManager#saveUser(User)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<Boolean> saveUser(@Nonnull User user);
|
@NonNull CompletableFuture<Boolean> saveUser(@NonNull User user);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a set all "unique" user UUIDs.
|
* Gets a set all "unique" user UUIDs.
|
||||||
@@ -134,9 +128,8 @@ public interface Storage {
|
|||||||
* @return a set of uuids, or null if the operation failed.
|
* @return a set of uuids, or null if the operation failed.
|
||||||
* @deprecated in favour of {@link UserManager#getUniqueUsers()}
|
* @deprecated in favour of {@link UserManager#getUniqueUsers()}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<Set<UUID>> getUniqueUsers();
|
@NonNull CompletableFuture<Set<UUID>> getUniqueUsers();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for a list of users with a given permission.
|
* Searches for a list of users with a given permission.
|
||||||
@@ -147,9 +140,8 @@ public interface Storage {
|
|||||||
* @since 2.17
|
* @since 2.17
|
||||||
* @deprecated in favour of {@link UserManager#getWithPermission(String)}
|
* @deprecated in favour of {@link UserManager#getWithPermission(String)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(@Nonnull String permission);
|
@NonNull CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(@NonNull String permission);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and loads a group into the plugins local storage
|
* Creates and loads a group into the plugins local storage
|
||||||
@@ -160,9 +152,8 @@ public interface Storage {
|
|||||||
* @throws IllegalArgumentException if the name is invalid
|
* @throws IllegalArgumentException if the name is invalid
|
||||||
* @deprecated in favour of {@link GroupManager#createAndLoadGroup(String)}
|
* @deprecated in favour of {@link GroupManager#createAndLoadGroup(String)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<Boolean> createAndLoadGroup(@Nonnull String name);
|
@NonNull CompletableFuture<Boolean> createAndLoadGroup(@NonNull String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a group into the plugins local storage.
|
* Loads a group into the plugins local storage.
|
||||||
@@ -173,9 +164,8 @@ public interface Storage {
|
|||||||
* @throws IllegalArgumentException if the name is invalid
|
* @throws IllegalArgumentException if the name is invalid
|
||||||
* @deprecated in favour of {@link GroupManager#loadGroup(String)}
|
* @deprecated in favour of {@link GroupManager#loadGroup(String)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<Boolean> loadGroup(@Nonnull String name);
|
@NonNull CompletableFuture<Boolean> loadGroup(@NonNull String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all groups from the storage into memory
|
* Loads all groups from the storage into memory
|
||||||
@@ -183,9 +173,8 @@ public interface Storage {
|
|||||||
* @return true if the operation completed successfully.
|
* @return true if the operation completed successfully.
|
||||||
* @deprecated in favour of {@link GroupManager#loadAllGroups()}
|
* @deprecated in favour of {@link GroupManager#loadAllGroups()}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<Boolean> loadAllGroups();
|
@NonNull CompletableFuture<Boolean> loadAllGroups();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a group back to storage.
|
* Saves a group back to storage.
|
||||||
@@ -198,9 +187,8 @@ public interface Storage {
|
|||||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||||
* @deprecated in favour of {@link GroupManager#saveGroup(Group)}
|
* @deprecated in favour of {@link GroupManager#saveGroup(Group)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<Boolean> saveGroup(@Nonnull Group group);
|
@NonNull CompletableFuture<Boolean> saveGroup(@NonNull Group group);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permanently deletes a group from storage.
|
* Permanently deletes a group from storage.
|
||||||
@@ -211,9 +199,8 @@ public interface Storage {
|
|||||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||||
* @deprecated in favour of {@link GroupManager#deleteGroup(Group)}
|
* @deprecated in favour of {@link GroupManager#deleteGroup(Group)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<Boolean> deleteGroup(@Nonnull Group group);
|
@NonNull CompletableFuture<Boolean> deleteGroup(@NonNull Group group);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for a list of groups with a given permission.
|
* Searches for a list of groups with a given permission.
|
||||||
@@ -224,9 +211,8 @@ public interface Storage {
|
|||||||
* @since 2.17
|
* @since 2.17
|
||||||
* @deprecated in favour of {@link GroupManager#getWithPermission(String)}
|
* @deprecated in favour of {@link GroupManager#getWithPermission(String)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(@Nonnull String permission);
|
@NonNull CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(@NonNull String permission);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and loads a track into the plugins local storage
|
* Creates and loads a track into the plugins local storage
|
||||||
@@ -237,9 +223,8 @@ public interface Storage {
|
|||||||
* @throws IllegalArgumentException if the name is invalid
|
* @throws IllegalArgumentException if the name is invalid
|
||||||
* @deprecated in favour of {@link TrackManager#createAndLoadTrack(String)}
|
* @deprecated in favour of {@link TrackManager#createAndLoadTrack(String)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<Boolean> createAndLoadTrack(@Nonnull String name);
|
@NonNull CompletableFuture<Boolean> createAndLoadTrack(@NonNull String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a track into the plugins local storage.
|
* Loads a track into the plugins local storage.
|
||||||
@@ -250,9 +235,8 @@ public interface Storage {
|
|||||||
* @throws IllegalArgumentException if the name is invalid
|
* @throws IllegalArgumentException if the name is invalid
|
||||||
* @deprecated in favour of {@link TrackManager#loadTrack(String)}
|
* @deprecated in favour of {@link TrackManager#loadTrack(String)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<Boolean> loadTrack(@Nonnull String name);
|
@NonNull CompletableFuture<Boolean> loadTrack(@NonNull String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all tracks from the storage into memory
|
* Loads all tracks from the storage into memory
|
||||||
@@ -260,9 +244,8 @@ public interface Storage {
|
|||||||
* @return true if the operation completed successfully.
|
* @return true if the operation completed successfully.
|
||||||
* @deprecated in favour of {@link TrackManager#loadAllTracks()}
|
* @deprecated in favour of {@link TrackManager#loadAllTracks()}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<Boolean> loadAllTracks();
|
@NonNull CompletableFuture<Boolean> loadAllTracks();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a track back to storage. You should call this after you make any changes to a track.
|
* Saves a track back to storage. You should call this after you make any changes to a track.
|
||||||
@@ -273,9 +256,8 @@ public interface Storage {
|
|||||||
* @throws IllegalStateException if the track instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the track instance was not obtained from LuckPerms.
|
||||||
* @deprecated in favour of {@link TrackManager#saveTrack(Track)}
|
* @deprecated in favour of {@link TrackManager#saveTrack(Track)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<Boolean> saveTrack(@Nonnull Track track);
|
@NonNull CompletableFuture<Boolean> saveTrack(@NonNull Track track);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permanently deletes a track from storage
|
* Permanently deletes a track from storage
|
||||||
@@ -286,9 +268,8 @@ public interface Storage {
|
|||||||
* @throws IllegalStateException if the track instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the track instance was not obtained from LuckPerms.
|
||||||
* @deprecated in favour of {@link TrackManager#deleteTrack(Track)}
|
* @deprecated in favour of {@link TrackManager#deleteTrack(Track)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
CompletableFuture<Boolean> deleteTrack(@Nonnull Track track);
|
@NonNull CompletableFuture<Boolean> deleteTrack(@NonNull Track track);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves UUID caching data to the global cache
|
* Saves UUID caching data to the global cache
|
||||||
@@ -300,8 +281,7 @@ public interface Storage {
|
|||||||
* @throws IllegalArgumentException if the username is invalid
|
* @throws IllegalArgumentException if the username is invalid
|
||||||
* @deprecated in favour of {@link UserManager#savePlayerData(UUID, String)}
|
* @deprecated in favour of {@link UserManager#savePlayerData(UUID, String)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Boolean> saveUUIDData(@NonNull String username, @NonNull UUID uuid);
|
||||||
CompletableFuture<Boolean> saveUUIDData(@Nonnull String username, @Nonnull UUID uuid);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a UUID from a username
|
* Gets a UUID from a username
|
||||||
@@ -312,8 +292,7 @@ public interface Storage {
|
|||||||
* @throws IllegalArgumentException if the username is invalid
|
* @throws IllegalArgumentException if the username is invalid
|
||||||
* @deprecated in favour of {@link UserManager#lookupUuid(String)}
|
* @deprecated in favour of {@link UserManager#lookupUuid(String)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<UUID> getUUID(@NonNull String username);
|
||||||
CompletableFuture<UUID> getUUID(@Nonnull String username);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a username from a UUID
|
* Gets a username from a UUID
|
||||||
@@ -324,9 +303,7 @@ public interface Storage {
|
|||||||
* @since 2.17
|
* @since 2.17
|
||||||
* @deprecated in favour of {@link UserManager#lookupUsername(UUID)}
|
* @deprecated in favour of {@link UserManager#lookupUsername(UUID)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Deprecated CompletableFuture<String> getName(@NonNull UUID uuid);
|
||||||
@Deprecated
|
|
||||||
CompletableFuture<String> getName(@Nonnull UUID uuid);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an executor which will run all passed runnables on the
|
* Returns an executor which will run all passed runnables on the
|
||||||
@@ -338,9 +315,7 @@ public interface Storage {
|
|||||||
* @return an executor instance
|
* @return an executor instance
|
||||||
* @deprecated as plugins should create their own executors
|
* @deprecated as plugins should create their own executors
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Deprecated Executor getSyncExecutor();
|
||||||
@Deprecated
|
|
||||||
Executor getSyncExecutor();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an executor which will run all passed runnables asynchronously
|
* Returns an executor which will run all passed runnables asynchronously
|
||||||
@@ -352,8 +327,6 @@ public interface Storage {
|
|||||||
* @return an executor instance
|
* @return an executor instance
|
||||||
* @deprecated as plugins should create their own executors
|
* @deprecated as plugins should create their own executors
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Deprecated Executor getAsyncExecutor();
|
||||||
@Deprecated
|
|
||||||
Executor getAsyncExecutor();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+19
-17
@@ -23,31 +23,33 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.verbose;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the origin of a permission check
|
* Extension of {@link DataMutateResult} for temporary set operations.
|
||||||
|
*
|
||||||
|
* @since 4.3
|
||||||
*/
|
*/
|
||||||
public enum CheckOrigin {
|
public interface TemporaryDataMutateResult {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates the check was caused by a 'hasPermission' check on the platform
|
* Gets the underlying result.
|
||||||
|
*
|
||||||
|
* @return the result
|
||||||
*/
|
*/
|
||||||
PLATFORM_PERMISSION_CHECK,
|
@NonNull DataMutateResult getResult();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates the check was caused by a 'hasPermissionSet' type check on the platform
|
* 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
|
||||||
*/
|
*/
|
||||||
PLATFORM_LOOKUP_CHECK,
|
@NonNull Node getMergedNode();
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates the check was caused by an API call
|
|
||||||
*/
|
|
||||||
API,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates the check was caused by a LuckPerms internal
|
|
||||||
*/
|
|
||||||
INTERNAL
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+19
-41
@@ -23,58 +23,36 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.web;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a pastebin service
|
* 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 interface Pastebin {
|
public enum TemporaryMergeBehaviour {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Posts the given json to the pastebin
|
* Expiry durations will be added to the existing expiry time of a permission.
|
||||||
*
|
|
||||||
* @param element the json element to post
|
|
||||||
* @param compress whether to compress and post the data using gzip
|
|
||||||
* @return a paste
|
|
||||||
*/
|
*/
|
||||||
Paste postJson(JsonElement element, boolean compress);
|
ADD_NEW_DURATION_TO_EXISTING,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Posts "plain" content to the pastebin
|
* Expiry durations will be replaced if the new duration is longer than the current one.
|
||||||
*
|
|
||||||
* @param content the content
|
|
||||||
* @return a paste
|
|
||||||
*/
|
*/
|
||||||
Paste postPlain(String content);
|
REPLACE_EXISTING_IF_DURATION_LONGER,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the raw url of a paste's data from an id
|
* The operation will fail if an existing temporary node is present.
|
||||||
*
|
|
||||||
* @param id the id
|
|
||||||
* @return a url
|
|
||||||
*/
|
*/
|
||||||
String getRawUrl(String id);
|
FAIL_WITH_ALREADY_HAS
|
||||||
|
|
||||||
/**
|
|
||||||
* Encapsulates the properties of a specific "paste" entry
|
|
||||||
*/
|
|
||||||
interface Paste {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the url of the paste
|
|
||||||
*
|
|
||||||
* @return the url
|
|
||||||
*/
|
|
||||||
String url();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the unique id of the paste
|
|
||||||
*
|
|
||||||
* @return the id
|
|
||||||
*/
|
|
||||||
String id();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,10 +27,10 @@ package me.lucko.luckperms.api;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
|
|
||||||
import java.util.List;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An ordered chain of {@link Group}s.
|
* An ordered chain of {@link Group}s.
|
||||||
@@ -42,8 +42,7 @@ public interface Track {
|
|||||||
*
|
*
|
||||||
* @return the name of this track
|
* @return the name of this track
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getName();
|
||||||
String getName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a list of the groups on this track
|
* Gets a list of the groups on this track
|
||||||
@@ -54,8 +53,7 @@ public interface Track {
|
|||||||
*
|
*
|
||||||
* @return an ordered {@link List} of the groups on this track
|
* @return an ordered {@link List} of the groups on this track
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull List<String> getGroups();
|
||||||
List<String> getGroups();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of groups on this track
|
* Gets the number of groups on this track
|
||||||
@@ -74,8 +72,7 @@ public interface Track {
|
|||||||
* @throws NullPointerException if the group is null
|
* @throws NullPointerException if the group is null
|
||||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable String getNext(@NonNull Group current);
|
||||||
String getNext(@Nonnull Group current);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the previous group on the track, before the one provided
|
* Gets the previous group on the track, before the one provided
|
||||||
@@ -87,41 +84,37 @@ public interface Track {
|
|||||||
* @throws NullPointerException if the group is null
|
* @throws NullPointerException if the group is null
|
||||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable String getPrevious(@NonNull Group current);
|
||||||
String getPrevious(@Nonnull Group current);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Promotes the given user along this track.
|
* Promotes the given user along this track.
|
||||||
*
|
*
|
||||||
* @param user the user to promote
|
* @param user the user to promote
|
||||||
* @param contextSet the contexts to promote the user in
|
* @param contextSet the contexts to promote the user in
|
||||||
* @return the result of the action
|
* @return the result of the action
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull PromotionResult promote(@NonNull User user, @NonNull ContextSet contextSet);
|
||||||
PromotionResult promote(@Nonnull User user, @Nonnull ContextSet contextSet);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Demotes the given user along this track.
|
* Demotes the given user along this track.
|
||||||
*
|
*
|
||||||
* @param user the user to demote
|
* @param user the user to demote
|
||||||
* @param contextSet the contexts to demote the user in
|
* @param contextSet the contexts to demote the user in
|
||||||
* @return the result of the action
|
* @return the result of the action
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull DemotionResult demote(@NonNull User user, @NonNull ContextSet contextSet);
|
||||||
DemotionResult demote(@Nonnull User user, @Nonnull ContextSet contextSet);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends a group to the end of this track
|
* Appends a group to the end of this track
|
||||||
*
|
*
|
||||||
* @param group the group to append
|
* @param group the group to append
|
||||||
* @return the result of the operation
|
* @return the result of the operation
|
||||||
* @throws NullPointerException if the group is null
|
* @throws NullPointerException if the group is null
|
||||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull DataMutateResult appendGroup(@NonNull Group group);
|
||||||
DataMutateResult appendGroup(@Nonnull Group group);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a group at a certain position on this track
|
* Inserts a group at a certain position on this track
|
||||||
@@ -133,8 +126,7 @@ public interface Track {
|
|||||||
* @throws NullPointerException if the group is null
|
* @throws NullPointerException if the group is null
|
||||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull DataMutateResult insertGroup(@NonNull Group group, int position) throws IndexOutOfBoundsException;
|
||||||
DataMutateResult insertGroup(@Nonnull Group group, int position) throws IndexOutOfBoundsException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a group from this track
|
* Removes a group from this track
|
||||||
@@ -144,8 +136,7 @@ public interface Track {
|
|||||||
* @throws NullPointerException if the group is null
|
* @throws NullPointerException if the group is null
|
||||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull DataMutateResult removeGroup(@NonNull Group group);
|
||||||
DataMutateResult removeGroup(@Nonnull Group group);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a group from this track
|
* Removes a group from this track
|
||||||
@@ -154,8 +145,7 @@ public interface Track {
|
|||||||
* @return the result of the operation
|
* @return the result of the operation
|
||||||
* @throws NullPointerException if the group is null
|
* @throws NullPointerException if the group is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull DataMutateResult removeGroup(@NonNull String group);
|
||||||
DataMutateResult removeGroup(@Nonnull String group);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a group features on this track
|
* Checks if a group features on this track
|
||||||
@@ -165,7 +155,7 @@ public interface Track {
|
|||||||
* @throws NullPointerException if the group is null
|
* @throws NullPointerException if the group is null
|
||||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||||
*/
|
*/
|
||||||
boolean containsGroup(@Nonnull Group group);
|
boolean containsGroup(@NonNull Group group);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a group features on this track
|
* Checks if a group features on this track
|
||||||
@@ -174,7 +164,7 @@ public interface Track {
|
|||||||
* @return true if the group is on this track
|
* @return true if the group is on this track
|
||||||
* @throws NullPointerException if the group is null
|
* @throws NullPointerException if the group is null
|
||||||
*/
|
*/
|
||||||
boolean containsGroup(@Nonnull String group);
|
boolean containsGroup(@NonNull String group);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear all of the groups from this track
|
* Clear all of the groups from this track
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents three different states of a setting.
|
* Represents three different states of a setting.
|
||||||
@@ -61,8 +61,7 @@ public enum Tristate {
|
|||||||
* @param val the boolean value
|
* @param val the boolean value
|
||||||
* @return {@link #TRUE} or {@link #FALSE}, if the value is <code>true</code> or <code>false</code>, respectively.
|
* @return {@link #TRUE} or {@link #FALSE}, if the value is <code>true</code> or <code>false</code>, respectively.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull Tristate fromBoolean(boolean val) {
|
||||||
public static Tristate fromBoolean(boolean val) {
|
|
||||||
return val ? TRUE : FALSE;
|
return val ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,8 +76,7 @@ public enum Tristate {
|
|||||||
* is <code>null</code>, <code>true</code> or <code>false</code>, respectively.
|
* is <code>null</code>, <code>true</code> or <code>false</code>, respectively.
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull Tristate fromNullableBoolean(Boolean val) {
|
||||||
public static Tristate fromNullableBoolean(Boolean val) {
|
|
||||||
return val == null ? UNDEFINED : val ? TRUE : FALSE;
|
return val == null ? UNDEFINED : val ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ package me.lucko.luckperms.api;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.caching.UserData;
|
import me.lucko.luckperms.api.caching.UserData;
|
||||||
|
|
||||||
import java.util.UUID;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.UUID;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A player which holds permission data.
|
* A player which holds permission data.
|
||||||
@@ -42,40 +42,40 @@ public interface User extends PermissionHolder {
|
|||||||
*
|
*
|
||||||
* @return the users Mojang assigned unique id
|
* @return the users Mojang assigned unique id
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull UUID getUuid();
|
||||||
UUID getUuid();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the users username
|
* Gets the users username
|
||||||
*
|
*
|
||||||
* <p>Returns null if no username is associated with this user.</p>
|
* <p>Returns null if no username is known for the user.</p>
|
||||||
*
|
*
|
||||||
* @return the users username
|
* @return the users username
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable String getName();
|
||||||
String getName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the users current 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
|
* <p>The result of this method depends on which method is configured for primary group
|
||||||
* be the same as any value set through {@link #setPrimaryGroup(String)}.</p>
|
* calculation. It may not be the same as any value set through
|
||||||
|
* {@link #setPrimaryGroup(String)}.</p>
|
||||||
*
|
*
|
||||||
* @return the users primary group
|
* @return the users primary group
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getPrimaryGroup();
|
||||||
String getPrimaryGroup();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a users primary group. This will only take effect if platform is using stored primary groups.
|
* 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
|
* @param group the new primary group
|
||||||
* @return if the change was applied successfully
|
* @return if the change was applied successfully
|
||||||
* @throws IllegalStateException if the user is not a member of that group
|
* @throws IllegalStateException if the user is not a member of that group
|
||||||
* @throws NullPointerException if the group is null
|
* @throws NullPointerException if the group is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull DataMutateResult setPrimaryGroup(@NonNull String group);
|
||||||
DataMutateResult setPrimaryGroup(@Nonnull String group);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the user's {@link UserData} cache.
|
* Gets the user's {@link UserData} cache.
|
||||||
@@ -83,17 +83,15 @@ public interface User extends PermissionHolder {
|
|||||||
* @return the users cached data.
|
* @return the users cached data.
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
UserData getCachedData();
|
@NonNull UserData getCachedData();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh and re-assign the users permissions.
|
* Refresh and re-assign the users permissions.
|
||||||
*
|
*
|
||||||
* <p>This request is not buffered, and the refresh call will be ran directly. This should be called on an
|
* @deprecated Calling this method is no longer necessary. Permissions data is now refreshed on
|
||||||
* asynchronous thread.</p>
|
* demand, as changes are made. Consider use of {@link #refreshCachedData()}
|
||||||
*
|
* instead. This method is now implemented as a no-op.
|
||||||
* @deprecated in favour of {@link #refreshCachedData()}.
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
void refreshPermissions();
|
void refreshPermissions();
|
||||||
@@ -101,11 +99,8 @@ public interface User extends PermissionHolder {
|
|||||||
/**
|
/**
|
||||||
* Pre-calculates some values in the user's data cache.
|
* Pre-calculates some values in the user's data cache.
|
||||||
*
|
*
|
||||||
* <p>Is it <b>not</b> necessary to call this method before
|
|
||||||
* using {@link #getCachedData()}.</p>
|
|
||||||
*
|
|
||||||
* @since 2.17
|
* @since 2.17
|
||||||
* @deprecated because use of this method is no longer necessary.
|
* @deprecated Use of this method is no longer necessary. It is implemented as a no-op.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
void setupDataCache();
|
void setupDataCache();
|
||||||
|
|||||||
@@ -25,16 +25,16 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import java.util.UUID;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A UUID cache for online users, between external Mojang UUIDs, and internal
|
* A UUID cache for online users, between external Mojang UUIDs, and internal
|
||||||
* LuckPerms UUIDs.
|
* LuckPerms UUIDs.
|
||||||
*
|
*
|
||||||
* @deprecated this feature is now handled internally - and the API returns a
|
* @deprecated this feature is now handled internally - and the API returns a
|
||||||
* No-op implementation of this class.
|
* No-op implementation of this class.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface UuidCache {
|
public interface UuidCache {
|
||||||
@@ -50,9 +50,8 @@ public interface UuidCache {
|
|||||||
* <code>ProxiedPlayer#getUniqueId</code>
|
* <code>ProxiedPlayer#getUniqueId</code>
|
||||||
* @return the corresponding internal UUID
|
* @return the corresponding internal UUID
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
UUID getUUID(@Nonnull UUID mojangUuid);
|
@NonNull UUID getUUID(@NonNull UUID mojangUuid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a users "external", server assigned unique id, from the internal
|
* Gets a users "external", server assigned unique id, from the internal
|
||||||
@@ -62,8 +61,7 @@ public interface UuidCache {
|
|||||||
* <code>User#getUuid</code>
|
* <code>User#getUuid</code>
|
||||||
* @return the corresponding external UUID
|
* @return the corresponding external UUID
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
UUID getExternalUUID(@Nonnull UUID internalUuid);
|
@NonNull UUID getExternalUUID(@NonNull UUID internalUuid);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,11 +28,12 @@ package me.lucko.luckperms.api.caching;
|
|||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.PermissionHolder;
|
import me.lucko.luckperms.api.PermissionHolder;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds cached permission and meta lookup data for a {@link PermissionHolder}.
|
* Holds cached permission and meta lookup data for a {@link PermissionHolder}.
|
||||||
*
|
*
|
||||||
@@ -56,8 +57,7 @@ public interface CachedData {
|
|||||||
* @return a permission data instance
|
* @return a permission data instance
|
||||||
* @throws NullPointerException if contexts is null
|
* @throws NullPointerException if contexts is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull PermissionData getPermissionData(@NonNull Contexts contexts);
|
||||||
PermissionData getPermissionData(@Nonnull Contexts contexts);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets MetaData from the cache, given a specified context.
|
* Gets MetaData from the cache, given a specified context.
|
||||||
@@ -67,8 +67,7 @@ public interface CachedData {
|
|||||||
* @throws NullPointerException if contexts is null
|
* @throws NullPointerException if contexts is null
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull MetaData getMetaData(@NonNull MetaContexts contexts);
|
||||||
MetaData getMetaData(@Nonnull MetaContexts contexts);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets MetaData from the cache, given a specified context.
|
* Gets MetaData from the cache, given a specified context.
|
||||||
@@ -77,8 +76,7 @@ public interface CachedData {
|
|||||||
* @return a meta data instance
|
* @return a meta data instance
|
||||||
* @throws NullPointerException if contexts is null
|
* @throws NullPointerException if contexts is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull MetaData getMetaData(@NonNull Contexts contexts);
|
||||||
MetaData getMetaData(@Nonnull Contexts contexts);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates permission data, bypassing the cache.
|
* Calculates permission data, bypassing the cache.
|
||||||
@@ -95,8 +93,7 @@ public interface CachedData {
|
|||||||
* @return a permission data instance
|
* @return a permission data instance
|
||||||
* @throws NullPointerException if contexts is null
|
* @throws NullPointerException if contexts is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull PermissionData calculatePermissions(@NonNull Contexts contexts);
|
||||||
PermissionData calculatePermissions(@Nonnull Contexts contexts);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates meta data, bypassing the cache.
|
* Calculates meta data, bypassing the cache.
|
||||||
@@ -114,8 +111,7 @@ public interface CachedData {
|
|||||||
* @throws NullPointerException if contexts is null
|
* @throws NullPointerException if contexts is null
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull MetaData calculateMeta(@NonNull MetaContexts contexts);
|
||||||
MetaData calculateMeta(@Nonnull MetaContexts contexts);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates meta data, bypassing the cache.
|
* Calculates meta data, bypassing the cache.
|
||||||
@@ -132,8 +128,7 @@ public interface CachedData {
|
|||||||
* @return a meta data instance
|
* @return a meta data instance
|
||||||
* @throws NullPointerException if contexts is null
|
* @throws NullPointerException if contexts is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull MetaData calculateMeta(@NonNull Contexts contexts);
|
||||||
MetaData calculateMeta(@Nonnull Contexts contexts);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (Re)calculates permission data for a given context.
|
* (Re)calculates permission data for a given context.
|
||||||
@@ -151,7 +146,7 @@ public interface CachedData {
|
|||||||
* @param contexts the contexts to recalculate in.
|
* @param contexts the contexts to recalculate in.
|
||||||
* @throws NullPointerException if contexts is null
|
* @throws NullPointerException if contexts is null
|
||||||
*/
|
*/
|
||||||
void recalculatePermissions(@Nonnull Contexts contexts);
|
void recalculatePermissions(@NonNull Contexts contexts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (Re)calculates meta data for a given context.
|
* (Re)calculates meta data for a given context.
|
||||||
@@ -170,7 +165,7 @@ public interface CachedData {
|
|||||||
* @throws NullPointerException if contexts is null
|
* @throws NullPointerException if contexts is null
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
void recalculateMeta(@Nonnull MetaContexts contexts);
|
void recalculateMeta(@NonNull MetaContexts contexts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (Re)calculates meta data for a given context.
|
* (Re)calculates meta data for a given context.
|
||||||
@@ -188,7 +183,7 @@ public interface CachedData {
|
|||||||
* @param contexts the contexts to recalculate in.
|
* @param contexts the contexts to recalculate in.
|
||||||
* @throws NullPointerException if contexts is null
|
* @throws NullPointerException if contexts is null
|
||||||
*/
|
*/
|
||||||
void recalculateMeta(@Nonnull Contexts contexts);
|
void recalculateMeta(@NonNull Contexts contexts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (Re)loads permission data for a given context.
|
* (Re)loads permission data for a given context.
|
||||||
@@ -211,12 +206,11 @@ public interface CachedData {
|
|||||||
* until the recalculation has been performed.</p>
|
* until the recalculation has been performed.</p>
|
||||||
*
|
*
|
||||||
* @param contexts the contexts to reload in.
|
* @param contexts the contexts to reload in.
|
||||||
* @throws NullPointerException if contexts is null
|
|
||||||
* @return a future
|
* @return a future
|
||||||
|
* @throws NullPointerException if contexts is null
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<? extends PermissionData> reloadPermissions(@NonNull Contexts contexts);
|
||||||
CompletableFuture<? extends PermissionData> reloadPermissions(@Nonnull Contexts contexts);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (Re)loads meta data for a given context.
|
* (Re)loads meta data for a given context.
|
||||||
@@ -239,12 +233,11 @@ public interface CachedData {
|
|||||||
* until the recalculation has been performed.</p>
|
* until the recalculation has been performed.</p>
|
||||||
*
|
*
|
||||||
* @param contexts the contexts to reload in.
|
* @param contexts the contexts to reload in.
|
||||||
* @throws NullPointerException if contexts is null
|
|
||||||
* @return a future
|
* @return a future
|
||||||
|
* @throws NullPointerException if contexts is null
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<? extends MetaData> reloadMeta(@NonNull MetaContexts contexts);
|
||||||
CompletableFuture<? extends MetaData> reloadMeta(@Nonnull MetaContexts contexts);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (Re)loads meta data for a given context.
|
* (Re)loads meta data for a given context.
|
||||||
@@ -267,12 +260,11 @@ public interface CachedData {
|
|||||||
* until the recalculation has been performed.</p>
|
* until the recalculation has been performed.</p>
|
||||||
*
|
*
|
||||||
* @param contexts the contexts to reload in.
|
* @param contexts the contexts to reload in.
|
||||||
* @throws NullPointerException if contexts is null
|
|
||||||
* @return a future
|
* @return a future
|
||||||
|
* @throws NullPointerException if contexts is null
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<? extends MetaData> reloadMeta(@NonNull Contexts contexts);
|
||||||
CompletableFuture<? extends MetaData> reloadMeta(@Nonnull Contexts contexts);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recalculates permission data for all known contexts.
|
* Recalculates permission data for all known contexts.
|
||||||
@@ -317,8 +309,7 @@ public interface CachedData {
|
|||||||
* @return a future
|
* @return a future
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Void> reloadPermissions();
|
||||||
CompletableFuture<Void> reloadPermissions();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reloads meta data for all known contexts.
|
* Reloads meta data for all known contexts.
|
||||||
@@ -341,8 +332,7 @@ public interface CachedData {
|
|||||||
* @return a future
|
* @return a future
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Void> reloadMeta();
|
||||||
CompletableFuture<Void> reloadMeta();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pre-calculates and caches {@link PermissionData} and {@link MetaData}
|
* Pre-calculates and caches {@link PermissionData} and {@link MetaData}
|
||||||
@@ -356,7 +346,7 @@ public interface CachedData {
|
|||||||
* @param contexts a set of contexts
|
* @param contexts a set of contexts
|
||||||
* @throws NullPointerException if contexts is null
|
* @throws NullPointerException if contexts is null
|
||||||
*/
|
*/
|
||||||
default void preCalculate(@Nonnull Set<Contexts> contexts) {
|
default void preCalculate(@NonNull Set<Contexts> contexts) {
|
||||||
contexts.forEach(this::preCalculate);
|
contexts.forEach(this::preCalculate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +362,14 @@ public interface CachedData {
|
|||||||
* @param contexts the contexts to pre-calculate for
|
* @param contexts the contexts to pre-calculate for
|
||||||
* @throws NullPointerException if contexts is null
|
* @throws NullPointerException if contexts is null
|
||||||
*/
|
*/
|
||||||
void preCalculate(@Nonnull Contexts contexts);
|
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
|
* Invalidates any cached {@link PermissionData} instances mapped to the given
|
||||||
@@ -381,7 +378,7 @@ public interface CachedData {
|
|||||||
* @param contexts the contexts to invalidate for
|
* @param contexts the contexts to invalidate for
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
void invalidatePermissions(@Nonnull Contexts contexts);
|
void invalidatePermissions(@NonNull Contexts contexts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidates any cached {@link MetaData} instances mapped to the given
|
* Invalidates any cached {@link MetaData} instances mapped to the given
|
||||||
@@ -390,7 +387,7 @@ public interface CachedData {
|
|||||||
* @param contexts the contexts to invalidate for
|
* @param contexts the contexts to invalidate for
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
void invalidateMeta(@Nonnull MetaContexts contexts);
|
void invalidateMeta(@NonNull MetaContexts contexts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidates any cached {@link MetaData} instances mapped to the given
|
* Invalidates any cached {@link MetaData} instances mapped to the given
|
||||||
@@ -399,7 +396,7 @@ public interface CachedData {
|
|||||||
* @param contexts the contexts to invalidate for
|
* @param contexts the contexts to invalidate for
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
void invalidateMeta(@Nonnull Contexts contexts);
|
void invalidateMeta(@NonNull Contexts contexts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidates all cached {@link PermissionData} instances.
|
* Invalidates all cached {@link PermissionData} instances.
|
||||||
@@ -415,6 +412,14 @@ public interface CachedData {
|
|||||||
*/
|
*/
|
||||||
void invalidateMeta();
|
void invalidateMeta();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidates all cached {@link PermissionData} and {@link MetaData}
|
||||||
|
* instances.
|
||||||
|
*
|
||||||
|
* @since 4.5
|
||||||
|
*/
|
||||||
|
void invalidate();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidates all of the underlying Permission calculators.
|
* Invalidates all of the underlying Permission calculators.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ package me.lucko.luckperms.api.caching;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds cached lookup data in a specific set of contexts.
|
* Holds cached lookup data in a specific set of contexts.
|
||||||
@@ -41,7 +41,6 @@ public interface CachedDataContainer {
|
|||||||
*
|
*
|
||||||
* @return the contexts this container is caching
|
* @return the contexts this container is caching
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Contexts getContexts();
|
||||||
Contexts getContexts();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,10 +28,9 @@ package me.lucko.luckperms.api.caching;
|
|||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
|
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
|
||||||
|
|
||||||
import java.util.Objects;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.Objects;
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates the options and settings for a meta lookup.
|
* Encapsulates the options and settings for a meta lookup.
|
||||||
@@ -41,18 +40,17 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
*
|
*
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
@Immutable
|
|
||||||
public final class MetaContexts {
|
public final class MetaContexts {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new meta contexts instance
|
* Creates a new meta contexts instance
|
||||||
*
|
*
|
||||||
* @param contexts the standard contexts for the query
|
* @param contexts the standard contexts for the query
|
||||||
* @param prefixStackDefinition the prefix stack definition to be used
|
* @param prefixStackDefinition the prefix stack definition to be used
|
||||||
* @param suffixStackDefinition the suffix stack definition to be used
|
* @param suffixStackDefinition the suffix stack definition to be used
|
||||||
* @return the new instance
|
* @return the new instance
|
||||||
*/
|
*/
|
||||||
public static MetaContexts of(@Nonnull Contexts contexts, @Nonnull MetaStackDefinition prefixStackDefinition, @Nonnull MetaStackDefinition suffixStackDefinition) {
|
public static MetaContexts of(@NonNull Contexts contexts, @NonNull MetaStackDefinition prefixStackDefinition, @NonNull MetaStackDefinition suffixStackDefinition) {
|
||||||
return new MetaContexts(contexts, prefixStackDefinition, suffixStackDefinition);
|
return new MetaContexts(contexts, prefixStackDefinition, suffixStackDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,35 +64,31 @@ public final class MetaContexts {
|
|||||||
/**
|
/**
|
||||||
* Creates a new meta contexts instance
|
* Creates a new meta contexts instance
|
||||||
*
|
*
|
||||||
* @param contexts the standard contexts for the query
|
* @param contexts the standard contexts for the query
|
||||||
* @param prefixStackDefinition the prefix stack definition to be used
|
* @param prefixStackDefinition the prefix stack definition to be used
|
||||||
* @param suffixStackDefinition the suffix 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) {
|
public MetaContexts(@NonNull Contexts contexts, @NonNull MetaStackDefinition prefixStackDefinition, @NonNull MetaStackDefinition suffixStackDefinition) {
|
||||||
this.contexts = Objects.requireNonNull(contexts, "contexts");
|
this.contexts = Objects.requireNonNull(contexts, "contexts");
|
||||||
this.prefixStackDefinition = Objects.requireNonNull(prefixStackDefinition, "prefixStackDefinition");
|
this.prefixStackDefinition = Objects.requireNonNull(prefixStackDefinition, "prefixStackDefinition");
|
||||||
this.suffixStackDefinition = Objects.requireNonNull(suffixStackDefinition, "suffixStackDefinition");
|
this.suffixStackDefinition = Objects.requireNonNull(suffixStackDefinition, "suffixStackDefinition");
|
||||||
this.hashCode = calculateHashCode();
|
this.hashCode = calculateHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
public @NonNull Contexts getContexts() {
|
||||||
public Contexts getContexts() {
|
|
||||||
return this.contexts;
|
return this.contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
public @NonNull MetaStackDefinition getPrefixStackDefinition() {
|
||||||
public MetaStackDefinition getPrefixStackDefinition() {
|
|
||||||
return this.prefixStackDefinition;
|
return this.prefixStackDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
public @NonNull MetaStackDefinition getSuffixStackDefinition() {
|
||||||
public MetaStackDefinition getSuffixStackDefinition() {
|
|
||||||
return this.suffixStackDefinition;
|
return this.suffixStackDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
public @NonNull String toString() {
|
||||||
public String toString() {
|
|
||||||
return "MetaContexts(" +
|
return "MetaContexts(" +
|
||||||
"contexts=" + this.getContexts() + ", " +
|
"contexts=" + this.getContexts() + ", " +
|
||||||
"prefixStackDefinition=" + this.getPrefixStackDefinition() + ", " +
|
"prefixStackDefinition=" + this.getPrefixStackDefinition() + ", " +
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ import com.google.common.collect.ListMultimap;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
|
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.Map;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds cached meta lookup data for a specific set of contexts.
|
* Holds cached meta lookup data for a specific set of contexts.
|
||||||
*
|
*
|
||||||
@@ -47,8 +47,7 @@ public interface MetaData extends CachedDataContainer {
|
|||||||
*
|
*
|
||||||
* @return the contexts this container is caching
|
* @return the contexts this container is caching
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull MetaContexts getMetaContexts();
|
||||||
MetaContexts getMetaContexts();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an immutable copy of the meta this user has.
|
* Gets an immutable copy of the meta this user has.
|
||||||
@@ -62,8 +61,7 @@ public interface MetaData extends CachedDataContainer {
|
|||||||
* @return an immutable multimap of meta
|
* @return an immutable multimap of meta
|
||||||
* @since 3.3
|
* @since 3.3
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull ListMultimap<String, String> getMetaMultimap();
|
||||||
ListMultimap<String, String> getMetaMultimap();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an immutable copy of the meta this user has.
|
* Gets an immutable copy of the meta this user has.
|
||||||
@@ -73,8 +71,7 @@ public interface MetaData extends CachedDataContainer {
|
|||||||
*
|
*
|
||||||
* @return an immutable map of meta
|
* @return an immutable map of meta
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Map<String, String> getMeta();
|
||||||
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
|
* Gets an immutable sorted map of all of the prefixes the user has, whereby the first value is the highest priority
|
||||||
@@ -82,8 +79,7 @@ public interface MetaData extends CachedDataContainer {
|
|||||||
*
|
*
|
||||||
* @return a sorted map of prefixes
|
* @return a sorted map of prefixes
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull SortedMap<Integer, String> getPrefixes();
|
||||||
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
|
* Gets an immutable sorted map of all of the suffixes the user has, whereby the first value is the highest priority
|
||||||
@@ -91,24 +87,21 @@ public interface MetaData extends CachedDataContainer {
|
|||||||
*
|
*
|
||||||
* @return a sorted map of suffixes
|
* @return a sorted map of suffixes
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull SortedMap<Integer, String> getSuffixes();
|
||||||
SortedMap<Integer, String> getSuffixes();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the user's highest priority prefix, or null if the user has no prefixes
|
* Gets the user's highest priority prefix, or null if the user has no prefixes
|
||||||
*
|
*
|
||||||
* @return a prefix string, or null
|
* @return a prefix string, or null
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable String getPrefix();
|
||||||
String getPrefix();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the user's highest priority suffix, or null if the user has no suffixes
|
* Gets the user's highest priority suffix, or null if the user has no suffixes
|
||||||
*
|
*
|
||||||
* @return a suffix string, or null
|
* @return a suffix string, or null
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable String getSuffix();
|
||||||
String getSuffix();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the definition used for the prefix stack
|
* Gets the definition used for the prefix stack
|
||||||
@@ -116,8 +109,7 @@ public interface MetaData extends CachedDataContainer {
|
|||||||
* @return the definition used for the prefix stack
|
* @return the definition used for the prefix stack
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull MetaStackDefinition getPrefixStackDefinition();
|
||||||
MetaStackDefinition getPrefixStackDefinition();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the definition used for the suffix stack
|
* Gets the definition used for the suffix stack
|
||||||
@@ -125,7 +117,6 @@ public interface MetaData extends CachedDataContainer {
|
|||||||
* @return the definition used for the suffix stack
|
* @return the definition used for the suffix stack
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull MetaStackDefinition getSuffixStackDefinition();
|
||||||
MetaStackDefinition getSuffixStackDefinition();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,9 +27,9 @@ package me.lucko.luckperms.api.caching;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
|
|
||||||
import java.util.Map;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.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.
|
||||||
@@ -45,8 +45,7 @@ public interface PermissionData extends CachedDataContainer {
|
|||||||
* @return a tristate result
|
* @return a tristate result
|
||||||
* @throws NullPointerException if permission is null
|
* @throws NullPointerException if permission is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Tristate getPermissionValue(@NonNull String permission);
|
||||||
Tristate getPermissionValue(@Nonnull String permission);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidates the underlying permission calculator cache.
|
* Invalidates the underlying permission calculator cache.
|
||||||
@@ -60,7 +59,6 @@ public interface PermissionData extends CachedDataContainer {
|
|||||||
*
|
*
|
||||||
* @return an immutable set of permissions
|
* @return an immutable set of permissions
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Map<String, Boolean> getImmutableBacking();
|
||||||
Map<String, Boolean> getImmutableBacking();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,15 +26,14 @@
|
|||||||
package me.lucko.luckperms.api.context;
|
package me.lucko.luckperms.api.context;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
import com.google.common.collect.SetMultimap;
|
import com.google.common.collect.SetMultimap;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
abstract class AbstractContextSet implements ContextSet {
|
abstract class AbstractContextSet implements ContextSet {
|
||||||
|
|
||||||
protected abstract SetMultimap<String, String> backing();
|
protected abstract SetMultimap<String, String> backing();
|
||||||
@@ -42,19 +41,18 @@ abstract class AbstractContextSet implements ContextSet {
|
|||||||
protected abstract void copyTo(SetMultimap<String, String> other);
|
protected abstract void copyTo(SetMultimap<String, String> other);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsKey(@Nonnull String key) {
|
public boolean containsKey(@NonNull String key) {
|
||||||
return backing().containsKey(sanitizeKey(key));
|
return backing().containsKey(sanitizeKey(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getValues(@Nonnull String key) {
|
public @NonNull Set<String> getValues(@NonNull String key) {
|
||||||
Collection<String> values = backing().asMap().get(sanitizeKey(key));
|
Collection<String> values = backing().asMap().get(sanitizeKey(key));
|
||||||
return values != null ? ImmutableSet.copyOf(values) : ImmutableSet.of();
|
return values != null ? ImmutableSet.copyOf(values) : ImmutableSet.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean has(@Nonnull String key, @Nonnull String value) {
|
public boolean has(@NonNull String key, @NonNull String value) {
|
||||||
return backing().containsEntry(sanitizeKey(key), sanitizeValue(value));
|
return backing().containsEntry(sanitizeKey(key), sanitizeValue(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,23 +66,6 @@ abstract class AbstractContextSet implements ContextSet {
|
|||||||
return backing().size();
|
return backing().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (o == this) return true;
|
|
||||||
if (!(o instanceof ContextSet)) return false;
|
|
||||||
final ContextSet that = (ContextSet) o;
|
|
||||||
|
|
||||||
final Multimap<String, String> otherContexts;
|
|
||||||
|
|
||||||
if (that instanceof AbstractContextSet) {
|
|
||||||
otherContexts = ((AbstractContextSet) that).backing();
|
|
||||||
} else {
|
|
||||||
otherContexts = that.toMultimap();
|
|
||||||
}
|
|
||||||
|
|
||||||
return backing().equals(otherContexts);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return backing().hashCode();
|
return backing().hashCode();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api.context;
|
package me.lucko.luckperms.api.context;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates whether contexts are applicable to a {@link T subject}.
|
* Calculates whether contexts are applicable to a {@link T subject}.
|
||||||
@@ -44,7 +44,6 @@ public interface ContextCalculator<T> {
|
|||||||
* @return the map
|
* @return the map
|
||||||
* @since 2.13
|
* @since 2.13
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull MutableContextSet giveApplicableContext(@NonNull T subject, @NonNull MutableContextSet accumulator);
|
||||||
MutableContextSet giveApplicableContext(@Nonnull T subject, @Nonnull MutableContextSet accumulator);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,9 +28,9 @@ package me.lucko.luckperms.api.context;
|
|||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.User;
|
import me.lucko.luckperms.api.User;
|
||||||
|
|
||||||
import java.util.Optional;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages {@link ContextCalculator}s, and calculates applicable contexts for a
|
* Manages {@link ContextCalculator}s, and calculates applicable contexts for a
|
||||||
@@ -44,9 +44,11 @@ import javax.annotation.Nonnull;
|
|||||||
*
|
*
|
||||||
* <p></p>
|
* <p></p>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@code org.bukkit.entity.Player}</li>
|
* <li>{@code org.bukkit.entity.Player}</li>
|
||||||
* <li>{@code net.md_5.bungee.api.connection.ProxiedPlayer}</li>
|
* <li>{@code net.md_5.bungee.api.connection.ProxiedPlayer}</li>
|
||||||
* <li>{@code org.spongepowered.api.service.permission.Subject}</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>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
@@ -59,8 +61,7 @@ public interface ContextManager {
|
|||||||
* @param subject the subject
|
* @param subject the subject
|
||||||
* @return the applicable context for the subject
|
* @return the applicable context for the subject
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull ImmutableContextSet getApplicableContext(@NonNull Object subject);
|
||||||
ImmutableContextSet getApplicableContext(@Nonnull Object subject);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queries the ContextManager for current context values for the subject.
|
* Queries the ContextManager for current context values for the subject.
|
||||||
@@ -68,8 +69,7 @@ public interface ContextManager {
|
|||||||
* @param subject the subject
|
* @param subject the subject
|
||||||
* @return the applicable context for the subject
|
* @return the applicable context for the subject
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Contexts getApplicableContexts(@NonNull Object subject);
|
||||||
Contexts getApplicableContexts(@Nonnull Object subject);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queries the ContextManager for current context values for the given User.
|
* Queries the ContextManager for current context values for the given User.
|
||||||
@@ -83,8 +83,7 @@ public interface ContextManager {
|
|||||||
* @param user the user
|
* @param user the user
|
||||||
* @return the applicable context for the subject
|
* @return the applicable context for the subject
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Optional<ImmutableContextSet> lookupApplicableContext(@NonNull User user);
|
||||||
Optional<ImmutableContextSet> lookupApplicableContext(@Nonnull User user);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queries the ContextManager for current context values for the given User.
|
* Queries the ContextManager for current context values for the given User.
|
||||||
@@ -98,8 +97,7 @@ public interface ContextManager {
|
|||||||
* @param user the user
|
* @param user the user
|
||||||
* @return the applicable context for the subject
|
* @return the applicable context for the subject
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Optional<Contexts> lookupApplicableContexts(@NonNull User user);
|
||||||
Optional<Contexts> lookupApplicableContexts(@Nonnull User user);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the contexts from the static calculators in this manager.
|
* Gets the contexts from the static calculators in this manager.
|
||||||
@@ -109,8 +107,7 @@ public interface ContextManager {
|
|||||||
*
|
*
|
||||||
* @return the current active static contexts
|
* @return the current active static contexts
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull ImmutableContextSet getStaticContext();
|
||||||
ImmutableContextSet getStaticContext();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the contexts from the static calculators in this manager.
|
* Gets the contexts from the static calculators in this manager.
|
||||||
@@ -120,8 +117,7 @@ public interface ContextManager {
|
|||||||
*
|
*
|
||||||
* @return the current active static contexts
|
* @return the current active static contexts
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Contexts getStaticContexts();
|
||||||
Contexts getStaticContexts();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forms a {@link Contexts} instance from an {@link ImmutableContextSet}.
|
* Forms a {@link Contexts} instance from an {@link ImmutableContextSet}.
|
||||||
@@ -129,12 +125,11 @@ public interface ContextManager {
|
|||||||
* <p>This method relies on the plugins configuration to form the
|
* <p>This method relies on the plugins configuration to form the
|
||||||
* {@link Contexts} instance.</p>
|
* {@link Contexts} instance.</p>
|
||||||
*
|
*
|
||||||
* @param subject the reference subject
|
* @param subject the reference subject
|
||||||
* @param contextSet the context set
|
* @param contextSet the context set
|
||||||
* @return a contexts instance
|
* @return a contexts instance
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Contexts formContexts(@NonNull Object subject, @NonNull ImmutableContextSet contextSet);
|
||||||
Contexts formContexts(@Nonnull Object subject, @Nonnull ImmutableContextSet contextSet);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forms a {@link Contexts} instance from an {@link ImmutableContextSet}.
|
* Forms a {@link Contexts} instance from an {@link ImmutableContextSet}.
|
||||||
@@ -145,30 +140,28 @@ public interface ContextManager {
|
|||||||
* @param contextSet the context set
|
* @param contextSet the context set
|
||||||
* @return a contexts instance
|
* @return a contexts instance
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Contexts formContexts(@NonNull ImmutableContextSet contextSet);
|
||||||
Contexts formContexts(@Nonnull ImmutableContextSet contextSet);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a context calculator with the manager.
|
* Registers a context calculator with the manager.
|
||||||
*
|
*
|
||||||
* @param calculator the calculator
|
* @param calculator the calculator
|
||||||
*/
|
*/
|
||||||
void registerCalculator(@Nonnull ContextCalculator<?> calculator);
|
void registerCalculator(@NonNull ContextCalculator<?> calculator);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a static context calculator with the manager.
|
* Unregisters a context calculator with the manager.
|
||||||
*
|
|
||||||
* <p>Static calculators provide the same context for all subjects.</p>
|
|
||||||
*
|
*
|
||||||
* @param calculator the calculator
|
* @param calculator the calculator
|
||||||
|
* @since 4.4
|
||||||
*/
|
*/
|
||||||
void registerStaticCalculator(@Nonnull StaticContextCalculator calculator);
|
void unregisterCalculator(@NonNull ContextCalculator<?> calculator);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidates the lookup cache for a given subject
|
* Invalidates the lookup cache for a given subject
|
||||||
*
|
*
|
||||||
* @param subject the subject
|
* @param subject the subject
|
||||||
*/
|
*/
|
||||||
void invalidateCache(@Nonnull Object subject);
|
void invalidateCache(@NonNull Object subject);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,14 +27,14 @@ package me.lucko.luckperms.api.context;
|
|||||||
|
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A set of contexts.
|
* A set of contexts.
|
||||||
*
|
*
|
||||||
@@ -71,24 +71,22 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
* @return a new ImmutableContextSet containing one context pair
|
* @return a new ImmutableContextSet containing one context pair
|
||||||
* @throws NullPointerException if key or value is null
|
* @throws NullPointerException if key or value is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
static @NonNull ImmutableContextSet singleton(@NonNull String key, @NonNull String value) {
|
||||||
static ImmutableContextSet singleton(@Nonnull String key, @Nonnull String value) {
|
|
||||||
return ImmutableContextSet.singleton(key, value);
|
return ImmutableContextSet.singleton(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an {@link ImmutableContextSet} from two context pairs.
|
* Creates an {@link ImmutableContextSet} from two context pairs.
|
||||||
*
|
*
|
||||||
* @param key1 the first key
|
* @param key1 the first key
|
||||||
* @param value1 the first value
|
* @param value1 the first value
|
||||||
* @param key2 the second key
|
* @param key2 the second key
|
||||||
* @param value2 the second value
|
* @param value2 the second value
|
||||||
* @return a new ImmutableContextSet containing the two pairs
|
* @return a new ImmutableContextSet containing the two pairs
|
||||||
* @throws NullPointerException if any of the keys or values are null
|
* @throws NullPointerException if any of the keys or values are null
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
static @NonNull ImmutableContextSet of(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2) {
|
||||||
static ImmutableContextSet of(@Nonnull String key1, @Nonnull String value1, @Nonnull String key2, @Nonnull String value2) {
|
|
||||||
return ImmutableContextSet.of(key1, value1, key2, value2);
|
return ImmutableContextSet.of(key1, value1, key2, value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,8 +97,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
* @return a new ImmutableContextSet representing the pairs in the iterable
|
* @return a new ImmutableContextSet representing the pairs in the iterable
|
||||||
* @throws NullPointerException if the iterable is null
|
* @throws NullPointerException if the iterable is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
static @NonNull ImmutableContextSet fromEntries(@NonNull Iterable<? extends Map.Entry<String, String>> iterable) {
|
||||||
static ImmutableContextSet fromEntries(@Nonnull Iterable<? extends Map.Entry<String, String>> iterable) {
|
|
||||||
return ImmutableContextSet.fromEntries(iterable);
|
return ImmutableContextSet.fromEntries(iterable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,8 +108,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
* @return a new ImmutableContextSet representing the pairs from the map
|
* @return a new ImmutableContextSet representing the pairs from the map
|
||||||
* @throws NullPointerException if the map is null
|
* @throws NullPointerException if the map is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
static @NonNull ImmutableContextSet fromMap(@NonNull Map<String, String> map) {
|
||||||
static ImmutableContextSet fromMap(@Nonnull Map<String, String> map) {
|
|
||||||
return ImmutableContextSet.fromMap(map);
|
return ImmutableContextSet.fromMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,8 +120,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
* @throws NullPointerException if the multimap is null
|
* @throws NullPointerException if the multimap is null
|
||||||
* @since 2.16
|
* @since 2.16
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
static @NonNull ImmutableContextSet fromMultimap(@NonNull Multimap<String, String> multimap) {
|
||||||
static ImmutableContextSet fromMultimap(@Nonnull Multimap<String, String> multimap) {
|
|
||||||
return ImmutableContextSet.fromMultimap(multimap);
|
return ImmutableContextSet.fromMultimap(multimap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,8 +133,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
* @return a new ImmutableContextSet with the same content and the one provided
|
* @return a new ImmutableContextSet with the same content and the one provided
|
||||||
* @throws NullPointerException if contextSet is null
|
* @throws NullPointerException if contextSet is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
static @NonNull ImmutableContextSet fromSet(@NonNull ContextSet contextSet) {
|
||||||
static ImmutableContextSet fromSet(@Nonnull ContextSet contextSet) {
|
|
||||||
return ImmutableContextSet.fromSet(contextSet);
|
return ImmutableContextSet.fromSet(contextSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,8 +142,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
*
|
*
|
||||||
* @return an empty ImmutableContextSet
|
* @return an empty ImmutableContextSet
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
static @NonNull ImmutableContextSet empty() {
|
||||||
static ImmutableContextSet empty() {
|
|
||||||
return ImmutableContextSet.empty();
|
return ImmutableContextSet.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,8 +163,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
*
|
*
|
||||||
* @return an immutable representation of this set
|
* @return an immutable representation of this set
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull ImmutableContextSet makeImmutable();
|
||||||
ImmutableContextSet makeImmutable();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a mutable copy of this {@link ContextSet}.
|
* Creates a mutable copy of this {@link ContextSet}.
|
||||||
@@ -182,8 +174,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
* @return a mutable ContextSet
|
* @return a mutable ContextSet
|
||||||
* @since 2.16
|
* @since 2.16
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull MutableContextSet mutableCopy();
|
||||||
MutableContextSet mutableCopy();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link Set} of {@link Map.Entry}s representing the current
|
* Returns a {@link Set} of {@link Map.Entry}s representing the current
|
||||||
@@ -194,8 +185,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
*
|
*
|
||||||
* @return an immutable set
|
* @return an immutable set
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Set<Map.Entry<String, String>> toSet();
|
||||||
Set<Map.Entry<String, String>> toSet();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link Map} <b>loosely</b> representing the current state of
|
* Returns a {@link Map} <b>loosely</b> representing the current state of
|
||||||
@@ -214,9 +204,8 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
* @return an immutable map
|
* @return an immutable map
|
||||||
* @deprecated because the resultant map may not contain all data in the ContextSet
|
* @deprecated because the resultant map may not contain all data in the ContextSet
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
Map<String, String> toMap();
|
@NonNull Map<String, String> toMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link Multimap} representing the current state of this
|
* Returns a {@link Multimap} representing the current state of this
|
||||||
@@ -228,8 +217,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
* @return a multimap
|
* @return a multimap
|
||||||
* @since 2.16
|
* @since 2.16
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Multimap<String, String> toMultimap();
|
||||||
Multimap<String, String> toMultimap();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an {@link Iterator} over each of the context pairs in this set.
|
* Returns an {@link Iterator} over each of the context pairs in this set.
|
||||||
@@ -241,9 +229,8 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
*
|
*
|
||||||
* @return an iterator
|
* @return an iterator
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
Iterator<Map.Entry<String, String>> iterator();
|
@NonNull Iterator<Map.Entry<String, String>> iterator();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the {@link ContextSet} contains at least one value for the
|
* Returns if the {@link ContextSet} contains at least one value for the
|
||||||
@@ -253,7 +240,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
* @return true if the set contains a value for the key
|
* @return true if the set contains a value for the key
|
||||||
* @throws NullPointerException if the key is null
|
* @throws NullPointerException if the key is null
|
||||||
*/
|
*/
|
||||||
boolean containsKey(@Nonnull String key);
|
boolean containsKey(@NonNull String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link Set} of the values mapped to the given key.
|
* Returns a {@link Set} of the values mapped to the given key.
|
||||||
@@ -265,8 +252,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
* @return a set of values
|
* @return a set of values
|
||||||
* @throws NullPointerException if the key is null
|
* @throws NullPointerException if the key is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Set<String> getValues(@NonNull String key);
|
||||||
Set<String> getValues(@Nonnull String key);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns any value from this {@link ContextSet} matching the key, if present.
|
* Returns any value from this {@link ContextSet} matching the key, if present.
|
||||||
@@ -278,8 +264,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
* @return an optional containing any match
|
* @return an optional containing any match
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull Optional<String> getAnyValue(@NonNull String key) {
|
||||||
default Optional<String> getAnyValue(@Nonnull String key) {
|
|
||||||
return getValues(key).stream().findAny();
|
return getValues(key).stream().findAny();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,7 +276,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
* @return true if the set contains the context pair
|
* @return true if the set contains the context pair
|
||||||
* @throws NullPointerException if the key or value is null
|
* @throws NullPointerException if the key or value is null
|
||||||
*/
|
*/
|
||||||
boolean has(@Nonnull String key, @Nonnull String value);
|
boolean has(@NonNull String key, @NonNull String value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the {@link ContextSet} contains a given context pairing.
|
* Returns if the {@link ContextSet} contains a given context pairing.
|
||||||
@@ -300,7 +285,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
* @return true if the set contains the context pair
|
* @return true if the set contains the context pair
|
||||||
* @throws NullPointerException if the key or value is null
|
* @throws NullPointerException if the key or value is null
|
||||||
*/
|
*/
|
||||||
default boolean has(@Nonnull Map.Entry<String, String> entry) {
|
default boolean has(Map.@NonNull Entry<String, String> entry) {
|
||||||
Objects.requireNonNull(entry, "entry");
|
Objects.requireNonNull(entry, "entry");
|
||||||
return has(entry.getKey(), entry.getValue());
|
return has(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
@@ -317,7 +302,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
|||||||
* @return true if all entries in this set are also in the other set
|
* @return true if all entries in this set are also in the other set
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
default boolean isSatisfiedBy(@Nonnull ContextSet other) {
|
default boolean isSatisfiedBy(@NonNull ContextSet other) {
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,21 +30,19 @@ import com.google.common.collect.ImmutableSetMultimap;
|
|||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.google.common.collect.SetMultimap;
|
import com.google.common.collect.SetMultimap;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Spliterator;
|
import java.util.Spliterator;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An immutable implementation of {@link ContextSet}.
|
* An immutable implementation of {@link ContextSet}.
|
||||||
*
|
*
|
||||||
* @since 2.16
|
* @since 2.16
|
||||||
*/
|
*/
|
||||||
@Immutable
|
|
||||||
public final class ImmutableContextSet extends AbstractContextSet implements ContextSet {
|
public final class ImmutableContextSet extends AbstractContextSet implements ContextSet {
|
||||||
private static final ImmutableContextSet EMPTY = new ImmutableContextSet(ImmutableSetMultimap.of());
|
private static final ImmutableContextSet EMPTY = new ImmutableContextSet(ImmutableSetMultimap.of());
|
||||||
|
|
||||||
@@ -54,8 +52,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
* @return a new ImmutableContextSet builder
|
* @return a new ImmutableContextSet builder
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull Builder builder() {
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,8 +64,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
* @return a new ImmutableContextSet containing one context pair
|
* @return a new ImmutableContextSet containing one context pair
|
||||||
* @throws NullPointerException if key or value is null
|
* @throws NullPointerException if key or value is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull ImmutableContextSet singleton(@NonNull String key, @NonNull String value) {
|
||||||
public static ImmutableContextSet singleton(@Nonnull String key, @Nonnull String value) {
|
|
||||||
return new ImmutableContextSet(ImmutableSetMultimap.of(sanitizeKey(key), sanitizeValue(value)));
|
return new ImmutableContextSet(ImmutableSetMultimap.of(sanitizeKey(key), sanitizeValue(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,8 +79,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
* @throws NullPointerException if any of the keys or values are null
|
* @throws NullPointerException if any of the keys or values are null
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull ImmutableContextSet of(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2) {
|
||||||
public static ImmutableContextSet of(@Nonnull String key1, @Nonnull String value1, @Nonnull String key2, @Nonnull String value2) {
|
|
||||||
return new ImmutableContextSet(ImmutableSetMultimap.of(
|
return new ImmutableContextSet(ImmutableSetMultimap.of(
|
||||||
sanitizeKey(key1),
|
sanitizeKey(key1),
|
||||||
sanitizeValue(value1),
|
sanitizeValue(value1),
|
||||||
@@ -100,8 +95,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
* @return a new ImmutableContextSet representing the pairs in the iterable
|
* @return a new ImmutableContextSet representing the pairs in the iterable
|
||||||
* @throws NullPointerException if the iterable is null
|
* @throws NullPointerException if the iterable is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull ImmutableContextSet fromEntries(@NonNull Iterable<? extends Map.Entry<String, String>> iterable) {
|
||||||
public static ImmutableContextSet fromEntries(@Nonnull Iterable<? extends Map.Entry<String, String>> iterable) {
|
|
||||||
Objects.requireNonNull(iterable, "iterable");
|
Objects.requireNonNull(iterable, "iterable");
|
||||||
ImmutableContextSet.Builder builder = builder();
|
ImmutableContextSet.Builder builder = builder();
|
||||||
for (Map.Entry<String, String> entry : iterable) {
|
for (Map.Entry<String, String> entry : iterable) {
|
||||||
@@ -117,8 +111,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
* @return a new ImmutableContextSet representing the pairs from the map
|
* @return a new ImmutableContextSet representing the pairs from the map
|
||||||
* @throws NullPointerException if the map is null
|
* @throws NullPointerException if the map is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull ImmutableContextSet fromMap(@NonNull Map<String, String> map) {
|
||||||
public static ImmutableContextSet fromMap(@Nonnull Map<String, String> map) {
|
|
||||||
return fromEntries(Objects.requireNonNull(map, "map").entrySet());
|
return fromEntries(Objects.requireNonNull(map, "map").entrySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,8 +123,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
* @throws NullPointerException if the multimap is null
|
* @throws NullPointerException if the multimap is null
|
||||||
* @since 2.16
|
* @since 2.16
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull ImmutableContextSet fromMultimap(@NonNull Multimap<String, String> multimap) {
|
||||||
public static ImmutableContextSet fromMultimap(@Nonnull Multimap<String, String> multimap) {
|
|
||||||
return fromEntries(Objects.requireNonNull(multimap, "multimap").entries());
|
return fromEntries(Objects.requireNonNull(multimap, "multimap").entries());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,8 +136,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
* @return a new ImmutableContextSet with the same content and the one provided
|
* @return a new ImmutableContextSet with the same content and the one provided
|
||||||
* @throws NullPointerException if contextSet is null
|
* @throws NullPointerException if contextSet is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull ImmutableContextSet fromSet(@NonNull ContextSet contextSet) {
|
||||||
public static ImmutableContextSet fromSet(@Nonnull ContextSet contextSet) {
|
|
||||||
return Objects.requireNonNull(contextSet, "contextSet").makeImmutable();
|
return Objects.requireNonNull(contextSet, "contextSet").makeImmutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,8 +145,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
*
|
*
|
||||||
* @return an empty ImmutableContextSet
|
* @return an empty ImmutableContextSet
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull ImmutableContextSet empty() {
|
||||||
public static ImmutableContextSet empty() {
|
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,29 +172,25 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Deprecated
|
||||||
@Override
|
@Override // This set is already immutable!
|
||||||
@Deprecated // This set is already immutable!
|
public @NonNull ImmutableContextSet makeImmutable() {
|
||||||
public ImmutableContextSet makeImmutable() {
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public MutableContextSet mutableCopy() {
|
public @NonNull MutableContextSet mutableCopy() {
|
||||||
return MutableContextSet.fromSet(this);
|
return MutableContextSet.fromSet(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Map.Entry<String, String>> toSet() {
|
public @NonNull Set<Map.Entry<String, String>> toSet() {
|
||||||
return this.map.entries();
|
return this.map.entries();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Map<String, String> toMap() {
|
@Override
|
||||||
|
public @NonNull Map<String, String> toMap() {
|
||||||
ImmutableMap.Builder<String, String> m = ImmutableMap.builder();
|
ImmutableMap.Builder<String, String> m = ImmutableMap.builder();
|
||||||
for (Map.Entry<String, String> e : this.map.entries()) {
|
for (Map.Entry<String, String> e : this.map.entries()) {
|
||||||
m.put(e.getKey(), e.getValue());
|
m.put(e.getKey(), e.getValue());
|
||||||
@@ -212,15 +198,13 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
return m.build();
|
return m.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public Multimap<String, String> toMultimap() {
|
public @NonNull Multimap<String, String> toMultimap() {
|
||||||
return this.map;
|
return this.map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Map.Entry<String, String>> iterator() {
|
public @NonNull Iterator<Map.Entry<String, String>> iterator() {
|
||||||
return this.map.entries().iterator();
|
return this.map.entries().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,6 +213,28 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
return this.map.entries().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 that = (ContextSet) o;
|
||||||
|
|
||||||
|
// 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
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return this.hashCode;
|
return this.hashCode;
|
||||||
@@ -271,8 +277,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
* @throws NullPointerException if the key or value is null
|
* @throws NullPointerException if the key or value is null
|
||||||
* @see MutableContextSet#add(String, String)
|
* @see MutableContextSet#add(String, String)
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public @NonNull Builder add(@NonNull String key, @NonNull String value) {
|
||||||
public Builder add(@Nonnull String key, @Nonnull String value) {
|
|
||||||
put(sanitizeKey(key), sanitizeValue(value));
|
put(sanitizeKey(key), sanitizeValue(value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -285,8 +290,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
* @throws NullPointerException if the entry is null
|
* @throws NullPointerException if the entry is null
|
||||||
* @see MutableContextSet#add(Map.Entry)
|
* @see MutableContextSet#add(Map.Entry)
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public @NonNull Builder add(Map.@NonNull Entry<String, String> entry) {
|
||||||
public Builder add(@Nonnull Map.Entry<String, String> entry) {
|
|
||||||
Objects.requireNonNull(entry, "entry");
|
Objects.requireNonNull(entry, "entry");
|
||||||
add(entry.getKey(), entry.getValue());
|
add(entry.getKey(), entry.getValue());
|
||||||
return this;
|
return this;
|
||||||
@@ -300,8 +304,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
* @throws NullPointerException if iterable is null
|
* @throws NullPointerException if iterable is null
|
||||||
* @see MutableContextSet#addAll(Iterable)
|
* @see MutableContextSet#addAll(Iterable)
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public @NonNull Builder addAll(@NonNull Iterable<? extends Map.Entry<String, String>> iterable) {
|
||||||
public Builder addAll(@Nonnull Iterable<? extends Map.Entry<String, String>> iterable) {
|
|
||||||
for (Map.Entry<String, String> e : Objects.requireNonNull(iterable, "iterable")) {
|
for (Map.Entry<String, String> e : Objects.requireNonNull(iterable, "iterable")) {
|
||||||
add(e);
|
add(e);
|
||||||
}
|
}
|
||||||
@@ -316,8 +319,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
* @throws NullPointerException if the map is null
|
* @throws NullPointerException if the map is null
|
||||||
* @see MutableContextSet#addAll(Map)
|
* @see MutableContextSet#addAll(Map)
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public @NonNull Builder addAll(@NonNull Map<String, String> map) {
|
||||||
public Builder addAll(@Nonnull Map<String, String> map) {
|
|
||||||
addAll(Objects.requireNonNull(map, "map").entrySet());
|
addAll(Objects.requireNonNull(map, "map").entrySet());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -331,8 +333,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
* @since 3.4
|
* @since 3.4
|
||||||
* @see MutableContextSet#addAll(Multimap)
|
* @see MutableContextSet#addAll(Multimap)
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public @NonNull Builder addAll(@NonNull Multimap<String, String> multimap) {
|
||||||
public Builder addAll(@Nonnull Multimap<String, String> multimap) {
|
|
||||||
addAll(Objects.requireNonNull(multimap, "multimap").entries());
|
addAll(Objects.requireNonNull(multimap, "multimap").entries());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -345,8 +346,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
* @throws NullPointerException if the contextSet is null
|
* @throws NullPointerException if the contextSet is null
|
||||||
* @see MutableContextSet#addAll(ContextSet)
|
* @see MutableContextSet#addAll(ContextSet)
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public @NonNull Builder addAll(@NonNull ContextSet contextSet) {
|
||||||
public Builder addAll(@Nonnull ContextSet contextSet) {
|
|
||||||
Objects.requireNonNull(contextSet, "contextSet");
|
Objects.requireNonNull(contextSet, "contextSet");
|
||||||
if (contextSet instanceof AbstractContextSet) {
|
if (contextSet instanceof AbstractContextSet) {
|
||||||
AbstractContextSet other = ((AbstractContextSet) contextSet);
|
AbstractContextSet other = ((AbstractContextSet) contextSet);
|
||||||
@@ -365,8 +365,7 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
*
|
*
|
||||||
* @return an {@link ImmutableContextSet} from the builder
|
* @return an {@link ImmutableContextSet} from the builder
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public @NonNull ImmutableContextSet build() {
|
||||||
public ImmutableContextSet build() {
|
|
||||||
if (this.builder == null) {
|
if (this.builder == null) {
|
||||||
return empty();
|
return empty();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -33,14 +33,14 @@ import com.google.common.collect.Multimap;
|
|||||||
import com.google.common.collect.Multimaps;
|
import com.google.common.collect.Multimaps;
|
||||||
import com.google.common.collect.SetMultimap;
|
import com.google.common.collect.SetMultimap;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Spliterator;
|
import java.util.Spliterator;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mutable implementation of {@link ContextSet}.
|
* A mutable implementation of {@link ContextSet}.
|
||||||
*
|
*
|
||||||
@@ -56,8 +56,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
* @return a new MutableContextSet containing one context pair
|
* @return a new MutableContextSet containing one context pair
|
||||||
* @throws NullPointerException if key or value is null
|
* @throws NullPointerException if key or value is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull MutableContextSet singleton(@NonNull String key, @NonNull String value) {
|
||||||
public static MutableContextSet singleton(@Nonnull String key, @Nonnull String value) {
|
|
||||||
Objects.requireNonNull(key, "key");
|
Objects.requireNonNull(key, "key");
|
||||||
Objects.requireNonNull(value, "value");
|
Objects.requireNonNull(value, "value");
|
||||||
MutableContextSet set = MutableContextSet.create();
|
MutableContextSet set = MutableContextSet.create();
|
||||||
@@ -76,8 +75,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
* @throws NullPointerException if any of the keys or values are null
|
* @throws NullPointerException if any of the keys or values are null
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull MutableContextSet of(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2) {
|
||||||
public static MutableContextSet of(@Nonnull String key1, @Nonnull String value1, @Nonnull String key2, @Nonnull String value2) {
|
|
||||||
Objects.requireNonNull(key1, "key1");
|
Objects.requireNonNull(key1, "key1");
|
||||||
Objects.requireNonNull(value1, "value1");
|
Objects.requireNonNull(value1, "value1");
|
||||||
Objects.requireNonNull(key2, "key2");
|
Objects.requireNonNull(key2, "key2");
|
||||||
@@ -95,8 +93,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
* @return a new MutableContextSet representing the pairs in the iterable
|
* @return a new MutableContextSet representing the pairs in the iterable
|
||||||
* @throws NullPointerException if the iterable is null
|
* @throws NullPointerException if the iterable is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull MutableContextSet fromEntries(@NonNull Iterable<? extends Map.Entry<String, String>> iterable) {
|
||||||
public static MutableContextSet fromEntries(@Nonnull Iterable<? extends Map.Entry<String, String>> iterable) {
|
|
||||||
Objects.requireNonNull(iterable, "iterable");
|
Objects.requireNonNull(iterable, "iterable");
|
||||||
MutableContextSet set = create();
|
MutableContextSet set = create();
|
||||||
set.addAll(iterable);
|
set.addAll(iterable);
|
||||||
@@ -110,8 +107,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
* @return a new MutableContextSet representing the pairs from the map
|
* @return a new MutableContextSet representing the pairs from the map
|
||||||
* @throws NullPointerException if the map is null
|
* @throws NullPointerException if the map is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull MutableContextSet fromMap(@NonNull Map<String, String> map) {
|
||||||
public static MutableContextSet fromMap(@Nonnull Map<String, String> map) {
|
|
||||||
Objects.requireNonNull(map, "map");
|
Objects.requireNonNull(map, "map");
|
||||||
MutableContextSet set = create();
|
MutableContextSet set = create();
|
||||||
set.addAll(map);
|
set.addAll(map);
|
||||||
@@ -126,8 +122,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
* @throws NullPointerException if the multimap is null
|
* @throws NullPointerException if the multimap is null
|
||||||
* @since 2.16
|
* @since 2.16
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull MutableContextSet fromMultimap(@NonNull Multimap<String, String> multimap) {
|
||||||
public static MutableContextSet fromMultimap(@Nonnull Multimap<String, String> multimap) {
|
|
||||||
Objects.requireNonNull(multimap, "multimap");
|
Objects.requireNonNull(multimap, "multimap");
|
||||||
MutableContextSet set = create();
|
MutableContextSet set = create();
|
||||||
set.addAll(multimap);
|
set.addAll(multimap);
|
||||||
@@ -143,8 +138,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
* @return a new MutableContextSet with the same content and the one provided
|
* @return a new MutableContextSet with the same content and the one provided
|
||||||
* @throws NullPointerException if contextSet is null
|
* @throws NullPointerException if contextSet is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull MutableContextSet fromSet(@NonNull ContextSet contextSet) {
|
||||||
public static MutableContextSet fromSet(@Nonnull ContextSet contextSet) {
|
|
||||||
Objects.requireNonNull(contextSet, "contextSet");
|
Objects.requireNonNull(contextSet, "contextSet");
|
||||||
|
|
||||||
if (contextSet instanceof ImmutableContextSet) {
|
if (contextSet instanceof ImmutableContextSet) {
|
||||||
@@ -164,8 +158,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
*
|
*
|
||||||
* @return a new MutableContextSet
|
* @return a new MutableContextSet
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public static @NonNull MutableContextSet create() {
|
||||||
public static MutableContextSet create() {
|
|
||||||
return new MutableContextSet();
|
return new MutableContextSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,9 +189,8 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ImmutableContextSet makeImmutable() {
|
public @NonNull ImmutableContextSet makeImmutable() {
|
||||||
// if the map is empty, don't create a new instance
|
// if the map is empty, don't create a new instance
|
||||||
if (this.map.isEmpty()) {
|
if (this.map.isEmpty()) {
|
||||||
return ImmutableContextSet.empty();
|
return ImmutableContextSet.empty();
|
||||||
@@ -208,27 +200,24 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public MutableContextSet mutableCopy() {
|
public @NonNull MutableContextSet mutableCopy() {
|
||||||
synchronized (this.map) {
|
synchronized (this.map) {
|
||||||
return new MutableContextSet(this.map);
|
return new MutableContextSet(this.map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Map.Entry<String, String>> toSet() {
|
public @NonNull Set<Map.Entry<String, String>> toSet() {
|
||||||
synchronized (this.map) {
|
synchronized (this.map) {
|
||||||
// map.entries() returns immutable Map.Entry instances, so we can just call copyOf
|
// map.entries() returns immutable Map.Entry instances, so we can just call copyOf
|
||||||
return ImmutableSet.copyOf(this.map.entries());
|
return ImmutableSet.copyOf(this.map.entries());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Map<String, String> toMap() {
|
@Override
|
||||||
|
public @NonNull Map<String, String> toMap() {
|
||||||
ImmutableMap.Builder<String, String> m = ImmutableMap.builder();
|
ImmutableMap.Builder<String, String> m = ImmutableMap.builder();
|
||||||
synchronized (this.map) {
|
synchronized (this.map) {
|
||||||
for (Map.Entry<String, String> e : this.map.entries()) {
|
for (Map.Entry<String, String> e : this.map.entries()) {
|
||||||
@@ -238,17 +227,15 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
return m.build();
|
return m.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public Multimap<String, String> toMultimap() {
|
public @NonNull Multimap<String, String> toMultimap() {
|
||||||
synchronized (this.map) {
|
synchronized (this.map) {
|
||||||
return ImmutableSetMultimap.copyOf(this.map);
|
return ImmutableSetMultimap.copyOf(this.map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Map.Entry<String, String>> iterator() {
|
public @NonNull Iterator<Map.Entry<String, String>> iterator() {
|
||||||
return toSet().iterator();
|
return toSet().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +251,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
* @param value the value to add
|
* @param value the value to add
|
||||||
* @throws NullPointerException if the key or value is null
|
* @throws NullPointerException if the key or value is null
|
||||||
*/
|
*/
|
||||||
public void add(@Nonnull String key, @Nonnull String value) {
|
public void add(@NonNull String key, @NonNull String value) {
|
||||||
this.map.put(sanitizeKey(key), sanitizeValue(value));
|
this.map.put(sanitizeKey(key), sanitizeValue(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,7 +261,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
* @param entry the entry to add
|
* @param entry the entry to add
|
||||||
* @throws NullPointerException if the entry is null
|
* @throws NullPointerException if the entry is null
|
||||||
*/
|
*/
|
||||||
public void add(@Nonnull Map.Entry<String, String> entry) {
|
public void add(Map.@NonNull Entry<String, String> entry) {
|
||||||
Objects.requireNonNull(entry, "entry");
|
Objects.requireNonNull(entry, "entry");
|
||||||
add(entry.getKey(), entry.getValue());
|
add(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
@@ -285,7 +272,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
* @param iterable an iterable of key value context pairs
|
* @param iterable an iterable of key value context pairs
|
||||||
* @throws NullPointerException if iterable is null
|
* @throws NullPointerException if iterable is null
|
||||||
*/
|
*/
|
||||||
public void addAll(@Nonnull Iterable<? extends Map.Entry<String, String>> iterable) {
|
public void addAll(@NonNull Iterable<? extends Map.Entry<String, String>> iterable) {
|
||||||
for (Map.Entry<String, String> e : Objects.requireNonNull(iterable, "iterable")) {
|
for (Map.Entry<String, String> e : Objects.requireNonNull(iterable, "iterable")) {
|
||||||
add(e);
|
add(e);
|
||||||
}
|
}
|
||||||
@@ -297,7 +284,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
* @param map the map to add from
|
* @param map the map to add from
|
||||||
* @throws NullPointerException if the map is null
|
* @throws NullPointerException if the map is null
|
||||||
*/
|
*/
|
||||||
public void addAll(@Nonnull Map<String, String> map) {
|
public void addAll(@NonNull Map<String, String> map) {
|
||||||
addAll(Objects.requireNonNull(map, "map").entrySet());
|
addAll(Objects.requireNonNull(map, "map").entrySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,7 +295,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
* @throws NullPointerException if the map is null
|
* @throws NullPointerException if the map is null
|
||||||
* @since 3.4
|
* @since 3.4
|
||||||
*/
|
*/
|
||||||
public void addAll(@Nonnull Multimap<String, String> multimap) {
|
public void addAll(@NonNull Multimap<String, String> multimap) {
|
||||||
addAll(Objects.requireNonNull(multimap, "multimap").entries());
|
addAll(Objects.requireNonNull(multimap, "multimap").entries());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,7 +305,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
* @param contextSet the set to add from
|
* @param contextSet the set to add from
|
||||||
* @throws NullPointerException if the contextSet is null
|
* @throws NullPointerException if the contextSet is null
|
||||||
*/
|
*/
|
||||||
public void addAll(@Nonnull ContextSet contextSet) {
|
public void addAll(@NonNull ContextSet contextSet) {
|
||||||
Objects.requireNonNull(contextSet, "contextSet");
|
Objects.requireNonNull(contextSet, "contextSet");
|
||||||
if (contextSet instanceof AbstractContextSet) {
|
if (contextSet instanceof AbstractContextSet) {
|
||||||
AbstractContextSet other = ((AbstractContextSet) contextSet);
|
AbstractContextSet other = ((AbstractContextSet) contextSet);
|
||||||
@@ -337,7 +324,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
* @param value the value to remove
|
* @param value the value to remove
|
||||||
* @throws NullPointerException if the key or value is null
|
* @throws NullPointerException if the key or value is null
|
||||||
*/
|
*/
|
||||||
public void remove(@Nonnull String key, @Nonnull String value) {
|
public void remove(@NonNull String key, @NonNull String value) {
|
||||||
this.map.remove(sanitizeKey(key), sanitizeValue(value));
|
this.map.remove(sanitizeKey(key), sanitizeValue(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,7 +334,7 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
* @param key the key to remove
|
* @param key the key to remove
|
||||||
* @throws NullPointerException if the key is null
|
* @throws NullPointerException if the key is null
|
||||||
*/
|
*/
|
||||||
public void removeAll(@Nonnull String key) {
|
public void removeAll(@NonNull String key) {
|
||||||
this.map.removeAll(sanitizeKey(key));
|
this.map.removeAll(sanitizeKey(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,6 +345,22 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
this.map.clear();
|
this.map.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (o == this) return true;
|
||||||
|
if (!(o instanceof ContextSet)) return false;
|
||||||
|
final ContextSet that = (ContextSet) o;
|
||||||
|
|
||||||
|
final Multimap<String, String> thatBacking;
|
||||||
|
if (that instanceof AbstractContextSet) {
|
||||||
|
thatBacking = ((AbstractContextSet) that).backing();
|
||||||
|
} else {
|
||||||
|
thatBacking = that.toMultimap();
|
||||||
|
}
|
||||||
|
|
||||||
|
return backing().equals(thatBacking);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MutableContextSet(contexts=" + this.map + ")";
|
return "MutableContextSet(contexts=" + this.map + ")";
|
||||||
|
|||||||
@@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api.context;
|
package me.lucko.luckperms.api.context;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import javax.annotation.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension of {@link ContextCalculator} which provides the same context
|
* Extension of {@link ContextCalculator} which provides the same context
|
||||||
@@ -43,20 +43,18 @@ public interface StaticContextCalculator extends ContextCalculator<Object> {
|
|||||||
* @param accumulator a map of contexts to add to
|
* @param accumulator a map of contexts to add to
|
||||||
* @return the map
|
* @return the map
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull MutableContextSet giveApplicableContext(@NonNull MutableContextSet accumulator);
|
||||||
MutableContextSet giveApplicableContext(@Nonnull MutableContextSet accumulator);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives the subject all of the applicable contexts they meet
|
* Gives the subject all of the applicable contexts they meet
|
||||||
*
|
*
|
||||||
* @param subject the subject to add contexts to
|
* @param subject the subject to add contexts to
|
||||||
* @param accumulator a map of contexts to add to
|
* @param accumulator a map of contexts to add to
|
||||||
* @return the map
|
* @return the map
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
default MutableContextSet giveApplicableContext(@Nullable Object subject, @Nonnull MutableContextSet accumulator) {
|
@Override
|
||||||
|
default @NonNull MutableContextSet giveApplicableContext(@Nullable Object subject, @NonNull MutableContextSet accumulator) {
|
||||||
return giveApplicableContext(accumulator);
|
return giveApplicableContext(accumulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api.event;
|
package me.lucko.luckperms.api.event;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an event that can be cancelled
|
* Represents an event that can be cancelled
|
||||||
@@ -39,8 +39,7 @@ public interface Cancellable {
|
|||||||
*
|
*
|
||||||
* @return the cancellation
|
* @return the cancellation
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(-1) AtomicBoolean getCancellationState();
|
||||||
AtomicBoolean getCancellationState();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the event is currently cancelled.
|
* Returns true if the event is currently cancelled.
|
||||||
|
|||||||
@@ -25,11 +25,11 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api.event;
|
package me.lucko.luckperms.api.event;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The LuckPerms event bus.
|
* The LuckPerms event bus.
|
||||||
*
|
*
|
||||||
@@ -51,8 +51,7 @@ public interface EventBus {
|
|||||||
* @param <T> the event class
|
* @param <T> the event class
|
||||||
* @return an event handler instance representing this subscription
|
* @return an event handler instance representing this subscription
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull <T extends LuckPermsEvent> EventHandler<T> subscribe(@NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler);
|
||||||
<T extends LuckPermsEvent> EventHandler<T> subscribe(@Nonnull Class<T> eventClass, @Nonnull Consumer<? super T> handler);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a new subscription to the given event.
|
* Registers a new subscription to the given event.
|
||||||
@@ -72,8 +71,7 @@ public interface EventBus {
|
|||||||
* @param handler the event handler
|
* @param handler the event handler
|
||||||
* @return an event handler instance representing this subscription
|
* @return an event handler instance representing this subscription
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull <T extends LuckPermsEvent> EventHandler<T> subscribe(Object plugin, @NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler);
|
||||||
<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.
|
* Gets a set of all registered handlers for a given event.
|
||||||
@@ -82,7 +80,6 @@ public interface EventBus {
|
|||||||
* @param <T> the event class
|
* @param <T> the event class
|
||||||
* @return an immutable set of event handlers
|
* @return an immutable set of event handlers
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull <T extends LuckPermsEvent> Set<EventHandler<T>> getHandlers(@NonNull Class<T> eventClass);
|
||||||
<T extends LuckPermsEvent> Set<EventHandler<T>> getHandlers(@Nonnull Class<T> eventClass);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api.event;
|
package me.lucko.luckperms.api.event;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a subscription to a {@link LuckPermsEvent}.
|
* Represents a subscription to a {@link LuckPermsEvent}.
|
||||||
@@ -41,8 +41,7 @@ public interface EventHandler<T extends LuckPermsEvent> extends AutoCloseable {
|
|||||||
*
|
*
|
||||||
* @return the event class
|
* @return the event class
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Class<T> getEventClass();
|
||||||
Class<T> getEventClass();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this handler is active
|
* Returns true if this handler is active
|
||||||
@@ -63,8 +62,7 @@ public interface EventHandler<T extends LuckPermsEvent> extends AutoCloseable {
|
|||||||
*
|
*
|
||||||
* @return the event consumer
|
* @return the event consumer
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Consumer<? super T> getConsumer();
|
||||||
Consumer<? super T> getConsumer();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of times this handler has been called
|
* Gets the number of times this handler has been called
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ package me.lucko.luckperms.api.event;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.LuckPermsApi;
|
import me.lucko.luckperms.api.LuckPermsApi;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A superinterface for all LuckPerms events.
|
* A superinterface for all LuckPerms events.
|
||||||
@@ -41,7 +41,14 @@ public interface LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the api instance
|
* @return the api instance
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull LuckPermsApi getApi();
|
||||||
LuckPermsApi getApi();
|
|
||||||
|
/**
|
||||||
|
* Gets the type of the event.
|
||||||
|
*
|
||||||
|
* @return the type of the event
|
||||||
|
* @since 4.4
|
||||||
|
*/
|
||||||
|
@NonNull Class<? extends LuckPermsEvent> getEventType();
|
||||||
|
|
||||||
}
|
}
|
||||||
+16
-15
@@ -23,26 +23,27 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.model;
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls how temporary permissions/parents/meta should be set
|
* Represents the position of a parameter within an event.
|
||||||
|
*
|
||||||
|
* <p>This is an implementation detail and should not be relied upon.</p>
|
||||||
*/
|
*/
|
||||||
public enum TemporaryModifier {
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface Param {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Durations will be added to the existing expiry time of a permission
|
* Gets the index of the parameter.
|
||||||
|
*
|
||||||
|
* @return the index
|
||||||
*/
|
*/
|
||||||
ACCUMULATE,
|
int value();
|
||||||
|
|
||||||
/**
|
|
||||||
* Durations will be replaced if the new duration is later than the current expiration
|
|
||||||
*/
|
|
||||||
REPLACE,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The command will just fail if you try to add another permission with the same expiry
|
|
||||||
*/
|
|
||||||
DENY
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ package me.lucko.luckperms.api.event;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.event.source.Source;
|
import me.lucko.luckperms.api.event.source.Source;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an event with a {@link Source}.
|
* Represents an event with a {@link Source}.
|
||||||
@@ -44,7 +44,6 @@ public interface Sourced {
|
|||||||
*
|
*
|
||||||
* @return the source
|
* @return the source
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(-1) Source getSource();
|
||||||
Source getSource();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,8 +28,9 @@ package me.lucko.luckperms.api.event.group;
|
|||||||
import me.lucko.luckperms.api.Group;
|
import me.lucko.luckperms.api.Group;
|
||||||
import me.lucko.luckperms.api.caching.GroupData;
|
import me.lucko.luckperms.api.caching.GroupData;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a groups {@link GroupData} is loaded.
|
* Called when a groups {@link GroupData} is loaded.
|
||||||
@@ -43,15 +44,13 @@ public interface GroupCacheLoadEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the group
|
* @return the group
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) Group getGroup();
|
||||||
Group getGroup();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the data that was loaded
|
* Gets the data that was loaded
|
||||||
*
|
*
|
||||||
* @return the loaded data
|
* @return the loaded data
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) GroupData getLoadedData();
|
||||||
GroupData getLoadedData();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,9 +27,10 @@ package me.lucko.luckperms.api.event.group;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Group;
|
import me.lucko.luckperms.api.Group;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a group is created
|
* Called when a group is created
|
||||||
@@ -41,15 +42,13 @@ public interface GroupCreateEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the new group
|
* @return the new group
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) Group getGroup();
|
||||||
Group getGroup();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the cause of the creation
|
* Gets the cause of the creation
|
||||||
*
|
*
|
||||||
* @return the cause of the creation
|
* @return the cause of the creation
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) CreationCause getCause();
|
||||||
CreationCause getCause();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,8 +28,9 @@ package me.lucko.luckperms.api.event.group;
|
|||||||
import me.lucko.luckperms.api.Group;
|
import me.lucko.luckperms.api.Group;
|
||||||
import me.lucko.luckperms.api.caching.GroupData;
|
import me.lucko.luckperms.api.caching.GroupData;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a groups cached data is refreshed
|
* Called when a groups cached data is refreshed
|
||||||
@@ -43,15 +44,13 @@ public interface GroupDataRecalculateEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the group
|
* @return the group
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) Group getGroup();
|
||||||
Group getGroup();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the data that was recalculated
|
* Gets the data that was recalculated
|
||||||
*
|
*
|
||||||
* @return the data
|
* @return the data
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) GroupData getData();
|
||||||
GroupData getData();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,11 +27,12 @@ package me.lucko.luckperms.api.event.group;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
||||||
|
|
||||||
import java.util.Set;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a group is deleted
|
* Called when a group is deleted
|
||||||
@@ -43,23 +44,20 @@ public interface GroupDeleteEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the name of the deleted group
|
* @return the name of the deleted group
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) String getGroupName();
|
||||||
String getGroupName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an immutable copy of the groups existing data
|
* Gets an immutable copy of the groups existing data
|
||||||
*
|
*
|
||||||
* @return a copy of the groups existing data
|
* @return a copy of the groups existing data
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) Set<Node> getExistingData();
|
||||||
Set<Node> getExistingData();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the cause of the deletion
|
* Gets the cause of the deletion
|
||||||
*
|
*
|
||||||
* @return the cause of the deletion
|
* @return the cause of the deletion
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(2) DeletionCause getCause();
|
||||||
DeletionCause getCause();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,8 +27,9 @@ package me.lucko.luckperms.api.event.group;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Group;
|
import me.lucko.luckperms.api.Group;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a group is loaded into memory from the storage.
|
* Called when a group is loaded into memory from the storage.
|
||||||
@@ -42,7 +43,6 @@ public interface GroupLoadEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the group that was loaded
|
* @return the group that was loaded
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) Group getGroup();
|
||||||
Group getGroup();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,8 +28,9 @@ package me.lucko.luckperms.api.event.log;
|
|||||||
import me.lucko.luckperms.api.LogEntry;
|
import me.lucko.luckperms.api.LogEntry;
|
||||||
import me.lucko.luckperms.api.event.Cancellable;
|
import me.lucko.luckperms.api.event.Cancellable;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a log entry is about to be sent to notifiable players on the platform
|
* Called when a log entry is about to be sent to notifiable players on the platform
|
||||||
@@ -41,8 +42,7 @@ public interface LogBroadcastEvent extends LuckPermsEvent, Cancellable {
|
|||||||
*
|
*
|
||||||
* @return the log entry to be broadcasted
|
* @return the log entry to be broadcasted
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) LogEntry getEntry();
|
||||||
LogEntry getEntry();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets where the log entry originated from.
|
* Gets where the log entry originated from.
|
||||||
@@ -50,8 +50,7 @@ public interface LogBroadcastEvent extends LuckPermsEvent, Cancellable {
|
|||||||
* @return the origin of the log
|
* @return the origin of the log
|
||||||
* @since 3.3
|
* @since 3.3
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) Origin getOrigin();
|
||||||
Origin getOrigin();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents where a log entry is from
|
* Represents where a log entry is from
|
||||||
|
|||||||
@@ -28,11 +28,12 @@ package me.lucko.luckperms.api.event.log;
|
|||||||
import me.lucko.luckperms.api.LogEntry;
|
import me.lucko.luckperms.api.LogEntry;
|
||||||
import me.lucko.luckperms.api.event.Cancellable;
|
import me.lucko.luckperms.api.event.Cancellable;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
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;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a log is about to be published to the network via the MessagingService
|
* Called when a log is about to be published to the network via the MessagingService
|
||||||
*
|
*
|
||||||
@@ -45,15 +46,13 @@ public interface LogNetworkPublishEvent extends LuckPermsEvent, Cancellable {
|
|||||||
*
|
*
|
||||||
* @return the id of the log entry being published
|
* @return the id of the log entry being published
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) UUID getLogId();
|
||||||
UUID getLogId();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the log entry to be published
|
* Gets the log entry to be published
|
||||||
*
|
*
|
||||||
* @return the log entry to be published
|
* @return the log entry to be published
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) LogEntry getEntry();
|
||||||
LogEntry getEntry();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -29,8 +29,9 @@ import me.lucko.luckperms.api.Entity;
|
|||||||
import me.lucko.luckperms.api.LogEntry;
|
import me.lucko.luckperms.api.LogEntry;
|
||||||
import me.lucko.luckperms.api.event.Cancellable;
|
import me.lucko.luckperms.api.event.Cancellable;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a log entry is about to be sent to specific notifiable object on
|
* Called when a log entry is about to be sent to specific notifiable object on
|
||||||
@@ -49,24 +50,21 @@ public interface LogNotifyEvent extends LuckPermsEvent, Cancellable {
|
|||||||
*
|
*
|
||||||
* @return the log entry to be sent
|
* @return the log entry to be sent
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) LogEntry getEntry();
|
||||||
LogEntry getEntry();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets where the log entry originated from.
|
* Gets where the log entry originated from.
|
||||||
*
|
*
|
||||||
* @return the origin of the log
|
* @return the origin of the log
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) Origin getOrigin();
|
||||||
Origin getOrigin();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the object to be notified.
|
* Gets the object to be notified.
|
||||||
*
|
*
|
||||||
* @return the object to notify
|
* @return the object to notify
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(2) Entity getNotifiable();
|
||||||
Entity getNotifiable();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents where a log entry is from
|
* Represents where a log entry is from
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ package me.lucko.luckperms.api.event.log;
|
|||||||
import me.lucko.luckperms.api.LogEntry;
|
import me.lucko.luckperms.api.LogEntry;
|
||||||
import me.lucko.luckperms.api.event.Cancellable;
|
import me.lucko.luckperms.api.event.Cancellable;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a log is about to be published to the storage file/table
|
* Called when a log is about to be published to the storage file/table
|
||||||
@@ -41,7 +42,6 @@ public interface LogPublishEvent extends LuckPermsEvent, Cancellable {
|
|||||||
*
|
*
|
||||||
* @return the log entry to be published
|
* @return the log entry to be published
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) LogEntry getEntry();
|
||||||
LogEntry getEntry();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,11 +27,12 @@ package me.lucko.luckperms.api.event.log;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.LogEntry;
|
import me.lucko.luckperms.api.LogEntry;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
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;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a log entry is received via the MessagingService
|
* Called when a log entry is received via the MessagingService
|
||||||
*
|
*
|
||||||
@@ -44,15 +45,13 @@ public interface LogReceiveEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the id of the log entry being received
|
* @return the id of the log entry being received
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) UUID getLogId();
|
||||||
UUID getLogId();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the log entry being received
|
* Gets the log entry being received
|
||||||
*
|
*
|
||||||
* @return the log entry being received
|
* @return the log entry being received
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) LogEntry getEntry();
|
||||||
LogEntry getEntry();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,8 +26,9 @@
|
|||||||
package me.lucko.luckperms.api.event.node;
|
package me.lucko.luckperms.api.event.node;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a node is added to a holder
|
* Called when a node is added to a holder
|
||||||
@@ -39,7 +40,6 @@ public interface NodeAddEvent extends NodeMutateEvent {
|
|||||||
*
|
*
|
||||||
* @return the node that was added
|
* @return the node that was added
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(3) Node getNode();
|
||||||
Node getNode();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,14 +25,17 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api.event.node;
|
package me.lucko.luckperms.api.event.node;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.Group;
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.api.PermissionHolder;
|
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.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a node is added to/removed from a user/group
|
* Called when a node is added to/removed from a user/group
|
||||||
*/
|
*/
|
||||||
@@ -43,24 +46,21 @@ public interface NodeMutateEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the event target
|
* @return the event target
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) PermissionHolder getTarget();
|
||||||
PermissionHolder getTarget();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an immutable copy of the holders data before the change
|
* Gets an immutable copy of the holders data before the change
|
||||||
*
|
*
|
||||||
* @return the data before the change
|
* @return the data before the change
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) Set<Node> getDataBefore();
|
||||||
Set<Node> getDataBefore();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an immutable copy of the holders data after the change
|
* Gets an immutable copy of the holders data after the change
|
||||||
*
|
*
|
||||||
* @return the data after the change
|
* @return the data after the change
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(2) Set<Node> getDataAfter();
|
||||||
Set<Node> getDataAfter();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets whether the target of this event is a {@link me.lucko.luckperms.api.User}
|
* Gets whether the target of this event is a {@link me.lucko.luckperms.api.User}
|
||||||
@@ -69,7 +69,9 @@ public interface NodeMutateEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return if the event is targeting a user
|
* @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}
|
* Gets whether the target of this event is a {@link me.lucko.luckperms.api.Group}
|
||||||
@@ -78,6 +80,8 @@ public interface NodeMutateEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return if the event is targeting a group
|
* @return if the event is targeting a group
|
||||||
*/
|
*/
|
||||||
boolean isGroup();
|
default boolean isGroup() {
|
||||||
|
return getTarget() instanceof Group;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,8 +26,9 @@
|
|||||||
package me.lucko.luckperms.api.event.node;
|
package me.lucko.luckperms.api.event.node;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a node is removed from a holder
|
* Called when a node is removed from a holder
|
||||||
@@ -39,7 +40,6 @@ public interface NodeRemoveEvent extends NodeMutateEvent {
|
|||||||
*
|
*
|
||||||
* @return the node that was removed
|
* @return the node that was removed
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(3) Node getNode();
|
||||||
Node getNode();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[email protected]>
|
||||||
|
* 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();
|
||||||
|
|
||||||
|
}
|
||||||
+34
-16
@@ -23,50 +23,68 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.api.event.user;
|
package me.lucko.luckperms.api.event.player;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.User;
|
import me.lucko.luckperms.api.User;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
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;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when LuckPerms has finished processing a certain Player's connection.
|
* Called when LuckPerms has finished processing a Player's initial connection.
|
||||||
*
|
*
|
||||||
* <p>This event will always execute during the platforms async login/auth event.
|
* <p>This event will always execute during the platforms async connection
|
||||||
* All handlers will be called instantly.</p>
|
* 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
|
* <p>This, among other things, allows you to wait until permission data is
|
||||||
* for a User during the BungeeCord 'LoginEvent', as event priorities are ignored
|
* loaded for a User during the BungeeCord 'LoginEvent', as event priorities are
|
||||||
* by the current implementation.</p>
|
* ignored by the current implementation.</p>
|
||||||
*
|
*
|
||||||
* @since 3.4
|
* <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 UserLoginProcessEvent extends LuckPermsEvent {
|
public interface PlayerLoginProcessEvent extends LuckPermsEvent {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the UUID of the connection which was processed
|
* Gets the UUID of the connection which was processed
|
||||||
*
|
*
|
||||||
* @return the uuid of the connection which was processed
|
* @return the uuid of the connection which was processed
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) UUID getUuid();
|
||||||
UUID getUuid();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the username of the connection which was processed
|
* Gets the username of the connection which was processed
|
||||||
*
|
*
|
||||||
* @return the username of the connection which was processed
|
* @return the username of the connection which was processed
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) String getUsername();
|
||||||
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.
|
* 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
|
* @return the user instance
|
||||||
*/
|
*/
|
||||||
User getUser();
|
@Nullable @Param(2) User getUser();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ package me.lucko.luckperms.api.event.source;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Entity;
|
import me.lucko.luckperms.api.Entity;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an {@link Entity} which was the {@link Source} of something.
|
* Represents an {@link Entity} which was the {@link Source} of something.
|
||||||
@@ -41,7 +41,6 @@ public interface EntitySource extends Source {
|
|||||||
*
|
*
|
||||||
* @return the entity
|
* @return the entity
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Entity getEntity();
|
||||||
Entity getEntity();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ package me.lucko.luckperms.api.event.source;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Entity;
|
import me.lucko.luckperms.api.Entity;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the source of an event.
|
* Represents the source of an event.
|
||||||
@@ -43,8 +43,7 @@ public interface Source {
|
|||||||
*
|
*
|
||||||
* @return the type
|
* @return the type
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Type getType();
|
||||||
Type getType();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a type of source
|
* Represents a type of source
|
||||||
|
|||||||
@@ -27,11 +27,12 @@ package me.lucko.luckperms.api.event.sync;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.event.Cancellable;
|
import me.lucko.luckperms.api.event.Cancellable;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
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;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before a received network sync task runs
|
* Called before a received network sync task runs
|
||||||
*/
|
*/
|
||||||
@@ -42,7 +43,6 @@ public interface PreNetworkSyncEvent extends LuckPermsEvent, Cancellable {
|
|||||||
*
|
*
|
||||||
* @return the id of the sync request
|
* @return the id of the sync request
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) UUID getSyncId();
|
||||||
UUID getSyncId();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,9 +27,10 @@ package me.lucko.luckperms.api.event.track;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Track;
|
import me.lucko.luckperms.api.Track;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a track is created
|
* Called when a track is created
|
||||||
@@ -41,15 +42,13 @@ public interface TrackCreateEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the new track
|
* @return the new track
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) Track getTrack();
|
||||||
Track getTrack();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the cause of the creation
|
* Gets the cause of the creation
|
||||||
*
|
*
|
||||||
* @return the cause of the creation
|
* @return the cause of the creation
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) CreationCause getCause();
|
||||||
CreationCause getCause();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,11 +26,12 @@
|
|||||||
package me.lucko.luckperms.api.event.track;
|
package me.lucko.luckperms.api.event.track;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
||||||
|
|
||||||
import java.util.List;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a track is deleted
|
* Called when a track is deleted
|
||||||
@@ -42,23 +43,20 @@ public interface TrackDeleteEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the name of the deleted track
|
* @return the name of the deleted track
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) String getTrackName();
|
||||||
String getTrackName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an immutable copy of the tracks existing data
|
* Gets an immutable copy of the tracks existing data
|
||||||
*
|
*
|
||||||
* @return a copy of the tracks existing data
|
* @return a copy of the tracks existing data
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) List<String> getExistingData();
|
||||||
List<String> getExistingData();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the cause of the deletion
|
* Gets the cause of the deletion
|
||||||
*
|
*
|
||||||
* @return the cause of the deletion
|
* @return the cause of the deletion
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(2) DeletionCause getCause();
|
||||||
DeletionCause getCause();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,8 +27,9 @@ package me.lucko.luckperms.api.event.track;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Track;
|
import me.lucko.luckperms.api.Track;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a track is loaded into memory from the storage.
|
* Called when a track is loaded into memory from the storage.
|
||||||
@@ -42,7 +43,6 @@ public interface TrackLoadEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the track that was loaded
|
* @return the track that was loaded
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) Track getTrack();
|
||||||
Track getTrack();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,9 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api.event.track.mutate;
|
package me.lucko.luckperms.api.event.track.mutate;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import me.lucko.luckperms.api.event.Param;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a group is added to a track
|
* Called when a group is added to a track
|
||||||
@@ -37,7 +39,6 @@ public interface TrackAddGroupEvent extends TrackMutateEvent {
|
|||||||
*
|
*
|
||||||
* @return the group that was added
|
* @return the group that was added
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(3) String getGroup();
|
||||||
String getGroup();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,11 +27,12 @@ package me.lucko.luckperms.api.event.track.mutate;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Track;
|
import me.lucko.luckperms.api.Track;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a track is changed
|
* Called when a track is changed
|
||||||
*/
|
*/
|
||||||
@@ -42,23 +43,20 @@ public interface TrackMutateEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the track that was mutated
|
* @return the track that was mutated
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) Track getTrack();
|
||||||
Track getTrack();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an immutable copy of the tracks data before the change
|
* Gets an immutable copy of the tracks data before the change
|
||||||
*
|
*
|
||||||
* @return the data before the change
|
* @return the data before the change
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) List<String> getDataBefore();
|
||||||
List<String> getDataBefore();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an immutable copy of the tracks data after the change
|
* Gets an immutable copy of the tracks data after the change
|
||||||
*
|
*
|
||||||
* @return the data after the change
|
* @return the data after the change
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(2) List<String> getDataAfter();
|
||||||
List<String> getDataAfter();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+4
-3
@@ -25,7 +25,9 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api.event.track.mutate;
|
package me.lucko.luckperms.api.event.track.mutate;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import me.lucko.luckperms.api.event.Param;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a group is removed from a track
|
* Called when a group is removed from a track
|
||||||
@@ -37,7 +39,6 @@ public interface TrackRemoveGroupEvent extends TrackMutateEvent {
|
|||||||
*
|
*
|
||||||
* @return the group that was removed
|
* @return the group that was removed
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(3) String getGroup();
|
||||||
String getGroup();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,11 +28,12 @@ package me.lucko.luckperms.api.event.user;
|
|||||||
import me.lucko.luckperms.api.User;
|
import me.lucko.luckperms.api.User;
|
||||||
import me.lucko.luckperms.api.caching.UserData;
|
import me.lucko.luckperms.api.caching.UserData;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
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 {
|
public interface UserCacheLoadEvent extends LuckPermsEvent {
|
||||||
|
|
||||||
@@ -41,15 +42,13 @@ public interface UserCacheLoadEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the user
|
* @return the user
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) User getUser();
|
||||||
User getUser();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the data that was loaded
|
* Gets the data that was loaded
|
||||||
*
|
*
|
||||||
* @return the loaded data
|
* @return the loaded data
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) UserData getLoadedData();
|
||||||
UserData getLoadedData();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,8 +28,9 @@ package me.lucko.luckperms.api.event.user;
|
|||||||
import me.lucko.luckperms.api.User;
|
import me.lucko.luckperms.api.User;
|
||||||
import me.lucko.luckperms.api.caching.UserData;
|
import me.lucko.luckperms.api.caching.UserData;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a users cached data is refreshed
|
* Called when a users cached data is refreshed
|
||||||
@@ -41,15 +42,13 @@ public interface UserDataRecalculateEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the user
|
* @return the user
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) User getUser();
|
||||||
User getUser();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the data that was recalculated
|
* Gets the data that was recalculated
|
||||||
*
|
*
|
||||||
* @return the data
|
* @return the data
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) UserData getData();
|
||||||
UserData getData();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,11 +26,12 @@
|
|||||||
package me.lucko.luckperms.api.event.user;
|
package me.lucko.luckperms.api.event.user;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
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;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the user logs into the network for the first time.
|
* Called when the user logs into the network for the first time.
|
||||||
*
|
*
|
||||||
@@ -49,15 +50,13 @@ public interface UserFirstLoginEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the uuid of the user
|
* @return the uuid of the user
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) UUID getUuid();
|
||||||
UUID getUuid();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the username of the user
|
* Gets the username of the user
|
||||||
*
|
*
|
||||||
* @return the username of the user
|
* @return the username of the user
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) String getUsername();
|
||||||
String getUsername();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,8 +27,9 @@ package me.lucko.luckperms.api.event.user;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.User;
|
import me.lucko.luckperms.api.User;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a user is loaded into memory from the storage.
|
* Called when a user is loaded into memory from the storage.
|
||||||
@@ -40,7 +41,6 @@ public interface UserLoadEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the user that was loaded
|
* @return the user that was loaded
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) User getUser();
|
||||||
User getUser();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api.event.user.track;
|
package me.lucko.luckperms.api.event.user.track;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a user is demoted down a track.
|
* Called when a user is demoted down a track.
|
||||||
*
|
*
|
||||||
@@ -32,4 +34,8 @@ package me.lucko.luckperms.api.event.user.track;
|
|||||||
*/
|
*/
|
||||||
public interface UserDemoteEvent extends UserTrackEvent {
|
public interface UserDemoteEvent extends UserTrackEvent {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default @NonNull TrackAction getAction() {
|
||||||
|
return TrackAction.DEMOTION;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api.event.user.track;
|
package me.lucko.luckperms.api.event.user.track;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a user is promoted up a track.
|
* Called when a user is promoted up a track.
|
||||||
*
|
*
|
||||||
@@ -32,4 +34,8 @@ package me.lucko.luckperms.api.event.user.track;
|
|||||||
*/
|
*/
|
||||||
public interface UserPromoteEvent extends UserTrackEvent {
|
public interface UserPromoteEvent extends UserTrackEvent {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default @NonNull TrackAction getAction() {
|
||||||
|
return TrackAction.PROMOTION;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -28,11 +28,12 @@ package me.lucko.luckperms.api.event.user.track;
|
|||||||
import me.lucko.luckperms.api.Track;
|
import me.lucko.luckperms.api.Track;
|
||||||
import me.lucko.luckperms.api.User;
|
import me.lucko.luckperms.api.User;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import me.lucko.luckperms.api.event.Param;
|
||||||
import me.lucko.luckperms.api.event.Sourced;
|
import me.lucko.luckperms.api.event.Sourced;
|
||||||
|
|
||||||
import java.util.Optional;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a user interacts with a track through a promotion or demotion
|
* Called when a user interacts with a track through a promotion or demotion
|
||||||
@@ -44,24 +45,21 @@ public interface UserTrackEvent extends LuckPermsEvent, Sourced {
|
|||||||
*
|
*
|
||||||
* @return the track involved in the event
|
* @return the track involved in the event
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(0) Track getTrack();
|
||||||
Track getTrack();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the user who was promoted or demoted
|
* Gets the user who was promoted or demoted
|
||||||
*
|
*
|
||||||
* @return the user involved in the event
|
* @return the user involved in the event
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(1) User getUser();
|
||||||
User getUser();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the action performed
|
* Gets the action performed
|
||||||
*
|
*
|
||||||
* @return the action performed
|
* @return the action performed
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull TrackAction getAction();
|
||||||
TrackAction getAction();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the group the user was promoted/demoted from.
|
* Gets the group the user was promoted/demoted from.
|
||||||
@@ -70,15 +68,13 @@ public interface UserTrackEvent extends LuckPermsEvent, Sourced {
|
|||||||
*
|
*
|
||||||
* @return the group the user was promoted/demoted from
|
* @return the group the user was promoted/demoted from
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(2) Optional<String> getGroupFrom();
|
||||||
Optional<String> getGroupFrom();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the group the user was promoted/demoted to
|
* Gets the group the user was promoted/demoted to
|
||||||
*
|
*
|
||||||
* @return the group the user was promoted/demoted to
|
* @return the group the user was promoted/demoted to
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull @Param(3) Optional<String> getGroupTo();
|
||||||
Optional<String> getGroupTo();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[email protected]>
|
||||||
|
* 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.manager;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.Group;
|
||||||
|
import me.lucko.luckperms.api.User;
|
||||||
|
import me.lucko.luckperms.api.caching.CachedData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an object responsible for managing {@link CachedData} instances.
|
||||||
|
*
|
||||||
|
* @since 4.5
|
||||||
|
*/
|
||||||
|
public interface CachedDataManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidate the {@link CachedData} instances for all loaded {@link User}s.
|
||||||
|
*
|
||||||
|
* @see CachedData#invalidate()
|
||||||
|
*/
|
||||||
|
void invalidateAllUserCaches();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidate the {@link CachedData} instances for all loaded {@link Group}s.
|
||||||
|
*
|
||||||
|
* @see CachedData#invalidate()
|
||||||
|
*/
|
||||||
|
void invalidateAllGroupCaches();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -29,6 +29,9 @@ import me.lucko.luckperms.api.Group;
|
|||||||
import me.lucko.luckperms.api.HeldPermission;
|
import me.lucko.luckperms.api.HeldPermission;
|
||||||
import me.lucko.luckperms.api.Storage;
|
import me.lucko.luckperms.api.Storage;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -36,9 +39,6 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the object responsible for managing {@link Group} instances.
|
* Represents the object responsible for managing {@link Group} instances.
|
||||||
*
|
*
|
||||||
@@ -74,8 +74,7 @@ public interface GroupManager {
|
|||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Group> createAndLoadGroup(@NonNull String name);
|
||||||
CompletableFuture<Group> createAndLoadGroup(@Nonnull String name);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a group from the plugin's storage provider into memory.
|
* Loads a group from the plugin's storage provider into memory.
|
||||||
@@ -95,8 +94,7 @@ public interface GroupManager {
|
|||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Optional<Group>> loadGroup(@NonNull String name);
|
||||||
CompletableFuture<Optional<Group>> loadGroup(@Nonnull String name);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a group's data back to the plugin's storage provider.
|
* Saves a group's data back to the plugin's storage provider.
|
||||||
@@ -115,8 +113,7 @@ public interface GroupManager {
|
|||||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Void> saveGroup(@NonNull Group group);
|
||||||
CompletableFuture<Void> saveGroup(@Nonnull Group group);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permanently deletes a group from the plugin's storage provider.
|
* Permanently deletes a group from the plugin's storage provider.
|
||||||
@@ -127,15 +124,13 @@ public interface GroupManager {
|
|||||||
* <p>Unlike the method in {@link Storage}, when a group cannot be deleted,
|
* <p>Unlike the method in {@link Storage}, when a group cannot be deleted,
|
||||||
* the future will be {@link CompletableFuture completed exceptionally}.</p>
|
* the future will be {@link CompletableFuture completed exceptionally}.</p>
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param group the group to delete
|
* @param group the group to delete
|
||||||
* @return a future to encapsulate the operation.
|
* @return a future to encapsulate the operation.
|
||||||
* @throws NullPointerException if group is null
|
* @throws NullPointerException if group is null
|
||||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Void> deleteGroup(@NonNull Group group);
|
||||||
CompletableFuture<Void> deleteGroup(@Nonnull Group group);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all groups into memory.
|
* Loads all groups into memory.
|
||||||
@@ -149,8 +144,7 @@ public interface GroupManager {
|
|||||||
* @return a future to encapsulate the operation.
|
* @return a future to encapsulate the operation.
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Void> loadAllGroups();
|
||||||
CompletableFuture<Void> loadAllGroups();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for a list of groups with a given permission.
|
* Searches for a list of groups with a given permission.
|
||||||
@@ -160,8 +154,7 @@ public interface GroupManager {
|
|||||||
* @throws NullPointerException if the permission is null
|
* @throws NullPointerException if the permission is null
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<List<HeldPermission<String>>> getWithPermission(@NonNull String permission);
|
||||||
CompletableFuture<List<HeldPermission<String>>> getWithPermission(@Nonnull String permission);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a loaded group.
|
* Gets a loaded group.
|
||||||
@@ -170,8 +163,7 @@ public interface GroupManager {
|
|||||||
* @return a {@link Group} object, if one matching the name exists, or null if not
|
* @return a {@link Group} object, if one matching the name exists, or null if not
|
||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable Group getGroup(@NonNull String name);
|
||||||
Group getGroup(@Nonnull String name);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a loaded group.
|
* Gets a loaded group.
|
||||||
@@ -182,8 +174,7 @@ public interface GroupManager {
|
|||||||
* @return an optional {@link Group} object
|
* @return an optional {@link Group} object
|
||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull Optional<Group> getGroupOpt(@NonNull String name) {
|
||||||
default Optional<Group> getGroupOpt(@Nonnull String name) {
|
|
||||||
return Optional.ofNullable(getGroup(name));
|
return Optional.ofNullable(getGroup(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,8 +183,7 @@ public interface GroupManager {
|
|||||||
*
|
*
|
||||||
* @return a {@link Set} of {@link Group} objects
|
* @return a {@link Set} of {@link Group} objects
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Set<Group> getLoadedGroups();
|
||||||
Set<Group> getLoadedGroups();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a group is loaded in memory
|
* Check if a group is loaded in memory
|
||||||
@@ -202,6 +192,6 @@ public interface GroupManager {
|
|||||||
* @return true if the group is loaded
|
* @return true if the group is loaded
|
||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
*/
|
*/
|
||||||
boolean isLoaded(@Nonnull String name);
|
boolean isLoaded(@NonNull String name);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,15 +28,15 @@ package me.lucko.luckperms.api.manager;
|
|||||||
import me.lucko.luckperms.api.Storage;
|
import me.lucko.luckperms.api.Storage;
|
||||||
import me.lucko.luckperms.api.Track;
|
import me.lucko.luckperms.api.Track;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the object responsible for managing {@link Track} instances.
|
* Represents the object responsible for managing {@link Track} instances.
|
||||||
*
|
*
|
||||||
@@ -72,8 +72,7 @@ public interface TrackManager {
|
|||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Track> createAndLoadTrack(@NonNull String name);
|
||||||
CompletableFuture<Track> createAndLoadTrack(@Nonnull String name);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a track from the plugin's storage provider into memory.
|
* Loads a track from the plugin's storage provider into memory.
|
||||||
@@ -93,8 +92,7 @@ public interface TrackManager {
|
|||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Optional<Track>> loadTrack(@NonNull String name);
|
||||||
CompletableFuture<Optional<Track>> loadTrack(@Nonnull String name);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a track's data back to the plugin's storage provider.
|
* Saves a track's data back to the plugin's storage provider.
|
||||||
@@ -113,8 +111,7 @@ public interface TrackManager {
|
|||||||
* @throws IllegalStateException if the track instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the track instance was not obtained from LuckPerms.
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Void> saveTrack(@NonNull Track track);
|
||||||
CompletableFuture<Void> saveTrack(@Nonnull Track track);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permanently deletes a track from the plugin's storage provider.
|
* Permanently deletes a track from the plugin's storage provider.
|
||||||
@@ -125,15 +122,13 @@ public interface TrackManager {
|
|||||||
* <p>Unlike the method in {@link Storage}, when a track cannot be deleted,
|
* <p>Unlike the method in {@link Storage}, when a track cannot be deleted,
|
||||||
* the future will be {@link CompletableFuture completed exceptionally}.</p>
|
* the future will be {@link CompletableFuture completed exceptionally}.</p>
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param track the track to delete
|
* @param track the track to delete
|
||||||
* @return a future to encapsulate the operation.
|
* @return a future to encapsulate the operation.
|
||||||
* @throws NullPointerException if track is null
|
* @throws NullPointerException if track is null
|
||||||
* @throws IllegalStateException if the track instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the track instance was not obtained from LuckPerms.
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Void> deleteTrack(@NonNull Track track);
|
||||||
CompletableFuture<Void> deleteTrack(@Nonnull Track track);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all tracks into memory.
|
* Loads all tracks into memory.
|
||||||
@@ -147,8 +142,7 @@ public interface TrackManager {
|
|||||||
* @return a future to encapsulate the operation.
|
* @return a future to encapsulate the operation.
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Void> loadAllTracks();
|
||||||
CompletableFuture<Void> loadAllTracks();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a loaded track.
|
* Gets a loaded track.
|
||||||
@@ -157,8 +151,7 @@ public interface TrackManager {
|
|||||||
* @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
|
* @throws NullPointerException if the name is null
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable Track getTrack(@NonNull String name);
|
||||||
Track getTrack(@Nonnull String name);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a loaded track.
|
* Gets a loaded track.
|
||||||
@@ -169,8 +162,7 @@ public interface TrackManager {
|
|||||||
* @return an optional {@link Track} object
|
* @return an optional {@link Track} object
|
||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull Optional<Track> getTrackOpt(@NonNull String name) {
|
||||||
default Optional<Track> getTrackOpt(@Nonnull String name) {
|
|
||||||
return Optional.ofNullable(getTrack(name));
|
return Optional.ofNullable(getTrack(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,8 +171,7 @@ public interface TrackManager {
|
|||||||
*
|
*
|
||||||
* @return a {@link Set} of {@link Track} objects
|
* @return a {@link Set} of {@link Track} objects
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Set<Track> getLoadedTracks();
|
||||||
Set<Track> getLoadedTracks();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a track is loaded in memory
|
* Check if a track is loaded in memory
|
||||||
@@ -189,6 +180,6 @@ public interface TrackManager {
|
|||||||
* @return true if the track is loaded
|
* @return true if the track is loaded
|
||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
*/
|
*/
|
||||||
boolean isLoaded(@Nonnull String name);
|
boolean isLoaded(@NonNull String name);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -30,6 +30,9 @@ import me.lucko.luckperms.api.PlayerSaveResult;
|
|||||||
import me.lucko.luckperms.api.Storage;
|
import me.lucko.luckperms.api.Storage;
|
||||||
import me.lucko.luckperms.api.User;
|
import me.lucko.luckperms.api.User;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -38,9 +41,6 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the object responsible for managing {@link User} instances.
|
* Represents the object responsible for managing {@link User} instances.
|
||||||
*
|
*
|
||||||
@@ -71,14 +71,13 @@ public interface UserManager {
|
|||||||
* <p>Unlike the method in {@link Storage}, when a user cannot be loaded,
|
* <p>Unlike the method in {@link Storage}, when a user cannot be loaded,
|
||||||
* the future will be {@link CompletableFuture completed exceptionally}.</p>
|
* the future will be {@link CompletableFuture completed exceptionally}.</p>
|
||||||
*
|
*
|
||||||
* @param uuid the uuid of the user
|
* @param uuid the uuid of the user
|
||||||
* @param username the username, if known
|
* @param username the username, if known
|
||||||
* @return the resultant user
|
* @return the resultant user
|
||||||
* @throws NullPointerException if the uuid is null
|
* @throws NullPointerException if the uuid is null
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<User> loadUser(@NonNull UUID uuid, @Nullable String username);
|
||||||
CompletableFuture<User> loadUser(@Nonnull UUID uuid, @Nullable String username);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a user from the plugin's storage provider into memory.
|
* Loads a user from the plugin's storage provider into memory.
|
||||||
@@ -95,8 +94,7 @@ public interface UserManager {
|
|||||||
* @throws NullPointerException if the uuid is null
|
* @throws NullPointerException if the uuid is null
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull CompletableFuture<User> loadUser(@NonNull UUID uuid) {
|
||||||
default CompletableFuture<User> loadUser(@Nonnull UUID uuid) {
|
|
||||||
return loadUser(uuid, null);
|
return loadUser(uuid, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,8 +109,7 @@ public interface UserManager {
|
|||||||
* @throws IllegalArgumentException if the username is invalid
|
* @throws IllegalArgumentException if the username is invalid
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<UUID> lookupUuid(@NonNull String username);
|
||||||
CompletableFuture<UUID> lookupUuid(@Nonnull String username);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses the LuckPerms cache to find a username for the given uuid.
|
* Uses the LuckPerms cache to find a username for the given uuid.
|
||||||
@@ -123,8 +120,7 @@ public interface UserManager {
|
|||||||
* @throws IllegalArgumentException if the username is invalid
|
* @throws IllegalArgumentException if the username is invalid
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<String> lookupUsername(@NonNull UUID uuid);
|
||||||
CompletableFuture<String> lookupUsername(@Nonnull UUID uuid);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a user's data back to the plugin's storage provider.
|
* Saves a user's data back to the plugin's storage provider.
|
||||||
@@ -143,8 +139,7 @@ public interface UserManager {
|
|||||||
* @throws IllegalStateException if the user instance was not obtained from LuckPerms.
|
* @throws IllegalStateException if the user instance was not obtained from LuckPerms.
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Void> saveUser(@NonNull User user);
|
||||||
CompletableFuture<Void> saveUser(@Nonnull User user);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves data about a player to the uuid caching system.
|
* Saves data about a player to the uuid caching system.
|
||||||
@@ -156,8 +151,7 @@ public interface UserManager {
|
|||||||
* @throws IllegalArgumentException if the username is invalid
|
* @throws IllegalArgumentException if the username is invalid
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<PlayerSaveResult> savePlayerData(@NonNull UUID uuid, @NonNull String username);
|
||||||
CompletableFuture<PlayerSaveResult> savePlayerData(@Nonnull UUID uuid, @Nonnull String username);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a set all "unique" user UUIDs.
|
* Gets a set all "unique" user UUIDs.
|
||||||
@@ -167,8 +161,7 @@ public interface UserManager {
|
|||||||
* @return a set of uuids
|
* @return a set of uuids
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<Set<UUID>> getUniqueUsers();
|
||||||
CompletableFuture<Set<UUID>> getUniqueUsers();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for a list of users with a given permission.
|
* Searches for a list of users with a given permission.
|
||||||
@@ -178,8 +171,7 @@ public interface UserManager {
|
|||||||
* @throws NullPointerException if the permission is null
|
* @throws NullPointerException if the permission is null
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull CompletableFuture<List<HeldPermission<UUID>>> getWithPermission(@NonNull String permission);
|
||||||
CompletableFuture<List<HeldPermission<UUID>>> getWithPermission(@Nonnull String permission);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a loaded user.
|
* Gets a loaded user.
|
||||||
@@ -188,8 +180,7 @@ public interface UserManager {
|
|||||||
* @return a {@link User} object, if one matching the uuid is loaded, or null if not
|
* @return a {@link User} object, if one matching the uuid is loaded, or null if not
|
||||||
* @throws NullPointerException if the uuid is null
|
* @throws NullPointerException if the uuid is null
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable User getUser(@NonNull UUID uuid);
|
||||||
User getUser(@Nonnull UUID uuid);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a loaded user.
|
* Gets a loaded user.
|
||||||
@@ -198,8 +189,7 @@ public interface UserManager {
|
|||||||
* @return an optional {@link User} object
|
* @return an optional {@link User} object
|
||||||
* @throws NullPointerException if the uuid is null
|
* @throws NullPointerException if the uuid is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull Optional<User> getUserOpt(@NonNull UUID uuid) {
|
||||||
default Optional<User> getUserOpt(@Nonnull UUID uuid) {
|
|
||||||
return Optional.ofNullable(getUser(uuid));
|
return Optional.ofNullable(getUser(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,8 +200,7 @@ public interface UserManager {
|
|||||||
* @return a {@link User} object, if one matching the uuid is loaded, or null if not
|
* @return a {@link User} object, if one matching the uuid is loaded, or null if not
|
||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable User getUser(@NonNull String name);
|
||||||
User getUser(@Nonnull String name);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a loaded user.
|
* Gets a loaded user.
|
||||||
@@ -220,8 +209,7 @@ public interface UserManager {
|
|||||||
* @return an optional {@link User} object
|
* @return an optional {@link User} object
|
||||||
* @throws NullPointerException if the name is null
|
* @throws NullPointerException if the name is null
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
default @NonNull Optional<User> getUserOpt(@NonNull String name) {
|
||||||
default Optional<User> getUserOpt(@Nonnull String name) {
|
|
||||||
return Optional.ofNullable(getUser(name));
|
return Optional.ofNullable(getUser(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,8 +218,7 @@ public interface UserManager {
|
|||||||
*
|
*
|
||||||
* @return a {@link Set} of {@link User} objects
|
* @return a {@link Set} of {@link User} objects
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Set<User> getLoadedUsers();
|
||||||
Set<User> getLoadedUsers();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a user is loaded in memory
|
* Check if a user is loaded in memory
|
||||||
@@ -240,7 +227,7 @@ public interface UserManager {
|
|||||||
* @return true if the user is loaded
|
* @return true if the user is loaded
|
||||||
* @throws NullPointerException if the uuid is null
|
* @throws NullPointerException if the uuid is null
|
||||||
*/
|
*/
|
||||||
boolean isLoaded(@Nonnull UUID uuid);
|
boolean isLoaded(@NonNull UUID uuid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unload a user from the internal storage, if they're not currently online.
|
* Unload a user from the internal storage, if they're not currently online.
|
||||||
@@ -248,6 +235,6 @@ public interface UserManager {
|
|||||||
* @param user the user to unload
|
* @param user the user to unload
|
||||||
* @throws NullPointerException if the user is null
|
* @throws NullPointerException if the user is null
|
||||||
*/
|
*/
|
||||||
void cleanupUser(@Nonnull User user);
|
void cleanupUser(@NonNull User user);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,11 +28,11 @@ package me.lucko.luckperms.api.messenger;
|
|||||||
import me.lucko.luckperms.api.messenger.message.Message;
|
import me.lucko.luckperms.api.messenger.message.Message;
|
||||||
import me.lucko.luckperms.api.messenger.message.OutgoingMessage;
|
import me.lucko.luckperms.api.messenger.message.OutgoingMessage;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates the LuckPerms system which accepts incoming {@link Message}s
|
* Encapsulates the LuckPerms system which accepts incoming {@link Message}s
|
||||||
* from implementations of {@link MessengerProvider}.
|
* from implementations of {@link Messenger}.
|
||||||
*
|
*
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
@@ -52,7 +52,7 @@ public interface IncomingMessageConsumer {
|
|||||||
* @param message the message
|
* @param message the message
|
||||||
* @return true if the message was accepted by the plugin
|
* @return true if the message was accepted by the plugin
|
||||||
*/
|
*/
|
||||||
boolean consumeIncomingMessage(@Nonnull Message message);
|
boolean consumeIncomingMessage(@NonNull Message message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consumes a message in an encoded string format.
|
* Consumes a message in an encoded string format.
|
||||||
@@ -73,6 +73,6 @@ public interface IncomingMessageConsumer {
|
|||||||
* @param encodedString the encoded string
|
* @param encodedString the encoded string
|
||||||
* @return true if the message was accepted by the plugin
|
* @return true if the message was accepted by the plugin
|
||||||
*/
|
*/
|
||||||
boolean consumeIncomingMessageAsString(@Nonnull String encodedString);
|
boolean consumeIncomingMessageAsString(@NonNull String encodedString);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ package me.lucko.luckperms.api.messenger;
|
|||||||
import me.lucko.luckperms.api.messenger.message.Message;
|
import me.lucko.luckperms.api.messenger.message.Message;
|
||||||
import me.lucko.luckperms.api.messenger.message.OutgoingMessage;
|
import me.lucko.luckperms.api.messenger.message.OutgoingMessage;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an object which dispatches {@link OutgoingMessage}s.
|
* Represents an object which dispatches {@link OutgoingMessage}s.
|
||||||
@@ -45,12 +45,18 @@ public interface Messenger extends AutoCloseable {
|
|||||||
* of the interfaces extending {@link Message} in the
|
* of the interfaces extending {@link Message} in the
|
||||||
* 'api.messenger.message.type' package.</p>
|
* 'api.messenger.message.type' package.</p>
|
||||||
*
|
*
|
||||||
|
* <p>3rd party implementations are encouraged to implement this method with consideration
|
||||||
|
* that new types may be added in the future.</p>
|
||||||
|
*
|
||||||
* <p>This call is always made async.</p>
|
* <p>This call is always made async.</p>
|
||||||
*
|
*
|
||||||
* @param outgoingMessage the outgoing message
|
* @param outgoingMessage the outgoing message
|
||||||
*/
|
*/
|
||||||
void sendOutgoingMessage(@Nonnull OutgoingMessage outgoingMessage);
|
void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs the necessary action to gracefully shutdown the messenger.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
default void close() {
|
default void close() {
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ package me.lucko.luckperms.api.messenger;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.LuckPermsApi;
|
import me.lucko.luckperms.api.LuckPermsApi;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a provider for {@link Messenger} instances.
|
* Represents a provider for {@link Messenger} instances.
|
||||||
@@ -35,8 +35,8 @@ import javax.annotation.Nonnull;
|
|||||||
* <p>Users wishing to provide their own implementation for the plugins
|
* <p>Users wishing to provide their own implementation for the plugins
|
||||||
* "Messaging Service" should implement and register this interface.</p>
|
* "Messaging Service" should implement and register this interface.</p>
|
||||||
*
|
*
|
||||||
* @since 4.1
|
|
||||||
* @see LuckPermsApi#registerMessengerProvider(MessengerProvider)
|
* @see LuckPermsApi#registerMessengerProvider(MessengerProvider)
|
||||||
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
public interface MessengerProvider {
|
public interface MessengerProvider {
|
||||||
|
|
||||||
@@ -45,8 +45,7 @@ public interface MessengerProvider {
|
|||||||
*
|
*
|
||||||
* @return the provider name
|
* @return the provider name
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getName();
|
||||||
String getName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new {@link Messenger} instance, which passes
|
* Creates and returns a new {@link Messenger} instance, which passes
|
||||||
@@ -59,7 +58,6 @@ public interface MessengerProvider {
|
|||||||
* incoming messages to
|
* incoming messages to
|
||||||
* @return a new messenger agent instance
|
* @return a new messenger agent instance
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull Messenger obtain(@NonNull IncomingMessageConsumer incomingMessageConsumer);
|
||||||
Messenger obtain(@Nonnull IncomingMessageConsumer incomingMessageConsumer);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,9 +27,9 @@ package me.lucko.luckperms.api.messenger.message;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.messenger.Messenger;
|
import me.lucko.luckperms.api.messenger.Messenger;
|
||||||
|
|
||||||
import java.util.UUID;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a message sent received via a {@link Messenger}.
|
* Represents a message sent received via a {@link Messenger}.
|
||||||
@@ -46,7 +46,6 @@ public interface Message {
|
|||||||
*
|
*
|
||||||
* @return the id of the message
|
* @return the id of the message
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull UUID getId();
|
||||||
UUID getId();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ package me.lucko.luckperms.api.messenger.message;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.messenger.IncomingMessageConsumer;
|
import me.lucko.luckperms.api.messenger.IncomingMessageConsumer;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an outgoing {@link Message}.
|
* Represents an outgoing {@link Message}.
|
||||||
@@ -56,7 +56,6 @@ public interface OutgoingMessage extends Message {
|
|||||||
*
|
*
|
||||||
* @return an encoded string form of the message
|
* @return an encoded string form of the message
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String asEncodedString();
|
||||||
String asEncodedString();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ package me.lucko.luckperms.api.messenger.message.type;
|
|||||||
import me.lucko.luckperms.api.LogEntry;
|
import me.lucko.luckperms.api.LogEntry;
|
||||||
import me.lucko.luckperms.api.messenger.message.Message;
|
import me.lucko.luckperms.api.messenger.message.Message;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an "log" message.
|
* Represents an "log" message.
|
||||||
@@ -44,7 +44,6 @@ public interface LogMessage extends Message {
|
|||||||
*
|
*
|
||||||
* @return the log entry
|
* @return the log entry
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull LogEntry getLogEntry();
|
||||||
LogEntry getLogEntry();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+3
-4
@@ -27,9 +27,9 @@ package me.lucko.luckperms.api.messenger.message.type;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.messenger.message.Message;
|
import me.lucko.luckperms.api.messenger.message.Message;
|
||||||
|
|
||||||
import java.util.UUID;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an "user update" message.
|
* Represents an "user update" message.
|
||||||
@@ -45,7 +45,6 @@ public interface UserUpdateMessage extends Message {
|
|||||||
*
|
*
|
||||||
* @return the user
|
* @return the user
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull UUID getUser();
|
||||||
UUID getUser();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[email protected]>
|
||||||
|
* 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.metastacking;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Functional interface which removes duplicate entries from a list.
|
||||||
|
*
|
||||||
|
* <p>Used by LuckPerms to remove duplicate entries from a MetaStack.</p>
|
||||||
|
*
|
||||||
|
* @since 4.4
|
||||||
|
*/
|
||||||
|
public interface DuplicateRemovalFunction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes duplicates from the given list, according to the behaviour
|
||||||
|
* of the function.
|
||||||
|
*
|
||||||
|
* @param list the entries
|
||||||
|
* @param <T> the type of entries
|
||||||
|
*/
|
||||||
|
<T> void processDuplicates(@NonNull List<T> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link DuplicateRemovalFunction} that does not remove duplicates.
|
||||||
|
*/
|
||||||
|
DuplicateRemovalFunction RETAIN_ALL = new DuplicateRemovalFunction() {
|
||||||
|
@Override
|
||||||
|
public <T> void processDuplicates(@NonNull List<T> list) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "DuplicateRemovalFunction#RETAIN_ALL";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link DuplicateRemovalFunction} that retains only the first occurrence.
|
||||||
|
*/
|
||||||
|
DuplicateRemovalFunction FIRST_ONLY = new DuplicateRemovalFunction() {
|
||||||
|
@SuppressWarnings("Java8CollectionRemoveIf")
|
||||||
|
@Override
|
||||||
|
public <T> void processDuplicates(@NonNull List<T> list) {
|
||||||
|
Set<T> seen = new HashSet<>();
|
||||||
|
for (ListIterator<T> it = list.listIterator(); it.hasNext(); ) {
|
||||||
|
T next = it.next();
|
||||||
|
if (!seen.add(next)) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "DuplicateRemovalFunction#FIRST_ONLY";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link DuplicateRemovalFunction} that retains only the last occurrence.
|
||||||
|
*/
|
||||||
|
DuplicateRemovalFunction LAST_ONLY = new DuplicateRemovalFunction() {
|
||||||
|
@Override
|
||||||
|
public <T> void processDuplicates(@NonNull List<T> list) {
|
||||||
|
Set<T> seen = new HashSet<>();
|
||||||
|
for (ListIterator<T> it = list.listIterator(list.size()); it.hasPrevious(); ) {
|
||||||
|
T next = it.previous();
|
||||||
|
if (!seen.add(next)) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "DuplicateRemovalFunction#LAST_ONLY";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
@@ -25,10 +25,9 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api.metastacking;
|
package me.lucko.luckperms.api.metastacking;
|
||||||
|
|
||||||
import java.util.List;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.List;
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a meta stack model, consisting of a chain of elements, separated by spacers.
|
* Represents a meta stack model, consisting of a chain of elements, separated by spacers.
|
||||||
@@ -41,7 +40,6 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
*
|
*
|
||||||
* @since 2.3
|
* @since 2.3
|
||||||
*/
|
*/
|
||||||
@Immutable
|
|
||||||
public interface MetaStackDefinition {
|
public interface MetaStackDefinition {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,31 +47,36 @@ public interface MetaStackDefinition {
|
|||||||
*
|
*
|
||||||
* @return the elements in this stack
|
* @return the elements in this stack
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull List<MetaStackElement> getElements();
|
||||||
List<MetaStackElement> getElements();
|
|
||||||
|
/**
|
||||||
|
* Gets the duplicate removal function, applied to the entries before
|
||||||
|
* formatting takes place.
|
||||||
|
*
|
||||||
|
* @return the duplicate removal function
|
||||||
|
* @since 4.4
|
||||||
|
*/
|
||||||
|
@NonNull DuplicateRemovalFunction getDuplicateRemovalFunction();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the spacer string added before any stack elements
|
* Gets the spacer string added before any stack elements
|
||||||
*
|
*
|
||||||
* @return the start spacer
|
* @return the start spacer
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getStartSpacer();
|
||||||
String getStartSpacer();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the spacer added between stack elements
|
* Gets the spacer added between stack elements
|
||||||
*
|
*
|
||||||
* @return the middle spacer
|
* @return the middle spacer
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getMiddleSpacer();
|
||||||
String getMiddleSpacer();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the spacer added after any stack elements
|
* Gets the spacer added after any stack elements
|
||||||
*
|
*
|
||||||
* @return the end spacer
|
* @return the end spacer
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NonNull String getEndSpacer();
|
||||||
String getEndSpacer();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loaded 100 of 718 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user