mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2026-11-25 12:14:21 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f54e57d43 | ||
|
|
d150bd39a5 | ||
|
|
f813122468 | ||
|
|
2e62c98c45 | ||
|
|
f0e1a8f092 | ||
|
|
2dc6902001 | ||
|
|
21f5c24847 | ||
|
|
6b2c4bca58 | ||
|
|
4564a97371 | ||
|
|
1df66255e4 | ||
|
|
1c7e2dfb8c | ||
|
|
ad1ba3c126 | ||
|
|
0f63b024e4 | ||
|
|
a17b441165 | ||
|
|
e3138eb94c | ||
|
|
53bb61f9b2 | ||
|
|
370e2aed0d | ||
|
|
b7f05a2f91 | ||
|
|
bb01c74642 | ||
|
|
ba71345cbd | ||
|
|
2c636c5ac6 | ||
|
|
0884dd7e97 | ||
|
|
c948632dfa | ||
|
|
9647b7de43 | ||
|
|
e7f2a8d713 | ||
|
|
bf0ac1a867 | ||
|
|
89894353b6 | ||
|
|
ca65e2175d | ||
|
|
84c5b818b8 | ||
|
|
843eaaed0c | ||
|
|
4ff2c75538 | ||
|
|
734b011dc7 | ||
|
|
4018493285 | ||
|
|
435e039b38 | ||
|
|
7579bbe549 | ||
|
|
16ee500054 | ||
|
|
88f040e822 | ||
|
|
a766c0e9aa | ||
|
|
40e8038604 | ||
|
|
3c4091018c | ||
|
|
75d8f00400 | ||
|
|
cb5f403043 | ||
|
|
997e3c7ef7 | ||
|
|
cb9e0899fc | ||
|
|
ab009ed110 | ||
|
|
c8b89f245e | ||
|
|
d8aefd23d3 | ||
|
|
a8dfd38fe6 | ||
|
|
b7ac05a0a5 | ||
|
|
b8e044c4e3 | ||
|
|
b708d04141 | ||
|
|
d485017744 | ||
|
|
35f5944d7b | ||
|
|
d12be01ecd | ||
|
|
8043b84dc4 | ||
|
|
284e260bc2 | ||
|
|
ec296460b2 | ||
|
|
20fee360fb | ||
|
|
cd496fdc39 | ||
|
|
f9030825fd | ||
|
|
0a92597767 | ||
|
|
6c34da6b32 | ||
|
|
d5cefac65d | ||
|
|
2a44572fb2 | ||
|
|
73230bc9b6 | ||
|
|
be1b9d45fa | ||
|
|
238a4fba75 | ||
|
|
33e412f663 | ||
|
|
c904ede972 | ||
|
|
489c09ddfc | ||
|
|
505c073c8e | ||
|
|
443ea510bb | ||
|
|
848c36928f | ||
|
|
21abb94796 | ||
|
|
0a99a96188 | ||
|
|
a8b1dc8c07 | ||
|
|
c3581c00d3 | ||
|
|
8124a17adb | ||
|
|
68167490d4 | ||
|
|
657cf2a45e | ||
|
|
d83559b949 | ||
|
|
8167fbf73f | ||
|
|
8dfeef9575 | ||
|
|
5c44333892 | ||
|
|
142cdc8e89 | ||
|
|
abb608b856 | ||
|
|
c28b1949a9 | ||
|
|
8ef871f6db | ||
|
|
fa89236e48 | ||
|
|
2d4af4c691 | ||
|
|
16fbf566f3 | ||
|
|
e6a5cb06af | ||
|
|
7bc422c83f | ||
|
|
478fddc486 | ||
|
|
97d1deec9c | ||
|
|
45188c6334 | ||
|
|
17f67f6e13 | ||
|
|
39a5ccf9a9 | ||
|
|
5fbb80f16a | ||
|
|
798a539024 | ||
|
|
645efb0e5b | ||
|
|
5bfbf26e2f | ||
|
|
7d7d40b087 | ||
|
|
e183f520d6 | ||
|
|
727c2f92c3 | ||
|
|
fdd3b117f1 | ||
|
|
8a38c5f4b7 | ||
|
|
53fb46ee85 | ||
|
|
d136359cd9 | ||
|
|
d449834767 | ||
|
|
e851234723 | ||
|
|
26f7dfcb24 | ||
|
|
d1b53f65ae | ||
|
|
c39749e526 | ||
|
|
23c7eb79d0 | ||
|
|
9af6dccd9d | ||
|
|
129a10aa60 | ||
|
|
62270bfd93 | ||
|
|
9f8b4b2404 | ||
|
|
00d4a2a1da | ||
|
|
4ce8ea21f9 | ||
|
|
93d0c54687 | ||
|
|
6564cc89f4 | ||
|
|
9796d2421f | ||
|
|
0ea0ce9d26 | ||
|
|
3f04d439b4 | ||
|
|
5bdc798237 | ||
|
|
5d0c578da1 | ||
|
|
7854de8991 | ||
|
|
4c23f93a67 | ||
|
|
7b3beae57f | ||
|
|
15d3000fc1 | ||
|
|
ad174742e9 | ||
|
|
ab0e25a56d | ||
|
|
6b05e47deb | ||
|
|
b9eb022011 | ||
|
|
7d47b31bcb | ||
|
|
f3857090fa | ||
|
|
d7fa9e08f3 | ||
|
|
2c7ff2120c | ||
|
|
703b18e51c | ||
|
|
3b779dbbd3 | ||
|
|
9af397c2bc | ||
|
|
b6e5b0bd47 | ||
|
|
6e7c49488d | ||
|
|
c5841b58a7 | ||
|
|
e8b1214219 | ||
|
|
4811129ab1 | ||
|
|
63878166db | ||
|
|
2ea43d4b2e | ||
|
|
442c7d46f9 | ||
|
|
971bb67b51 | ||
|
|
020aff66aa | ||
|
|
198b86d7c3 | ||
|
|
84e7fd4d09 | ||
|
|
4027129052 | ||
|
|
63f67ca72c | ||
|
|
2adaea2dac | ||
|
|
5e48224c78 | ||
|
|
cc1d8984da | ||
|
|
8d9b4182f4 | ||
|
|
f972113d11 | ||
|
|
4d5a24f2c4 | ||
|
|
e2b575dd24 | ||
|
|
7fae141e33 | ||
|
|
6f90e545fc | ||
|
|
ee3bb22c2c | ||
|
|
361a4d66bc | ||
|
|
e1bac438aa | ||
|
|
ac9706b83f | ||
|
|
fea757887c | ||
|
|
1eab127f50 | ||
|
|
92e008ff0a | ||
|
|
9659333d0e | ||
|
|
d8020e77fe | ||
|
|
232d17436c | ||
|
|
1461651e22 | ||
|
|
ef556f7cf7 | ||
|
|
47ca6b162b | ||
|
|
f72a5cb6b5 | ||
|
|
cd0fd80b33 | ||
|
|
0fd7f643a7 | ||
|
|
6c7c1b67b8 | ||
|
|
4514a17eaf | ||
|
|
adbd2fc81f | ||
|
|
8b506b6a95 | ||
|
|
426c8565fd | ||
|
|
bd6d3ab7c0 | ||
|
|
d12d13d6ea | ||
|
|
cc08390abe | ||
|
|
b460e282b1 | ||
|
|
005d19f2a3 | ||
|
|
8817e17d2c | ||
|
|
0f23b7a460 | ||
|
|
21ae1dbac0 | ||
|
|
6cb0f5e810 | ||
|
|
2ac7d3dfe6 | ||
|
|
bfaa543ecd | ||
|
|
f893b1c632 | ||
|
|
cb5a28f043 | ||
|
|
bd9718c5af | ||
|
|
97a0dbebcb | ||
|
|
df324de9ec | ||
|
|
6fa690a49d | ||
|
|
2bb1aa7511 | ||
|
|
0bef0902c0 | ||
|
|
f10f60e27f | ||
|
|
91337b49ea | ||
|
|
f5e41f7e7e | ||
|
|
fe0e82f285 | ||
|
|
8996cf02af | ||
|
|
e37c77a1be | ||
|
|
11998b2dd6 | ||
|
|
8754123535 | ||
|
|
91d75424f4 | ||
|
|
c5c99abd16 | ||
|
|
6c88f7629e | ||
|
|
98c71739f8 | ||
|
|
25551641fc | ||
|
|
00b701f129 | ||
|
|
ab082aa311 | ||
|
|
dc32c84bb3 | ||
|
|
0bb4161397 | ||
|
|
4a049ca732 | ||
|
|
d5ac45d230 | ||
|
|
6b3e4bdc71 | ||
|
|
5c0d82f306 | ||
|
|
5a6176def5 | ||
|
|
13ebc87b29 | ||
|
|
1ca1bcf1d1 | ||
|
|
ea5a05d770 | ||
|
|
ed85ab1bfd | ||
|
|
c09e4a1aa0 | ||
|
|
ee36fa9d81 | ||
|
|
bfa5fc43cd | ||
|
|
5d6389249a | ||
|
|
637cb0d836 | ||
|
|
bfebe6a5d0 | ||
|
|
4cbbbd390f | ||
|
|
c120fa6a4d | ||
|
|
918ea7503a | ||
|
|
dbe07827bd | ||
|
|
98eb756951 | ||
|
|
86eeeb5b94 | ||
|
|
a3e6628e11 | ||
|
|
84bc4217de | ||
|
|
b88819b9bb | ||
|
|
c7a0e59919 | ||
|
|
9984d4be42 | ||
|
|
a1c91b9007 | ||
|
|
6a256d59f5 | ||
|
|
fca2f1e6de | ||
|
|
ec7994a561 | ||
|
|
2839c36ea2 | ||
|
|
9f22bf2fbf | ||
|
|
5f0df1b167 | ||
|
|
3bf2fab2e9 | ||
|
|
73d76d860e | ||
|
|
bcfcb64931 | ||
|
|
a19cb71394 | ||
|
|
52731fe68e | ||
|
|
7845d89f10 | ||
|
|
3d358e57ff | ||
|
|
bd9ae9dbd5 | ||
|
|
f281927578 | ||
|
|
665c53093a | ||
|
|
10fbc24f43 | ||
|
|
6631e9144e | ||
|
|
7ae532f082 | ||
|
|
1af55e3720 | ||
|
|
fe32aa2d33 | ||
|
|
f6460c2802 | ||
|
|
045c10048d | ||
|
|
308356de80 | ||
|
|
8771d4c5e5 | ||
|
|
cd25681cd3 | ||
|
|
ad6a11819d | ||
|
|
b17da055af | ||
|
|
2fd896508b | ||
|
|
99348fce53 | ||
|
|
eb0d758efc | ||
|
|
c03aca35d6 | ||
|
|
f484e87828 | ||
|
|
07b2df7c7e | ||
|
|
cab15d39c3 | ||
|
|
36335c10a4 | ||
|
|
642d14d003 | ||
|
|
175808e251 | ||
|
|
14d952a212 | ||
|
|
37e09caac5 | ||
|
|
4d7a6cb658 | ||
|
|
cc80fe5105 | ||
|
|
b79f6b0fdd | ||
|
|
83e9ac04b2 | ||
|
|
8cecfe5b7c | ||
|
|
54aed80db8 | ||
|
|
0d89fc9d28 | ||
|
|
cee34d0c31 | ||
|
|
d2e60eb5ac | ||
|
|
c71742a996 | ||
|
|
fe139f8420 | ||
|
|
bb015d0c88 | ||
|
|
94809c2a66 | ||
|
|
141d3e26ea | ||
|
|
efb958ba44 | ||
|
|
9f0fe9e0cb | ||
|
|
2028d65579 | ||
|
|
c98c60b120 | ||
|
|
6805574553 | ||
|
|
c3128dec0d | ||
|
|
b65639cd76 | ||
|
|
42e9f43443 | ||
|
|
c40ad63291 | ||
|
|
0964762217 | ||
|
|
3553a0f9fe | ||
|
|
24304a61a7 | ||
|
|
497846e5a6 | ||
|
|
0729be0f0a | ||
|
|
2adea2d3dc | ||
|
|
30d7768299 | ||
|
|
3a7fadb843 | ||
|
|
779bbb9f88 | ||
|
|
a721cc0b7c | ||
|
|
3973aa1000 | ||
|
|
ac9fe74785 | ||
|
|
46c9e3b713 | ||
|
|
05b82cdbab | ||
|
|
3086724e92 | ||
|
|
fbac03e372 | ||
|
|
2518a7c8e5 | ||
|
|
bbec0932fd | ||
|
|
bca766c20d | ||
|
|
bb3afa21a4 | ||
|
|
85451a9a20 | ||
|
|
d475ace76c | ||
|
|
9f3395f256 | ||
|
|
c6bda0875c | ||
|
|
4f63a00bad | ||
|
|
0a3141841c | ||
|
|
6fea194ef5 | ||
|
|
e66ab1be0d | ||
|
|
5ce8217cd5 | ||
|
|
2ed45c92a6 | ||
|
|
9f7d431d34 | ||
|
|
d937c9ce06 | ||
|
|
6a96d40da4 | ||
|
|
2eabe845d7 | ||
|
|
4cfee76202 | ||
|
|
446fa48d9a | ||
|
|
9546987970 | ||
|
|
7a624fb449 | ||
|
|
26de6cf86f | ||
|
|
5fe7302965 | ||
|
|
a779b31ca5 | ||
|
|
8fa629a243 | ||
|
|
0864cf756c | ||
|
|
e9d72df890 | ||
|
|
c39a44c3ac | ||
|
|
7e8402b542 | ||
|
|
a050a2604f | ||
|
|
abad672bef | ||
|
|
fe3d715f09 | ||
|
|
e151fbe298 | ||
|
|
2ccb475aa0 | ||
|
|
4c83d439af | ||
|
|
352f3bd263 | ||
|
|
b73b73e221 | ||
|
|
c454d17826 | ||
|
|
098f8d8231 | ||
|
|
c1e3660551 | ||
|
|
3ceb53aa4f | ||
|
|
a33f326cfc | ||
|
|
83883aa7e6 | ||
|
|
3fae4e5e9e | ||
|
|
4e9b11f30a | ||
|
|
46dc4e5104 | ||
|
|
9c8bdb1166 | ||
|
|
242993763c | ||
|
|
b84518e1f1 | ||
|
|
b2593d409e | ||
|
|
d3b3a8af38 | ||
|
|
ec2cb5007c | ||
|
|
ca33cee79d | ||
|
|
2d456bd346 | ||
|
|
10680668db | ||
|
|
0e64b61be4 | ||
|
|
96c53091d0 | ||
|
|
6e64f80c81 | ||
|
|
8906e4c4fc | ||
|
|
cc5d7ea873 | ||
|
|
6237d58ad6 | ||
|
|
fae5ebe226 | ||
|
|
9a92920120 | ||
|
|
dc5c6b0138 | ||
|
|
88c432496b | ||
|
|
63b890d522 | ||
|
|
cd5c8d7cdf | ||
|
|
d80017ba7b | ||
|
|
5eb8a262be | ||
|
|
7474842b45 | ||
|
|
9093385de3 | ||
|
|
bd349ac4a3 | ||
|
|
37367fe91f | ||
|
|
dce792083b | ||
|
|
06f7900318 | ||
|
|
d8ac199858 | ||
|
|
9cf21e2927 | ||
|
|
86a15b9a66 | ||
|
|
31b57df567 | ||
|
|
a07f876c85 | ||
|
|
2eb0c1e67e | ||
|
|
6325e25630 | ||
|
|
6fdd349654 | ||
|
|
01e17adf82 | ||
|
|
acdd5f3faa | ||
|
|
4d3c692402 | ||
|
|
787f691f44 | ||
|
|
500385cd3e | ||
|
|
6df64a29dc | ||
|
|
233324f6c9 | ||
|
|
da253c47da |
No files matched your search
@@ -1 +1,2 @@
|
|||||||
|
github: lucko
|
||||||
patreon: luckdev
|
patreon: luckdev
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
name: 🐛 Bug report
|
||||||
|
about: Report an issue or problem with the way LuckPerms is functioning.
|
||||||
|
title: ''
|
||||||
|
labels: 'type: issue'
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- Before going any further, please check to see if your problem is fixed by updating to a newer version. The latest development builds can be obtained from https://luckperms.net/download -->
|
||||||
|
|
||||||
|
### Description
|
||||||
|
<!-- Please provide a short description of the issue in the space below. -->
|
||||||
|
|
||||||
|
|
||||||
|
### Reproduction steps
|
||||||
|
<!-- Please provide a clear list of steps we should follow in order to reproduce your issue in the space below. -->
|
||||||
|
|
||||||
|
1. Open the config.yml file and set example to true.
|
||||||
|
2. Restart the server
|
||||||
|
3. Run /lp user example permission set x from the console
|
||||||
|
4. See error
|
||||||
|
|
||||||
|
|
||||||
|
### Expected behaviour
|
||||||
|
<!-- Please provide a description of what you expected to happen. -->
|
||||||
|
|
||||||
|
|
||||||
|
### Environment details
|
||||||
|
<!-- Please provide details of your server environment in the space below. -->
|
||||||
|
|
||||||
|
* Server type/version: `ExampleSpigot` running version `1.12.2` build `???`
|
||||||
|
* LuckPerms version: `v???`
|
||||||
|
|
||||||
|
<!-- If you think it would be helpful, please also include a "pastebin" of any relevant config files or log output. You should use https://gist.github.com/ to upload, then include the link below. -->
|
||||||
|
|
||||||
|
|
||||||
|
### Any other relevant details
|
||||||
|
<!-- Please include any other relevant details in the space below. -->
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: 💬 Ask a question
|
||||||
|
url: https://discord.gg/luckperms
|
||||||
|
about: We use Discord to provide support for the project. If you have a question, need help, or aren't sure if you've found a bug or not, please come and talk to us there!
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
name: 💡 Suggestion
|
||||||
|
about: Suggest an idea for an improvement or change to LuckPerms.
|
||||||
|
title: ''
|
||||||
|
labels: 'type: suggestion'
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Description
|
||||||
|
<!-- Please provide a short description of the suggestion in the space below. -->
|
||||||
|
|
||||||
|
|
||||||
|
### Proposed behaviour
|
||||||
|
<!-- Please provide a short explanation of how the feature should work / be changed, and how this will effect the project. -->
|
||||||
|
|
||||||
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
### :speech_balloon: Looking for support?
|
### :speech_balloon: Looking for support?
|
||||||
|
|
||||||
Details about support for the project can be found [here, on the Wiki Homepage](https://github.com/lucko/LuckPerms/wiki#support).
|
Details about support for the project can be found [here, on the Wiki Homepage](https://luckperms.net/wiki/Home#support).
|
||||||
|
|
||||||
### :bug: Reporting bugs?
|
### :bug: Reporting bugs?
|
||||||
|
|
||||||
@@ -16,11 +16,11 @@ If you make any changes or improvements to the plugin which you think would be b
|
|||||||
|
|
||||||
LuckPerms loosely follows the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). Generally, try to copy the style of code found in the class you're editing.
|
LuckPerms loosely follows the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). Generally, try to copy the style of code found in the class you're editing.
|
||||||
|
|
||||||
If you're considering submitting a substantial pull request, please open an issue so we can discuss the change before starting work on the contribution. Most pull requests are happily accepted, but larger changes may have an inpact on the maintainability of the project, and require more consideration.
|
If you're considering submitting a substantial pull request, please open an issue so we can discuss the change before starting work on the contribution. Most pull requests are happily accepted, but larger changes may have an impact on the maintainability of the project, and require more consideration.
|
||||||
|
|
||||||
#### Project Layout
|
#### Project Layout
|
||||||
The project is split up into a few seperate modules.
|
The project is split up into a few separate modules.
|
||||||
|
|
||||||
* **API** - The public, semantically versioned API used by other plugins wishing to integrate with and retrieve data from LuckPerms. This module (for the most part) does not contain any implementation itself, and is provided by the plugin.
|
* **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 & Velocity** - Each use the common module to implement plugins on the respective server platforms.
|
* **Bukkit, BungeeCord, Sponge, Nukkit, Velocity & Fabric** - Each use the common module to implement plugins on the respective server platforms.
|
||||||
@@ -1,21 +1,24 @@
|
|||||||

|

|
||||||
# LuckPerms
|
# LuckPerms
|
||||||
[](https://ci.lucko.me/job/LuckPerms/)
|
[](https://ci.lucko.me/job/LuckPerms/)
|
||||||
[](https://javadoc.io/doc/me.lucko.luckperms/luckperms-api)
|
[](https://javadoc.io/doc/net.luckperms/api)
|
||||||
[](https://search.maven.org/artifact/me.lucko.luckperms/luckperms-api)
|
[](https://search.maven.org/artifact/net.luckperms/api)
|
||||||
[](https://discord.gg/luckperms)
|
[](https://discord.gg/luckperms)
|
||||||
|
|
||||||
LuckPerms is an advanced permissions implementation aiming to be a fast, reliable and flexible alternative to existing permission plugins. The project's main goals are centered around high performance and a wide feature set, filling the gaps of functionality and building upon existing features found in other plugins.
|
LuckPerms is a permissions plugin for Minecraft servers. It allows server admins to control what features players can use by creating groups and assigning permissions.
|
||||||
|
|
||||||
LuckPerms also includes an extensive API for developers, and support for a variety of Minecraft server software & data storage options.
|
The latest downloads, wiki & other useful links can be found on the project homepage at [luckperms.net](https://luckperms.net/).
|
||||||
|
|
||||||
Still not convinced? More information can be found on the wiki, under: [Why LuckPerms?](https://github.com/lucko/LuckPerms/wiki/Why-LuckPerms)
|
It is:
|
||||||
|
|
||||||
## Useful Links
|
* **fast** - written with performance and scalability in mind.
|
||||||
|
* **reliable** - trusted by thousands of server admins, and the largest of server networks.
|
||||||
|
* **easy to use** - setup permissions using commands, directly in config files, or using the web editor.
|
||||||
|
* **flexible** - supports a variety of data storage options, and works on lots of different server types.
|
||||||
|
* **extensive** - a plethora of customization options and settings which can be changed to suit your server.
|
||||||
|
* **free** - available for download and usage at no cost, and permissively licensed so it can remain free forever.
|
||||||
|
|
||||||
The latest **downloads** can be found on the [project's homepage](https://luckperms.net/).
|
For more information, see the wiki article on [Why LuckPerms?](https://luckperms.net/wiki/Why-LuckPerms)
|
||||||
|
|
||||||
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 Gradle to handle dependencies & building.
|
LuckPerms uses Gradle to handle dependencies & building.
|
||||||
@@ -31,7 +34,7 @@ cd LuckPerms/
|
|||||||
./gradlew build
|
./gradlew build
|
||||||
```
|
```
|
||||||
|
|
||||||
You can find the output jars in the `build/libs` directories.
|
You can find the output jars in the `loader/build/libs` or `build/libs` directories.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
#### Pull Requests
|
#### Pull Requests
|
||||||
@@ -44,7 +47,7 @@ The project is split up into a few separate modules.
|
|||||||
|
|
||||||
* **API** - The public, semantically versioned API used by other plugins wishing to integrate with and retrieve data from LuckPerms. This module (for the most part) does not contain any implementation itself, and is provided by the plugin.
|
* **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 & Velocity** - Each use the common module to implement plugins on the respective server platforms.
|
* **Bukkit, BungeeCord, Sponge, Fabric, Nukkit & Velocity** - Each use the common module to implement plugins on the respective server platforms.
|
||||||
|
|
||||||
## License
|
## 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.
|
||||||
+10
-5
@@ -1,8 +1,9 @@
|
|||||||
group = 'net.luckperms'
|
group = 'net.luckperms'
|
||||||
project.version = '5.0'
|
project.version = '5.3'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'org.checkerframework:checker-qual:2.5.5'
|
compileOnly 'org.checkerframework:checker-qual:3.8.0'
|
||||||
|
compileOnly 'org.jetbrains:annotations:20.1.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only used occasionally for deployment - not needed for normal builds.
|
// Only used occasionally for deployment - not needed for normal builds.
|
||||||
@@ -12,10 +13,13 @@ if (project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePass
|
|||||||
|
|
||||||
javadoc {
|
javadoc {
|
||||||
title = 'LuckPerms API (v' + project.ext.apiVersion + ')'
|
title = 'LuckPerms API (v' + project.ext.apiVersion + ')'
|
||||||
|
options.overview = 'javadoc/overview.html'
|
||||||
options.encoding = 'UTF-8'
|
options.encoding = 'UTF-8'
|
||||||
options.charSet = 'UTF-8'
|
options.charSet = 'UTF-8'
|
||||||
options.links(
|
options.links(
|
||||||
'https://docs.oracle.com/javase/8/docs/api/'
|
'https://docs.oracle.com/javase/8/docs/api/',
|
||||||
|
'https://checkerframework.org/api/',
|
||||||
|
'https://javadoc.io/static/org.jetbrains/annotations/20.1.0/'
|
||||||
)
|
)
|
||||||
options.addStringOption('Xdoclint:none', '-quiet')
|
options.addStringOption('Xdoclint:none', '-quiet')
|
||||||
}
|
}
|
||||||
@@ -56,7 +60,7 @@ if (project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePass
|
|||||||
pom {
|
pom {
|
||||||
project {
|
project {
|
||||||
name 'LuckPerms API'
|
name 'LuckPerms API'
|
||||||
description 'An advanced permissions plugin for Bukkit/Spigot, BungeeCord, Sponge, Nukkit and Velocity.'
|
description 'A permissions plugin for Minecraft servers.'
|
||||||
url 'https://luckperms.net'
|
url 'https://luckperms.net'
|
||||||
|
|
||||||
licenses {
|
licenses {
|
||||||
@@ -68,9 +72,10 @@ if (project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePass
|
|||||||
|
|
||||||
developers {
|
developers {
|
||||||
developer {
|
developer {
|
||||||
|
id 'lucko'
|
||||||
name 'Luck'
|
name 'Luck'
|
||||||
|
url 'https://lucko.me'
|
||||||
email '[email protected]'
|
email '[email protected]'
|
||||||
url 'https://github.com/lucko'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<body>
|
||||||
|
<p>
|
||||||
|
LuckPerms is a permissions plugin for Minecraft servers. It allows server admins to control what
|
||||||
|
features players can use by creating groups and assigning permissions.
|
||||||
|
</p>
|
||||||
|
<h4>Useful Links</h4>
|
||||||
|
<ul>
|
||||||
|
<li><a target="_top" href="https://luckperms.net">Project Website</a></li>
|
||||||
|
<li><a target="_top" href="https://luckperms.net/wiki/Developer-API">Wiki - API Introduction</a></li>
|
||||||
|
<li><a target="_top" href="https://luckperms.net/wiki/Developer-API-Usage">Wiki - API Usage</a></li>
|
||||||
|
</ul>
|
||||||
|
<h4>Maven</h4>
|
||||||
|
<p>
|
||||||
|
The API artifact is deployed to Maven Central under
|
||||||
|
<a target="_top" href="https://search.maven.org/artifact/net.luckperms/api">
|
||||||
|
group id: <b><code>net.luckperms</code></b>, artifact id: <b><code>api</code></b>.
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
@@ -39,12 +39,16 @@ import net.luckperms.api.model.group.GroupManager;
|
|||||||
import net.luckperms.api.model.user.User;
|
import net.luckperms.api.model.user.User;
|
||||||
import net.luckperms.api.model.user.UserManager;
|
import net.luckperms.api.model.user.UserManager;
|
||||||
import net.luckperms.api.node.NodeBuilderRegistry;
|
import net.luckperms.api.node.NodeBuilderRegistry;
|
||||||
|
import net.luckperms.api.node.matcher.NodeMatcherFactory;
|
||||||
import net.luckperms.api.platform.Platform;
|
import net.luckperms.api.platform.Platform;
|
||||||
|
import net.luckperms.api.platform.PlayerAdapter;
|
||||||
import net.luckperms.api.platform.PluginMetadata;
|
import net.luckperms.api.platform.PluginMetadata;
|
||||||
|
import net.luckperms.api.query.QueryOptionsRegistry;
|
||||||
import net.luckperms.api.track.Track;
|
import net.luckperms.api.track.Track;
|
||||||
import net.luckperms.api.track.TrackManager;
|
import net.luckperms.api.track.TrackManager;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.ApiStatus.Internal;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@@ -114,6 +118,33 @@ public interface LuckPerms {
|
|||||||
*/
|
*/
|
||||||
@NonNull TrackManager getTrackManager();
|
@NonNull TrackManager getTrackManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link PlayerAdapter} instance, a utility class for adapting platform Player
|
||||||
|
* instances to {@link User}s.
|
||||||
|
*
|
||||||
|
* <p>The {@code playerClass} parameter must be equal to the class or interface used by the
|
||||||
|
* server platform to represent players.</p>
|
||||||
|
*
|
||||||
|
* <p>Specifically:</p>
|
||||||
|
*
|
||||||
|
* <p></p>
|
||||||
|
* <ul>
|
||||||
|
* <li>{@code org.bukkit.entity.Player}</li>
|
||||||
|
* <li>{@code net.md_5.bungee.api.connection.ProxiedPlayer}</li>
|
||||||
|
* <li>{@code org.spongepowered.api/entity.living.player.Player}</li>
|
||||||
|
* <li>{@code net.minecraft.server.network.ServerPlayerEntity} (Fabric)</li>
|
||||||
|
* <li>{@code cn.nukkit.Player}</li>
|
||||||
|
* <li>{@code com.velocitypowered.api.proxy.Player}</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @param playerClass the class used by the platform to represent players
|
||||||
|
* @param <T> the player class type
|
||||||
|
* @return the player adapter
|
||||||
|
* @throws IllegalArgumentException if the player class is not correct
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
<T> @NonNull PlayerAdapter<T> getPlayerAdapter(@NonNull Class<T> playerClass);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link Platform}, which represents the server platform the
|
* Gets the {@link Platform}, which represents the server platform the
|
||||||
* plugin is running on.
|
* plugin is running on.
|
||||||
@@ -165,13 +196,6 @@ public interface LuckPerms {
|
|||||||
*/
|
*/
|
||||||
@NonNull ContextManager getContextManager();
|
@NonNull ContextManager getContextManager();
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the {@link NodeBuilderRegistry}.
|
|
||||||
*
|
|
||||||
* @return the node builder registry
|
|
||||||
*/
|
|
||||||
@NonNull NodeBuilderRegistry getNodeBuilderRegistry();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link MetaStackFactory}.
|
* Gets the {@link MetaStackFactory}.
|
||||||
*
|
*
|
||||||
@@ -206,4 +230,30 @@ public interface LuckPerms {
|
|||||||
*/
|
*/
|
||||||
void registerMessengerProvider(@NonNull MessengerProvider messengerProvider);
|
void registerMessengerProvider(@NonNull MessengerProvider messengerProvider);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link NodeBuilderRegistry}.
|
||||||
|
*
|
||||||
|
* @return the node builder registry
|
||||||
|
*/
|
||||||
|
@Internal
|
||||||
|
@NonNull NodeBuilderRegistry getNodeBuilderRegistry();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link QueryOptionsRegistry}.
|
||||||
|
*
|
||||||
|
* @return the query options registry
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
@Internal
|
||||||
|
@NonNull QueryOptionsRegistry getQueryOptionsRegistry();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link NodeMatcherFactory}.
|
||||||
|
*
|
||||||
|
* @return the node matcher factory
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
@Internal
|
||||||
|
@NonNull NodeMatcherFactory getNodeMatcherFactory();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,41 +27,62 @@ package net.luckperms.api;
|
|||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
import static org.jetbrains.annotations.ApiStatus.Internal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides static access to the {@link LuckPerms} service.
|
* Provides static access to the {@link LuckPerms} API.
|
||||||
*
|
*
|
||||||
* <p>Ideally, the ServiceManager for the platform should be used to obtain an
|
* <p>Ideally, the ServiceManager for the platform should be used to obtain an
|
||||||
* instance, however, this provider can be used if you need static access.</p>
|
* instance, however, this provider can be used if this is not viable.</p>
|
||||||
*/
|
*/
|
||||||
public final class LuckPermsProvider {
|
public final class LuckPermsProvider {
|
||||||
private static LuckPerms instance = null;
|
private static LuckPerms instance = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an instance of the {@link LuckPerms} service,
|
* Gets an instance of the {@link LuckPerms} API,
|
||||||
* throwing {@link IllegalStateException} if an instance is not yet loaded.
|
* throwing {@link IllegalStateException} if the API is not loaded yet.
|
||||||
*
|
*
|
||||||
* <p>Will never return null.</p>
|
* <p>This method will never return null.</p>
|
||||||
*
|
*
|
||||||
* @return an api instance
|
* @return an instance of the LuckPerms API
|
||||||
* @throws IllegalStateException if the api is not loaded
|
* @throws IllegalStateException if the API is not loaded yet
|
||||||
*/
|
*/
|
||||||
public static @NonNull LuckPerms get() {
|
public static @NonNull LuckPerms get() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
throw new IllegalStateException("The LuckPerms API is not loaded.");
|
throw new NotLoadedException();
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Internal
|
||||||
static void register(LuckPerms instance) {
|
static void register(LuckPerms instance) {
|
||||||
LuckPermsProvider.instance = instance;
|
LuckPermsProvider.instance = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Internal
|
||||||
static void unregister() {
|
static void unregister() {
|
||||||
LuckPermsProvider.instance = null;
|
LuckPermsProvider.instance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Internal
|
||||||
private LuckPermsProvider() {
|
private LuckPermsProvider() {
|
||||||
throw new UnsupportedOperationException("This class cannot be instantiated.");
|
throw new UnsupportedOperationException("This class cannot be instantiated.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception thrown when the API is requested before it has been loaded.
|
||||||
|
*/
|
||||||
|
private static final class NotLoadedException extends IllegalStateException {
|
||||||
|
private static final String MESSAGE = "The LuckPerms API isn't loaded yet!\n" +
|
||||||
|
"This could be because:\n" +
|
||||||
|
" a) the LuckPerms plugin is not installed or it failed to enable\n" +
|
||||||
|
" b) your plugin does not declare a dependency on LuckPerms\n" +
|
||||||
|
" c) you are attempting to use the API before plugins reach the 'enable' phase\n" +
|
||||||
|
" (call the #get method in onEnable, not in your plugin constructor!)\n";
|
||||||
|
|
||||||
|
NotLoadedException() {
|
||||||
|
super(MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ public interface Action extends Comparable<Action> {
|
|||||||
* @param type the type
|
* @param type the type
|
||||||
* @return the builder
|
* @return the builder
|
||||||
*/
|
*/
|
||||||
@NonNull Builder targetType(Action.Target.Type type);
|
@NonNull Builder targetType(Target.@NonNull Type type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the acted object for the entry.
|
* Sets the acted object for the entry.
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
package net.luckperms.api.actionlog;
|
package net.luckperms.api.actionlog;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -47,7 +48,7 @@ public interface ActionLog {
|
|||||||
*
|
*
|
||||||
* @return the content
|
* @return the content
|
||||||
*/
|
*/
|
||||||
@NonNull SortedSet<Action> getContent();
|
@NonNull @Unmodifiable SortedSet<Action> getContent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the entries in the log performed by the given actor.
|
* Gets the entries in the log performed by the given actor.
|
||||||
@@ -55,7 +56,7 @@ public interface ActionLog {
|
|||||||
* @param actor the uuid of the actor to filter by
|
* @param actor the uuid of the actor to filter by
|
||||||
* @return the content for the given actor
|
* @return the content for the given actor
|
||||||
*/
|
*/
|
||||||
@NonNull SortedSet<Action> getContent(@NonNull UUID actor);
|
@NonNull @Unmodifiable SortedSet<Action> getContent(@NonNull UUID actor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the log content for a given user
|
* Gets the log content for a given user
|
||||||
@@ -63,7 +64,7 @@ public interface ActionLog {
|
|||||||
* @param uniqueId the uuid to filter by
|
* @param uniqueId 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 SortedSet<Action> getUserHistory(@NonNull UUID uniqueId);
|
@NonNull @Unmodifiable SortedSet<Action> getUserHistory(@NonNull UUID uniqueId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the log content for a given group
|
* Gets the log content for a given group
|
||||||
@@ -71,7 +72,7 @@ public interface ActionLog {
|
|||||||
* @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 SortedSet<Action> getGroupHistory(@NonNull String name);
|
@NonNull @Unmodifiable SortedSet<Action> getGroupHistory(@NonNull String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the log content for a given track
|
* Gets the log content for a given track
|
||||||
@@ -79,6 +80,6 @@ public interface ActionLog {
|
|||||||
* @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 SortedSet<Action> getTrackHistory(@NonNull String name);
|
@NonNull @Unmodifiable SortedSet<Action> getTrackHistory(@NonNull String name);
|
||||||
|
|
||||||
}
|
}
|
||||||
+2
-10
@@ -23,15 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.dependencies.classloader;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the plugins classloader
|
* {@link net.luckperms.api.actionlog.ActionLog} related functionality.
|
||||||
*/
|
*/
|
||||||
public interface PluginClassLoader {
|
package net.luckperms.api.actionlog;
|
||||||
|
|
||||||
void loadJar(Path file);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -25,7 +25,10 @@
|
|||||||
|
|
||||||
package net.luckperms.api.cacheddata;
|
package net.luckperms.api.cacheddata;
|
||||||
|
|
||||||
|
import net.luckperms.api.context.ContextManager;
|
||||||
import net.luckperms.api.model.PermissionHolder;
|
import net.luckperms.api.model.PermissionHolder;
|
||||||
|
import net.luckperms.api.model.group.Group;
|
||||||
|
import net.luckperms.api.model.user.User;
|
||||||
import net.luckperms.api.query.QueryOptions;
|
import net.luckperms.api.query.QueryOptions;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
@@ -56,23 +59,58 @@ public interface CachedDataManager {
|
|||||||
@NonNull Container<CachedMetaData> metaData();
|
@NonNull Container<CachedMetaData> metaData();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets PermissionData from the cache, given a specified context.
|
* Gets PermissionData from the cache, using the given query options.
|
||||||
*
|
*
|
||||||
* @param queryOptions the query options
|
* @param queryOptions the query options
|
||||||
* @return a permission data instance
|
* @return a permission data instance
|
||||||
* @throws NullPointerException if contexts is null
|
|
||||||
*/
|
*/
|
||||||
@NonNull CachedPermissionData getPermissionData(@NonNull QueryOptions queryOptions);
|
@NonNull CachedPermissionData getPermissionData(@NonNull QueryOptions queryOptions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets MetaData from the cache, given a specified context.
|
* Gets MetaData from the cache, using the given query options.
|
||||||
*
|
*
|
||||||
* @param queryOptions the query options
|
* @param queryOptions the query options
|
||||||
* @return a meta data instance
|
* @return a meta data instance
|
||||||
* @throws NullPointerException if contexts is null
|
|
||||||
*/
|
*/
|
||||||
@NonNull CachedMetaData getMetaData(@NonNull QueryOptions queryOptions);
|
@NonNull CachedMetaData getMetaData(@NonNull QueryOptions queryOptions);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets PermissionData from the cache, using the most appropriate query options
|
||||||
|
* available at the time.
|
||||||
|
*
|
||||||
|
* <p>For {@link User}s, the most appropriate query options will be their
|
||||||
|
* {@link ContextManager#getQueryOptions(User) current active query options} if the
|
||||||
|
* corresponding player is online, and otherwise, will fallback to
|
||||||
|
* {@link ContextManager#getStaticQueryOptions() the current static query options}
|
||||||
|
* if they are offline.</p>
|
||||||
|
*
|
||||||
|
* <p>For {@link Group}s, the most appropriate query options will always be
|
||||||
|
* {@link ContextManager#getStaticQueryOptions()} the current static query options.</p>
|
||||||
|
*
|
||||||
|
* @return a permission data instance
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
@NonNull CachedPermissionData getPermissionData();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets MetaData from the cache, using the most appropriate query options
|
||||||
|
* available at the time.
|
||||||
|
*
|
||||||
|
* <p>For {@link User}s, the most appropriate query options will be their
|
||||||
|
* {@link ContextManager#getQueryOptions(User) current active query options} if the
|
||||||
|
* corresponding player is online, and otherwise, will fallback to
|
||||||
|
* {@link ContextManager#getStaticQueryOptions() the current static query options}
|
||||||
|
* if they are offline.</p>
|
||||||
|
*
|
||||||
|
* <p>For {@link Group}s, the most appropriate query options will always be
|
||||||
|
* {@link ContextManager#getStaticQueryOptions()} the current static query options.</p>
|
||||||
|
*
|
||||||
|
* @return a meta data instance
|
||||||
|
* @since 5.1
|
||||||
|
* @see PermissionHolder#getQueryOptions()
|
||||||
|
*/
|
||||||
|
@NonNull CachedMetaData getMetaData();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidates all cached {@link CachedPermissionData} and {@link CachedMetaData}
|
* Invalidates all cached {@link CachedPermissionData} and {@link CachedMetaData}
|
||||||
* instances.
|
* instances.
|
||||||
|
|||||||
@@ -29,10 +29,13 @@ import net.luckperms.api.metastacking.MetaStackDefinition;
|
|||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds cached meta lookup data for a specific set of contexts.
|
* Holds cached meta lookup data for a specific set of contexts.
|
||||||
@@ -45,44 +48,84 @@ public interface CachedMetaData extends CachedData {
|
|||||||
* @param key the key
|
* @param key the key
|
||||||
* @return the value
|
* @return the value
|
||||||
*/
|
*/
|
||||||
@Nullable String getMetaValue(String key);
|
@Nullable String getMetaValue(@NonNull String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the user's highest priority prefix, or null if the user has no prefixes
|
* Gets a value for the given meta key, and runs it through the given {@code transformer}.
|
||||||
|
*
|
||||||
|
* <p>If no such meta value exists, an {@link Optional#empty() empty optional} is returned.
|
||||||
|
* (the transformer will never be passed a null argument)</p>
|
||||||
|
*
|
||||||
|
* <p>The transformer is allowed to throw {@link IllegalArgumentException} or return null. This
|
||||||
|
* will also result in an {@link Optional#empty() empty optional} being returned.</p>
|
||||||
|
*
|
||||||
|
* <p>For example, to parse and return an integer meta value, use:</p>
|
||||||
|
* <p><blockquote><pre>
|
||||||
|
* getMetaValue("my-int-val", Integer::parseInt).orElse(0);
|
||||||
|
* </pre></blockquote>
|
||||||
|
*
|
||||||
|
* @param key the key
|
||||||
|
* @param valueTransformer the transformer used to transform the value
|
||||||
|
* @param <T> the type of the transformed result
|
||||||
|
* @return the meta value
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
default <T> @NonNull Optional<T> getMetaValue(@NonNull String key, @NonNull Function<String, ? extends T> valueTransformer) {
|
||||||
|
return Optional.ofNullable(getMetaValue(key)).map(value -> {
|
||||||
|
try {
|
||||||
|
return valueTransformer.apply(value);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the holder's highest priority prefix, or null if the holder has no prefixes
|
||||||
*
|
*
|
||||||
* @return a prefix string, or null
|
* @return a prefix string, or null
|
||||||
*/
|
*/
|
||||||
@Nullable String getPrefix();
|
@Nullable String getPrefix();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the user's highest priority suffix, or null if the user has no suffixes
|
* Gets the holder's highest priority suffix, or null if the holder has no suffixes
|
||||||
*
|
*
|
||||||
* @return a suffix string, or null
|
* @return a suffix string, or null
|
||||||
*/
|
*/
|
||||||
@Nullable String getSuffix();
|
@Nullable String getSuffix();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an immutable copy of the meta this user has.
|
* Gets an immutable copy of the meta this holder has.
|
||||||
*
|
*
|
||||||
* @return an immutable map of meta
|
* @return an immutable map of meta
|
||||||
*/
|
*/
|
||||||
@NonNull Map<String, List<String>> getMeta();
|
@NonNull @Unmodifiable Map<String, List<String>> getMeta();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an immutable sorted map of all of the prefixes the user has, whereby the first value is the highest priority
|
* Gets an immutable sorted map of all of the prefixes the holder has, whereby the first
|
||||||
* prefix.
|
* value is the highest priority prefix.
|
||||||
*
|
*
|
||||||
* @return a sorted map of prefixes
|
* @return a sorted map of prefixes
|
||||||
*/
|
*/
|
||||||
@NonNull SortedMap<Integer, String> getPrefixes();
|
@NonNull @Unmodifiable SortedMap<Integer, String> getPrefixes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an immutable sorted map of all of the suffixes the user has, whereby the first value is the highest priority
|
* Gets an immutable sorted map of all of the suffixes the holder has, whereby the first
|
||||||
* suffix.
|
* value is the highest priority suffix.
|
||||||
*
|
*
|
||||||
* @return a sorted map of suffixes
|
* @return a sorted map of suffixes
|
||||||
*/
|
*/
|
||||||
@NonNull SortedMap<Integer, String> getSuffixes();
|
@NonNull @Unmodifiable SortedMap<Integer, String> getSuffixes();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name of the holders primary group.
|
||||||
|
*
|
||||||
|
* <p>Will return {@code null} for Group holder types.</p>
|
||||||
|
*
|
||||||
|
* @return the name of the primary group
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
@Nullable String getPrimaryGroup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the definition used for the prefix stack
|
* Gets the definition used for the prefix stack
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ package net.luckperms.api.cacheddata;
|
|||||||
import net.luckperms.api.util.Tristate;
|
import net.luckperms.api.util.Tristate;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -57,6 +58,6 @@ public interface CachedPermissionData extends CachedData {
|
|||||||
*
|
*
|
||||||
* @return an immutable set of permissions
|
* @return an immutable set of permissions
|
||||||
*/
|
*/
|
||||||
@NonNull Map<String, Boolean> getPermissionMap();
|
@NonNull @Unmodifiable Map<String, Boolean> getPermissionMap();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CachedData lookup API for {@link net.luckperms.api.model.user.User}s and
|
||||||
|
* {@link net.luckperms.api.model.group.Group}s.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.cacheddata;
|
||||||
@@ -26,12 +26,64 @@
|
|||||||
package net.luckperms.api.context;
|
package net.luckperms.api.context;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an individual context pair.
|
* Represents an individual context pair.
|
||||||
|
*
|
||||||
|
* <p>Context keys and values may not be null or empty. A key/value will be
|
||||||
|
* deemed empty if it's length is zero, or if it consists of only space
|
||||||
|
* characters.</p>
|
||||||
|
*
|
||||||
|
* @see ContextSet
|
||||||
*/
|
*/
|
||||||
public interface Context {
|
public interface Context {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether {@code key} is valid.
|
||||||
|
*
|
||||||
|
* <p>Context keys and values may not be null or empty. A key/value will be
|
||||||
|
* deemed empty if it's length is zero, or if it consists of only space
|
||||||
|
* characters.</p>
|
||||||
|
*
|
||||||
|
* <p>An exception is thrown when an invalid key is added to a {@link ContextSet}.</p>
|
||||||
|
*
|
||||||
|
* @param key the key to test
|
||||||
|
* @return true if valid, false otherwise.
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
static boolean isValidKey(@Nullable String key) {
|
||||||
|
if (key == null || key.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// look for a non-whitespace character
|
||||||
|
for (int i = 0, n = key.length(); i < n; i++) {
|
||||||
|
if (key.charAt(i) != ' ') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether {@code value} is valid.
|
||||||
|
*
|
||||||
|
* <p>Context keys and values may not be null or empty. A key/value will be
|
||||||
|
* deemed empty if it's length is zero, or if it consists of only space
|
||||||
|
* characters.</p>
|
||||||
|
*
|
||||||
|
* <p>An exception is thrown when an invalid value is added to a {@link ContextSet}.</p>
|
||||||
|
*
|
||||||
|
* @param value the value to test
|
||||||
|
* @return true if valid, false otherwise.
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
static boolean isValidValue(@Nullable String value) {
|
||||||
|
return isValidKey(value); // the same for now...
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the context key.
|
* Gets the context key.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public interface ContextCalculator<T> {
|
|||||||
*
|
*
|
||||||
* @return a set of potential contexts
|
* @return a set of potential contexts
|
||||||
*/
|
*/
|
||||||
default ContextSet estimatePotentialContexts() {
|
default @NonNull ContextSet estimatePotentialContexts() {
|
||||||
return ImmutableContextSet.empty();
|
return ImmutableContextSet.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import net.luckperms.api.query.QueryMode;
|
|||||||
import net.luckperms.api.query.QueryOptions;
|
import net.luckperms.api.query.QueryOptions;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.ApiStatus.Internal;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -37,17 +38,18 @@ import java.util.Optional;
|
|||||||
* Manages {@link ContextCalculator}s, and calculates applicable contexts for a
|
* Manages {@link ContextCalculator}s, and calculates applicable contexts for a
|
||||||
* given type.
|
* given type.
|
||||||
*
|
*
|
||||||
* This interface accepts {@link Object} types as a parameter to avoid having to depend
|
* <p>This interface accepts {@link Object} types as a parameter to avoid having to depend
|
||||||
* on specific server implementations. In all cases, the "player" or "subject" type for
|
* on specific server implementations. In all cases, the "player" or "subject" type for
|
||||||
* the platform must be used.
|
* the platform must be used.</p>
|
||||||
*
|
*
|
||||||
* Specifically:
|
* <p>Specifically:</p>
|
||||||
*
|
*
|
||||||
* <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 net.minecraft.server.network.ServerPlayerEntity} (Fabric)</li>
|
||||||
* <li>{@code cn.nukkit.Player}</li>
|
* <li>{@code cn.nukkit.Player}</li>
|
||||||
* <li>{@code com.velocitypowered.api.proxy.Player}</li>
|
* <li>{@code com.velocitypowered.api.proxy.Player}</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
@@ -138,19 +140,36 @@ public interface ContextManager {
|
|||||||
*/
|
*/
|
||||||
void unregisterCalculator(@NonNull ContextCalculator<?> calculator);
|
void unregisterCalculator(@NonNull ContextCalculator<?> calculator);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signal to the {@link ContextManager} that a {@code subject}s
|
||||||
|
* current contexts have changed.
|
||||||
|
*
|
||||||
|
* <p>It is not strictly necessary to make a call to this method every time a context
|
||||||
|
* changes.</p>
|
||||||
|
*
|
||||||
|
* @param subject the subject
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
void signalContextUpdate(@NonNull Object subject);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link ContextSetFactory}, responsible for creating
|
* Gets the {@link ContextSetFactory}, responsible for creating
|
||||||
* {@link ContextSet} instances.
|
* {@link ContextSet} instances.
|
||||||
*
|
*
|
||||||
* @return the context set factory
|
* @return the context set factory
|
||||||
*/
|
*/
|
||||||
|
@Internal
|
||||||
@NonNull ContextSetFactory getContextSetFactory();
|
@NonNull ContextSetFactory getContextSetFactory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidates the lookup cache for a given subject
|
* Invalidates the lookup cache for a given subject
|
||||||
*
|
*
|
||||||
* @param subject the subject
|
* @param subject the subject
|
||||||
|
* @deprecated Use {@link #signalContextUpdate(Object)} instead
|
||||||
*/
|
*/
|
||||||
void invalidateCache(@NonNull Object subject);
|
@Deprecated
|
||||||
|
default void invalidateCache(@NonNull Object subject) {
|
||||||
|
signalContextUpdate(subject);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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 net.luckperms.api.context;
|
||||||
|
|
||||||
|
import net.luckperms.api.query.OptionKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mode for determining whether a {@link ContextSet} satisfies another.
|
||||||
|
*
|
||||||
|
* @since 5.2
|
||||||
|
* @see ContextSet#isSatisfiedBy(ContextSet, ContextSatisfyMode)
|
||||||
|
*/
|
||||||
|
public enum ContextSatisfyMode {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mode where a {@link ContextSet} A will be satisfied by another set B, if at least one of the
|
||||||
|
* key-value entries per key in A are also in B.
|
||||||
|
*
|
||||||
|
* <p>For example, given <code>A = {server=survival, world=overworld, world=nether}</code>,
|
||||||
|
* another set {@code X} will satisfy {@code A} if {@code X} contains
|
||||||
|
* <code>server=survival AND (world=overworld OR world=nether)</code>.</p>
|
||||||
|
*/
|
||||||
|
AT_LEAST_ONE_VALUE_PER_KEY,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mode where a {@link ContextSet} A will be satisfied by another set B, if all key-value
|
||||||
|
* entries in A are also in B.
|
||||||
|
*
|
||||||
|
* <p>For example, given <code>A = {server=survival, world=overworld, world=nether}</code>,
|
||||||
|
* another set {@code X} will satisfy {@code A} if {@code X} contains
|
||||||
|
* <code>server=survival AND world=overworld AND world=nether</code>.</p>
|
||||||
|
*/
|
||||||
|
ALL_VALUES_PER_KEY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link OptionKey} for {@link ContextSatisfyMode}.
|
||||||
|
*/
|
||||||
|
public static final OptionKey<ContextSatisfyMode> KEY = OptionKey.of("contextsatisfymode", ContextSatisfyMode.class);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
package net.luckperms.api.context;
|
package net.luckperms.api.context;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -40,19 +41,33 @@ import java.util.Set;
|
|||||||
* something will apply.</p>
|
* something will apply.</p>
|
||||||
*
|
*
|
||||||
* <p>A single "context" consists of a key and a value, both strings. The key
|
* <p>A single "context" consists of a key and a value, both strings. The key
|
||||||
* represents the type of context, and the value represents the setting of the
|
* describes the type of the context, and the value represents what the key is
|
||||||
* context key.</p>
|
* set to.</p>
|
||||||
|
*
|
||||||
|
* <p>For example, a context with {@code key=world} and {@code value=world_nether}
|
||||||
|
* describes that a subject is in the "world_nether" world.</p>
|
||||||
|
*
|
||||||
|
* <p>Contexts are exposed to end users and manipulated when managing permissions.
|
||||||
|
* For this reason, context keys should strike a balance between being descriptive
|
||||||
|
* and succinct.</p>
|
||||||
|
*
|
||||||
|
* <p>Context keys and values are case-insensitive, and will be automatically
|
||||||
|
* converted to {@link String#toLowerCase() lowercase} when added to a
|
||||||
|
* context set. Keys and values cannot be null or empty (len=0 or consisting of
|
||||||
|
* only whitespace).</p>
|
||||||
|
*
|
||||||
|
* <p>If a context key is formed of more than one word, the parts should be
|
||||||
|
* separated by the '{@code -}' character. (e.g. "{@code server-type}")</p>
|
||||||
|
*
|
||||||
|
* <p>If a context key is likely to conflict with another plugin, it should be
|
||||||
|
* appropriately namespaced using the name of the plugin providing the context.
|
||||||
|
* The namespace should be at the start of the context key, and separated using
|
||||||
|
* the '{@code :}' character. (e.g. "{@code worldguard:region}" for WorldGuard
|
||||||
|
* regions)</p>
|
||||||
*
|
*
|
||||||
* <p>Contexts can be combined with each other to form so called
|
* <p>Contexts can be combined with each other to form so called
|
||||||
* "context sets" - simply a collection of context pairs.</p>
|
* "context sets" - simply a collection of context pairs.</p>
|
||||||
*
|
*
|
||||||
* <p>Context keys and values are case-insensitive, and will be converted to
|
|
||||||
* {@link String#toLowerCase() lowercase} by all implementations.</p>
|
|
||||||
*
|
|
||||||
* <p>Context keys and values may not be null or empty. A key/value will be
|
|
||||||
* deemed empty if it's length is zero, or if it consists of only space
|
|
||||||
* characters.</p>
|
|
||||||
*
|
|
||||||
* <p>Two default ContextSet implementations are provided.
|
* <p>Two default ContextSet implementations are provided.
|
||||||
* {@link MutableContextSet} allows the addition and removal of context keys
|
* {@link MutableContextSet} allows the addition and removal of context keys
|
||||||
* after construction, and {@link ImmutableContextSet} does not.</p>
|
* after construction, and {@link ImmutableContextSet} does not.</p>
|
||||||
@@ -97,7 +112,7 @@ public interface ContextSet extends Iterable<Context> {
|
|||||||
*
|
*
|
||||||
* @return an immutable set
|
* @return an immutable set
|
||||||
*/
|
*/
|
||||||
@NonNull Set<Context> toSet();
|
@NonNull @Unmodifiable Set<Context> toSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link Map} representing the current state of this
|
* Returns a {@link Map} representing the current state of this
|
||||||
@@ -108,7 +123,7 @@ public interface ContextSet extends Iterable<Context> {
|
|||||||
*
|
*
|
||||||
* @return a map
|
* @return a map
|
||||||
*/
|
*/
|
||||||
@NonNull Map<String, Set<String>> toMap();
|
@NonNull @Unmodifiable Map<String, Set<String>> toMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link Map} <b>loosely</b> representing the current state of
|
* Returns a {@link Map} <b>loosely</b> representing the current state of
|
||||||
@@ -121,10 +136,10 @@ public interface ContextSet extends Iterable<Context> {
|
|||||||
* may not be a true representation of the set.</p>
|
* may not be a true representation of the set.</p>
|
||||||
*
|
*
|
||||||
* @return an immutable map
|
* @return an immutable map
|
||||||
* @deprecated because the resultant map may not contain all data in the ContextSet
|
* @deprecated Deprecated because the returned map may not contain all data in the ContextSet
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@NonNull Map<String, String> toFlattenedMap();
|
@NonNull @Unmodifiable Map<String, String> toFlattenedMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an {@link Iterator} over each of the context pairs in this set.
|
* Returns an {@link Iterator} over each of the context pairs in this set.
|
||||||
@@ -137,7 +152,7 @@ public interface ContextSet extends Iterable<Context> {
|
|||||||
* @return an iterator
|
* @return an iterator
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@NonNull Iterator<Context> iterator();
|
@NonNull @Unmodifiable Iterator<Context> 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
|
||||||
@@ -159,7 +174,7 @@ public interface ContextSet extends Iterable<Context> {
|
|||||||
* @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 Set<String> getValues(@NonNull String key);
|
@NonNull @Unmodifiable Set<String> getValues(@NonNull String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns any value from this {@link ContextSet} matching the key, if present.
|
* Returns any value from this {@link ContextSet} matching the key, if present.
|
||||||
@@ -197,17 +212,47 @@ public interface ContextSet extends Iterable<Context> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if this {@link ContextSet} is fully "satisfied" by another set.
|
* Returns if the {@link ContextSet} contains any of the given context pairings.
|
||||||
*
|
*
|
||||||
* <p>For a context set to "satisfy" another, it must itself contain all of
|
* @param key the key to look for
|
||||||
* the context pairings in the other set.</p>
|
* @param values the values to look for
|
||||||
*
|
* @return true if the set contains any of the pairs
|
||||||
* <p>Mathematically, this method returns true if this set is a <b>subset</b> of the other.</p>
|
* @since 5.2
|
||||||
*
|
|
||||||
* @param other the other set to check
|
|
||||||
* @return true if all entries in this set are also in the other set
|
|
||||||
*/
|
*/
|
||||||
boolean isSatisfiedBy(@NonNull ContextSet other);
|
default boolean containsAny(@NonNull String key, @NonNull Iterable<String> values) {
|
||||||
|
Objects.requireNonNull(key, "key");
|
||||||
|
Objects.requireNonNull(values, "values");
|
||||||
|
|
||||||
|
for (String value : values) {
|
||||||
|
if (contains(key, value)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if this {@link ContextSet} is "satisfied" by another set.
|
||||||
|
*
|
||||||
|
* <p>{@link ContextSatisfyMode#AT_LEAST_ONE_VALUE_PER_KEY} is the mode used by this method.</p>
|
||||||
|
*
|
||||||
|
* @param other the other set
|
||||||
|
* @return true if this context set is satisfied by the other
|
||||||
|
*/
|
||||||
|
default boolean isSatisfiedBy(@NonNull ContextSet other) {
|
||||||
|
return isSatisfiedBy(other, ContextSatisfyMode.AT_LEAST_ONE_VALUE_PER_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if this {@link ContextSet} is "satisfied" by another set, according to the given
|
||||||
|
* {@code mode}.
|
||||||
|
*
|
||||||
|
* @param other the other set
|
||||||
|
* @param mode the mode to use
|
||||||
|
* @return true if this context set is satisfied by the other
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
boolean isSatisfiedBy(@NonNull ContextSet other, @NonNull ContextSatisfyMode mode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the {@link ContextSet} is empty.
|
* Returns if the {@link ContextSet} is empty.
|
||||||
|
|||||||
@@ -26,18 +26,49 @@
|
|||||||
package net.luckperms.api.context;
|
package net.luckperms.api.context;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.ApiStatus.Internal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A factory for creating {@link ContextSet}s.
|
* A factory for creating {@link ContextSet}s.
|
||||||
|
*
|
||||||
|
* <p>Prefer using the static methods on {@link ImmutableContextSet} or {@link MutableContextSet}
|
||||||
|
* instead of this interface.</p>
|
||||||
*/
|
*/
|
||||||
|
@Internal
|
||||||
public interface ContextSetFactory {
|
public interface ContextSetFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefer using {@link ImmutableContextSet#builder()}.
|
||||||
|
*
|
||||||
|
* @return a immutable context set builder
|
||||||
|
* @see ImmutableContextSet#builder()
|
||||||
|
*/
|
||||||
ImmutableContextSet.@NonNull Builder immutableBuilder();
|
ImmutableContextSet.@NonNull Builder immutableBuilder();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefer using {@link ImmutableContextSet#of(String, String)}.
|
||||||
|
*
|
||||||
|
* @param key the key
|
||||||
|
* @param value the value
|
||||||
|
* @return an immutable context set
|
||||||
|
* @see ImmutableContextSet#of(String, String)
|
||||||
|
*/
|
||||||
@NonNull ImmutableContextSet immutableOf(@NonNull String key, @NonNull String value);
|
@NonNull ImmutableContextSet immutableOf(@NonNull String key, @NonNull String value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefer using {@link ImmutableContextSet#empty()}.
|
||||||
|
*
|
||||||
|
* @return an empty immutable context set
|
||||||
|
* @see ImmutableContextSet#empty()
|
||||||
|
*/
|
||||||
@NonNull ImmutableContextSet immutableEmpty();
|
@NonNull ImmutableContextSet immutableEmpty();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefer using {@link MutableContextSet#create()}.
|
||||||
|
*
|
||||||
|
* @return a new mutable context set
|
||||||
|
* @see MutableContextSet#create()
|
||||||
|
*/
|
||||||
@NonNull MutableContextSet mutable();
|
@NonNull MutableContextSet mutable();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -34,13 +34,31 @@ public final class DefaultContextKeys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The context key used to denote the subjects server.
|
* The context key used to denote the name of the subjects server.
|
||||||
*/
|
*/
|
||||||
public static final String SERVER_KEY = "server";
|
public static final String SERVER_KEY = "server";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The context key used to denote the subjects world.
|
* The context key used to denote the name of the subjects world.
|
||||||
*/
|
*/
|
||||||
public static final String WORLD_KEY = "world";
|
public static final String WORLD_KEY = "world";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The context key used to denote the dimension type of the subjects world.
|
||||||
|
*
|
||||||
|
* <p>Possible values: overworld, the_nether, the_end</p>
|
||||||
|
*
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final String DIMENSION_TYPE_KEY = "dimension-type";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The context key used to denote the subjects gamemode.
|
||||||
|
*
|
||||||
|
* <p>Possible values: survival, creative, adventure, spectator</p>
|
||||||
|
*
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static final String GAMEMODE_KEY = "gamemode";
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ public interface ImmutableContextSet extends ContextSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Already immutable!
|
* @deprecated This context set is already immutable!
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context functionality, including {@link net.luckperms.api.context.ContextSet}s and
|
||||||
|
* {@link net.luckperms.api.context.ContextCalculator}s.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.context;
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
package net.luckperms.api.event;
|
package net.luckperms.api.event;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -49,7 +50,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 <T extends LuckPermsEvent> EventSubscription<T> subscribe(@NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler);
|
<T extends LuckPermsEvent> @NonNull EventSubscription<T> subscribe(@NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a new subscription to the given event.
|
* Registers a new subscription to the given event.
|
||||||
@@ -69,7 +70,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 <T extends LuckPermsEvent> EventSubscription<T> subscribe(Object plugin, @NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler);
|
<T extends LuckPermsEvent> @NonNull EventSubscription<T> subscribe(Object plugin, @NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a set of all registered handlers for a given event.
|
* Gets a set of all registered handlers for a given event.
|
||||||
@@ -78,6 +79,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 <T extends LuckPermsEvent> Set<EventSubscription<T>> getSubscriptions(@NonNull Class<T> eventClass);
|
<T extends LuckPermsEvent> @NonNull @Unmodifiable Set<EventSubscription<T>> getSubscriptions(@NonNull Class<T> eventClass);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -35,6 +35,12 @@ public enum DeletionCause {
|
|||||||
*/
|
*/
|
||||||
COMMAND,
|
COMMAND,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The deletion was caused by the web editor
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
WEB_EDITOR,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The deletion was caused by an API call
|
* The deletion was caused by an API call
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event causes.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event.cause;
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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 net.luckperms.api.event.context;
|
||||||
|
|
||||||
|
import net.luckperms.api.context.ContextManager;
|
||||||
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import net.luckperms.api.event.util.Param;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a subject's current/active contexts are updated.
|
||||||
|
*
|
||||||
|
* <p>There are no guarantees that this event will be called for every update. It is merely to be
|
||||||
|
* used as a "hint" for plugins which depend on the current active contexts for a player.</p>
|
||||||
|
*
|
||||||
|
* <p>It will always be fired following a call to
|
||||||
|
* {@link ContextManager#signalContextUpdate(Object)}.</p>
|
||||||
|
*
|
||||||
|
* <p>The {@link #getSubject() subject} is always an instance of the platform's subject type. See
|
||||||
|
* {@link ContextManager} for details.</p>
|
||||||
|
*
|
||||||
|
* <p>Unlike most other LuckPerms events, this event is not fired asynchronously. Care should be
|
||||||
|
* taken to ensure listeners are lightweight. Additionally, listeners should ensure they do not
|
||||||
|
* cause further updates to player context, thus possibly causing a stack overflow.</p>
|
||||||
|
*
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
public interface ContextUpdateEvent extends LuckPermsEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the subject whose contexts were updated.
|
||||||
|
*
|
||||||
|
* @return the subject
|
||||||
|
*/
|
||||||
|
@Param(0)
|
||||||
|
@NonNull Object getSubject();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the subject whose contexts were updated, casted to a given type.
|
||||||
|
*
|
||||||
|
* @param subjectClass the type to cast to
|
||||||
|
* @param <T> the subject type
|
||||||
|
* @return the casted subject
|
||||||
|
*/
|
||||||
|
default <T> @NonNull Optional<T> getSubject(@NonNull Class<T> subjectClass) {
|
||||||
|
Object subject = getSubject();
|
||||||
|
return subjectClass.isInstance(subject) ? Optional.of(subjectClass.cast(subject)) : Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events relating to {@link net.luckperms.api.context.Context}s.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event.context;
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events relating to {@link net.luckperms.api.extension.Extension}s.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event.extension;
|
||||||
@@ -26,8 +26,8 @@
|
|||||||
package net.luckperms.api.event.group;
|
package net.luckperms.api.event.group;
|
||||||
|
|
||||||
import net.luckperms.api.event.LuckPermsEvent;
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
import net.luckperms.api.event.util.Param;
|
|
||||||
import net.luckperms.api.event.cause.CreationCause;
|
import net.luckperms.api.event.cause.CreationCause;
|
||||||
|
import net.luckperms.api.event.util.Param;
|
||||||
import net.luckperms.api.model.group.Group;
|
import net.luckperms.api.model.group.Group;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
package net.luckperms.api.event.group;
|
package net.luckperms.api.event.group;
|
||||||
|
|
||||||
import net.luckperms.api.event.LuckPermsEvent;
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
import net.luckperms.api.event.util.Param;
|
|
||||||
import net.luckperms.api.event.cause.DeletionCause;
|
import net.luckperms.api.event.cause.DeletionCause;
|
||||||
|
import net.luckperms.api.event.util.Param;
|
||||||
import net.luckperms.api.node.Node;
|
import net.luckperms.api.node.Node;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events relating to {@link net.luckperms.api.model.group.Group}s.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event.group;
|
||||||
@@ -26,8 +26,8 @@
|
|||||||
package net.luckperms.api.event.log;
|
package net.luckperms.api.event.log;
|
||||||
|
|
||||||
import net.luckperms.api.actionlog.Action;
|
import net.luckperms.api.actionlog.Action;
|
||||||
import net.luckperms.api.event.type.Cancellable;
|
|
||||||
import net.luckperms.api.event.LuckPermsEvent;
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import net.luckperms.api.event.type.Cancellable;
|
||||||
import net.luckperms.api.event.util.Param;
|
import net.luckperms.api.event.util.Param;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
package net.luckperms.api.event.log;
|
package net.luckperms.api.event.log;
|
||||||
|
|
||||||
import net.luckperms.api.actionlog.Action;
|
import net.luckperms.api.actionlog.Action;
|
||||||
import net.luckperms.api.event.type.Cancellable;
|
|
||||||
import net.luckperms.api.event.LuckPermsEvent;
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import net.luckperms.api.event.type.Cancellable;
|
||||||
import net.luckperms.api.event.util.Param;
|
import net.luckperms.api.event.util.Param;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
package net.luckperms.api.event.log;
|
package net.luckperms.api.event.log;
|
||||||
|
|
||||||
import net.luckperms.api.actionlog.Action;
|
import net.luckperms.api.actionlog.Action;
|
||||||
import net.luckperms.api.event.type.Cancellable;
|
|
||||||
import net.luckperms.api.event.LuckPermsEvent;
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import net.luckperms.api.event.type.Cancellable;
|
||||||
import net.luckperms.api.event.util.Param;
|
import net.luckperms.api.event.util.Param;
|
||||||
import net.luckperms.api.platform.PlatformEntity;
|
import net.luckperms.api.platform.PlatformEntity;
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
package net.luckperms.api.event.log;
|
package net.luckperms.api.event.log;
|
||||||
|
|
||||||
import net.luckperms.api.actionlog.Action;
|
import net.luckperms.api.actionlog.Action;
|
||||||
import net.luckperms.api.event.type.Cancellable;
|
|
||||||
import net.luckperms.api.event.LuckPermsEvent;
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import net.luckperms.api.event.type.Cancellable;
|
||||||
import net.luckperms.api.event.util.Param;
|
import net.luckperms.api.event.util.Param;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events relating to the {@link net.luckperms.api.actionlog.ActionLog}.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event.log;
|
||||||
@@ -29,6 +29,11 @@ import net.luckperms.api.event.util.Param;
|
|||||||
import net.luckperms.api.node.Node;
|
import net.luckperms.api.node.Node;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a node is added to a holder
|
* Called when a node is added to a holder
|
||||||
@@ -40,7 +45,14 @@ public interface NodeAddEvent extends NodeMutateEvent {
|
|||||||
*
|
*
|
||||||
* @return the node that was added
|
* @return the node that was added
|
||||||
*/
|
*/
|
||||||
@Param(4)
|
@Param(3)
|
||||||
@NonNull Node getNode();
|
@NonNull Node getNode();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default @NonNull @Unmodifiable Set<Node> getDataBefore() {
|
||||||
|
// Get data after, then reverse the action
|
||||||
|
Set<Node> nodes = new HashSet<>(this.getDataAfter());
|
||||||
|
nodes.remove(this.getNode());
|
||||||
|
return Collections.unmodifiableSet(nodes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -25,9 +25,35 @@
|
|||||||
|
|
||||||
package net.luckperms.api.event.node;
|
package net.luckperms.api.event.node;
|
||||||
|
|
||||||
|
import net.luckperms.api.event.util.Param;
|
||||||
|
import net.luckperms.api.node.Node;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a holder has their nodes cleared
|
* Called when a holder has their nodes cleared
|
||||||
*/
|
*/
|
||||||
public interface NodeClearEvent extends NodeMutateEvent {
|
public interface NodeClearEvent extends NodeMutateEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the nodes that were cleared
|
||||||
|
*
|
||||||
|
* @return the nodes that were removed
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
@Param(3)
|
||||||
|
@NonNull @Unmodifiable Set<Node> getNodes();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default @NonNull @Unmodifiable Set<Node> getDataBefore() {
|
||||||
|
// Get data after, then reverse the action
|
||||||
|
Set<Node> nodes = new HashSet<>(this.getDataAfter());
|
||||||
|
nodes.addAll(this.getNodes());
|
||||||
|
return Collections.unmodifiableSet(nodes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,7 @@ import net.luckperms.api.model.user.User;
|
|||||||
import net.luckperms.api.node.Node;
|
import net.luckperms.api.node.Node;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -63,16 +64,15 @@ public interface NodeMutateEvent extends LuckPermsEvent {
|
|||||||
*
|
*
|
||||||
* @return the data before the change
|
* @return the data before the change
|
||||||
*/
|
*/
|
||||||
@Param(2)
|
@NonNull @Unmodifiable Set<Node> getDataBefore();
|
||||||
@NonNull 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
|
||||||
*/
|
*/
|
||||||
@Param(3)
|
@Param(2)
|
||||||
@NonNull Set<Node> getDataAfter();
|
@NonNull @Unmodifiable Set<Node> getDataAfter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets whether the target of this event is a {@link User}
|
* Gets whether the target of this event is a {@link User}
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ import net.luckperms.api.event.util.Param;
|
|||||||
import net.luckperms.api.node.Node;
|
import net.luckperms.api.node.Node;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a node is removed from a holder
|
* Called when a node is removed from a holder
|
||||||
@@ -40,7 +45,15 @@ public interface NodeRemoveEvent extends NodeMutateEvent {
|
|||||||
*
|
*
|
||||||
* @return the node that was removed
|
* @return the node that was removed
|
||||||
*/
|
*/
|
||||||
@Param(4)
|
@Param(3)
|
||||||
@NonNull Node getNode();
|
@NonNull Node getNode();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default @NonNull @Unmodifiable Set<Node> getDataBefore() {
|
||||||
|
// Get data after, then reverse the action
|
||||||
|
Set<Node> nodes = new HashSet<>(this.getDataAfter());
|
||||||
|
nodes.add(this.getNode());
|
||||||
|
return Collections.unmodifiableSet(nodes);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events relating to changes to a {@link net.luckperms.api.model.user.User} or
|
||||||
|
* {@link net.luckperms.api.model.group.Group}s {@link net.luckperms.api.model.data.NodeMap}.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event.node;
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main events package.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event;
|
||||||
+86
@@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* 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 net.luckperms.api.event.player.lookup;
|
||||||
|
|
||||||
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import net.luckperms.api.event.type.ResultEvent;
|
||||||
|
import net.luckperms.api.event.util.Param;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the platform needs to determine the type of a player's {@link UUID unique id}.
|
||||||
|
*
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public interface UniqueIdDetermineTypeEvent extends LuckPermsEvent, ResultEvent<String> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The players UUID has been obtained by authenticating with the Mojang session servers.
|
||||||
|
*
|
||||||
|
* <p>Usually indicated by the UUID being {@link UUID#version() version} 4.</p>
|
||||||
|
*/
|
||||||
|
String TYPE_AUTHENTICATED = "authenticated";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The players UUID has not been obtained through authentication, and instead is likely based
|
||||||
|
* on the username they connected with.
|
||||||
|
*
|
||||||
|
* <p>Usually indicated by the UUID being {@link UUID#version() version} 3.</p>
|
||||||
|
*/
|
||||||
|
String TYPE_UNAUTHENTICATED = "unauthenticated";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link UUID unique id} being queried.
|
||||||
|
*
|
||||||
|
* @return the unique id
|
||||||
|
*/
|
||||||
|
@Param(0)
|
||||||
|
@NonNull UUID getUniqueId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current result unique id type.
|
||||||
|
*
|
||||||
|
* @return the type
|
||||||
|
*/
|
||||||
|
default @NonNull String getType() {
|
||||||
|
return result().get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the result unique id type.
|
||||||
|
*
|
||||||
|
* @param type the type
|
||||||
|
*/
|
||||||
|
default void setType(@NonNull String type) {
|
||||||
|
Objects.requireNonNull(type, "type");
|
||||||
|
result().set(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* 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 net.luckperms.api.event.player.lookup;
|
||||||
|
|
||||||
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import net.luckperms.api.event.type.ResultEvent;
|
||||||
|
import net.luckperms.api.event.util.Param;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the platform needs a unique id for a given username.
|
||||||
|
*
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public interface UniqueIdLookupEvent extends LuckPermsEvent, ResultEvent<UUID> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the username being looked up.
|
||||||
|
*
|
||||||
|
* @return the username
|
||||||
|
*/
|
||||||
|
@Param(0)
|
||||||
|
@NonNull String getUsername();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the result unique id.
|
||||||
|
*
|
||||||
|
* @param uniqueId the unique id
|
||||||
|
*/
|
||||||
|
default void setUniqueId(@Nullable UUID uniqueId) {
|
||||||
|
result().set(uniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* 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 net.luckperms.api.event.player.lookup;
|
||||||
|
|
||||||
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import net.luckperms.api.event.type.ResultEvent;
|
||||||
|
import net.luckperms.api.event.util.Param;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the platform needs a username for a given unique id.
|
||||||
|
*
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public interface UsernameLookupEvent extends LuckPermsEvent, ResultEvent<String> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link UUID unique id} being looked up.
|
||||||
|
*
|
||||||
|
* @return the unique id
|
||||||
|
*/
|
||||||
|
@Param(0)
|
||||||
|
@NonNull UUID getUniqueId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the result username.
|
||||||
|
*
|
||||||
|
* @param username the username
|
||||||
|
*/
|
||||||
|
default void setUsername(@Nullable String username) {
|
||||||
|
result().set(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+28
-22
@@ -23,48 +23,54 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.metastacking;
|
package net.luckperms.api.event.player.lookup;
|
||||||
|
|
||||||
import net.luckperms.api.metastacking.MetaStackDefinition;
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
import net.luckperms.api.node.ChatMetaType;
|
import net.luckperms.api.event.util.Param;
|
||||||
import net.luckperms.api.node.types.ChatMetaNode;
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A live stack of {@link MetaStackEntry} instances, formed from a
|
* Called when the validity of a username is being tested.
|
||||||
* {@link MetaStackDefinition}.
|
|
||||||
*
|
*
|
||||||
* This class is used to construct a formatted string, by accumulating
|
* @since 5.3
|
||||||
* nodes to each element.
|
|
||||||
*/
|
*/
|
||||||
public interface MetaStack {
|
public interface UsernameValidityCheckEvent extends LuckPermsEvent {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the definition this stack is based upon
|
* Gets the username being tested.
|
||||||
*
|
*
|
||||||
* @return the definition of the stack
|
* @return the username
|
||||||
*/
|
*/
|
||||||
MetaStackDefinition getDefinition();
|
@Param(0)
|
||||||
|
@NonNull String getUsername();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the target of this stack
|
* Gets the current validity state for the username.
|
||||||
*
|
*
|
||||||
* @return the stack target
|
* @return the validity state
|
||||||
*/
|
*/
|
||||||
ChatMetaType getTargetType();
|
@Param(1)
|
||||||
|
@NonNull AtomicBoolean validityState();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a formatted string, as defined by the {@link MetaStackDefinition},
|
* Gets if the username is currently considered to be valid.
|
||||||
* using the accumulated elements in the stack.
|
|
||||||
*
|
*
|
||||||
* @return the string output
|
* @return if the username is valid
|
||||||
*/
|
*/
|
||||||
String toFormattedString();
|
default boolean isValid() {
|
||||||
|
return validityState().get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to accumulate the given node to all elements in the stack.
|
* Sets if the username should be considered valid or not.
|
||||||
*
|
*
|
||||||
* @param node the node to accumulate
|
* @param valid whether the username is valid
|
||||||
*/
|
*/
|
||||||
void accumulateToAll(ChatMetaNode<?, ?> node);
|
default void setValid(boolean valid) {
|
||||||
|
validityState().set(valid);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events relating to a player {@link java.util.UUID unique id} or username lookup.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event.player.lookup;
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events relating to a player.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event.player;
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event sources.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event.source;
|
||||||
@@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
package net.luckperms.api.event.sync;
|
package net.luckperms.api.event.sync;
|
||||||
|
|
||||||
import net.luckperms.api.event.type.Cancellable;
|
|
||||||
import net.luckperms.api.event.LuckPermsEvent;
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import net.luckperms.api.event.type.Cancellable;
|
||||||
import net.luckperms.api.event.util.Param;
|
import net.luckperms.api.event.util.Param;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|||||||
@@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
package net.luckperms.api.event.sync;
|
package net.luckperms.api.event.sync;
|
||||||
|
|
||||||
import net.luckperms.api.event.type.Cancellable;
|
|
||||||
import net.luckperms.api.event.LuckPermsEvent;
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import net.luckperms.api.event.type.Cancellable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before a sync task runs
|
* Called before a sync task runs
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events relating to {@link net.luckperms.api.LuckPerms#runUpdateTask() sync/update task}s.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event.sync;
|
||||||
@@ -26,8 +26,8 @@
|
|||||||
package net.luckperms.api.event.track;
|
package net.luckperms.api.event.track;
|
||||||
|
|
||||||
import net.luckperms.api.event.LuckPermsEvent;
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
import net.luckperms.api.event.util.Param;
|
|
||||||
import net.luckperms.api.event.cause.CreationCause;
|
import net.luckperms.api.event.cause.CreationCause;
|
||||||
|
import net.luckperms.api.event.util.Param;
|
||||||
import net.luckperms.api.track.Track;
|
import net.luckperms.api.track.Track;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
package net.luckperms.api.event.track;
|
package net.luckperms.api.event.track;
|
||||||
|
|
||||||
import net.luckperms.api.event.LuckPermsEvent;
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
import net.luckperms.api.event.util.Param;
|
|
||||||
import net.luckperms.api.event.cause.DeletionCause;
|
import net.luckperms.api.event.cause.DeletionCause;
|
||||||
|
import net.luckperms.api.event.util.Param;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import net.luckperms.api.event.util.Param;
|
|||||||
import net.luckperms.api.track.Track;
|
import net.luckperms.api.track.Track;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ public interface TrackMutateEvent extends LuckPermsEvent {
|
|||||||
* @return the data before the change
|
* @return the data before the change
|
||||||
*/
|
*/
|
||||||
@Param(1)
|
@Param(1)
|
||||||
@NonNull List<String> getStateBefore();
|
@NonNull @Unmodifiable List<String> getStateBefore();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an immutable copy of the tracks data after the change
|
* Gets an immutable copy of the tracks data after the change
|
||||||
@@ -60,6 +61,6 @@ public interface TrackMutateEvent extends LuckPermsEvent {
|
|||||||
* @return the data after the change
|
* @return the data after the change
|
||||||
*/
|
*/
|
||||||
@Param(2)
|
@Param(2)
|
||||||
@NonNull List<String> getStateAfter();
|
@NonNull @Unmodifiable List<String> getStateAfter();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events relating to changes to a {@link net.luckperms.api.track.Track}s contents.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event.track.mutate;
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events relating to {@link net.luckperms.api.track.Track}s.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event.track;
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* 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 net.luckperms.api.event.type;
|
||||||
|
|
||||||
|
import net.luckperms.api.event.util.Param;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an event that has a result.
|
||||||
|
*
|
||||||
|
* @param <T> the type of the result
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public interface ResultEvent<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an {@link AtomicReference} containing the result.
|
||||||
|
*
|
||||||
|
* @return the result
|
||||||
|
*/
|
||||||
|
@Param(-1)
|
||||||
|
@NonNull AtomicReference<T> result();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets if a result has been set for the event.
|
||||||
|
*
|
||||||
|
* @return if there is a result
|
||||||
|
*/
|
||||||
|
default boolean hasResult() {
|
||||||
|
return result().get() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event abstract types.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event.type;
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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 net.luckperms.api.event.user;
|
||||||
|
|
||||||
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
|
import net.luckperms.api.event.type.Cancellable;
|
||||||
|
import net.luckperms.api.event.util.Param;
|
||||||
|
import net.luckperms.api.model.user.User;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a user is about to be unloaded from memory.
|
||||||
|
*
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public interface UserUnloadEvent extends LuckPermsEvent, Cancellable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the user that is being unloaded
|
||||||
|
*
|
||||||
|
* @return the user that is being unloaded
|
||||||
|
*/
|
||||||
|
@Param(0)
|
||||||
|
@NonNull User getUser();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events relating to {@link net.luckperms.api.model.user.User}s.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event.user;
|
||||||
@@ -26,8 +26,8 @@
|
|||||||
package net.luckperms.api.event.user.track;
|
package net.luckperms.api.event.user.track;
|
||||||
|
|
||||||
import net.luckperms.api.event.LuckPermsEvent;
|
import net.luckperms.api.event.LuckPermsEvent;
|
||||||
import net.luckperms.api.event.util.Param;
|
|
||||||
import net.luckperms.api.event.type.Sourced;
|
import net.luckperms.api.event.type.Sourced;
|
||||||
|
import net.luckperms.api.event.util.Param;
|
||||||
import net.luckperms.api.model.user.User;
|
import net.luckperms.api.model.user.User;
|
||||||
import net.luckperms.api.track.Track;
|
import net.luckperms.api.track.Track;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events relating to a {@link net.luckperms.api.model.user.User}s movement on a
|
||||||
|
* {@link net.luckperms.api.track.Track}.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event.user.track;
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event utilities.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.event.util;
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
package net.luckperms.api.extension;
|
package net.luckperms.api.extension;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -57,6 +58,6 @@ public interface ExtensionManager {
|
|||||||
*
|
*
|
||||||
* @return the loaded extensions
|
* @return the loaded extensions
|
||||||
*/
|
*/
|
||||||
@NonNull Collection<Extension> getLoadedExtensions();
|
@NonNull @Unmodifiable Collection<Extension> getLoadedExtensions();
|
||||||
|
|
||||||
}
|
}
|
||||||
+4
-7
@@ -23,10 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.util;
|
/**
|
||||||
|
* {@link net.luckperms.api.extension.Extension}s functionality.
|
||||||
public interface ThrowingRunnable {
|
*/
|
||||||
|
package net.luckperms.api.extension;
|
||||||
void run() throws Exception;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -40,7 +40,7 @@ public interface MessagingService {
|
|||||||
*
|
*
|
||||||
* @return the name of this messaging service
|
* @return the name of this messaging service
|
||||||
*/
|
*/
|
||||||
String getName();
|
@NonNull String getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses the messaging service to inform other servers about a general
|
* Uses the messaging service to inform other servers about a general
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link net.luckperms.api.messaging.MessagingService} functionality.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.messaging;
|
||||||
@@ -29,11 +29,13 @@ import net.luckperms.api.messenger.message.Message;
|
|||||||
import net.luckperms.api.messenger.message.OutgoingMessage;
|
import net.luckperms.api.messenger.message.OutgoingMessage;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.ApiStatus.NonExtendable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates the LuckPerms system which accepts incoming {@link Message}s
|
* Encapsulates the LuckPerms system which accepts incoming {@link Message}s
|
||||||
* from implementations of {@link Messenger}.
|
* from implementations of {@link Messenger}.
|
||||||
*/
|
*/
|
||||||
|
@NonExtendable
|
||||||
public interface IncomingMessageConsumer {
|
public interface IncomingMessageConsumer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,10 +29,12 @@ import net.luckperms.api.messenger.message.Message;
|
|||||||
import net.luckperms.api.messenger.message.OutgoingMessage;
|
import net.luckperms.api.messenger.message.OutgoingMessage;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.ApiStatus.OverrideOnly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an object which dispatches {@link OutgoingMessage}s.
|
* Represents an object which dispatches {@link OutgoingMessage}s.
|
||||||
*/
|
*/
|
||||||
|
@OverrideOnly
|
||||||
public interface Messenger extends AutoCloseable {
|
public interface Messenger extends AutoCloseable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ package net.luckperms.api.messenger;
|
|||||||
import net.luckperms.api.LuckPerms;
|
import net.luckperms.api.LuckPerms;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.ApiStatus.OverrideOnly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a provider for {@link Messenger} instances.
|
* Represents a provider for {@link Messenger} instances.
|
||||||
@@ -37,6 +38,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
*
|
*
|
||||||
* @see LuckPerms#registerMessengerProvider(MessengerProvider)
|
* @see LuckPerms#registerMessengerProvider(MessengerProvider)
|
||||||
*/
|
*/
|
||||||
|
@OverrideOnly
|
||||||
public interface MessengerProvider {
|
public interface MessengerProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -28,12 +28,14 @@ package net.luckperms.api.messenger.message;
|
|||||||
import net.luckperms.api.messenger.Messenger;
|
import net.luckperms.api.messenger.Messenger;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.ApiStatus.NonExtendable;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a message sent received via a {@link Messenger}.
|
* Represents a message sent received via a {@link Messenger}.
|
||||||
*/
|
*/
|
||||||
|
@NonExtendable
|
||||||
public interface Message {
|
public interface Message {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link net.luckperms.api.messenger.Messenger} message abstract types.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.messenger.message;
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link net.luckperms.api.messenger.Messenger} message actual types.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.messenger.message.type;
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link net.luckperms.api.messenger.Messenger} provider API.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.messenger;
|
||||||
@@ -28,6 +28,7 @@ package net.luckperms.api.metastacking;
|
|||||||
import net.luckperms.api.query.OptionKey;
|
import net.luckperms.api.query.OptionKey;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ public interface MetaStackDefinition {
|
|||||||
*
|
*
|
||||||
* @return the elements in this stack
|
* @return the elements in this stack
|
||||||
*/
|
*/
|
||||||
@NonNull List<MetaStackElement> getElements();
|
@NonNull @Unmodifiable List<MetaStackElement> getElements();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the duplicate removal function, applied to the entries before
|
* Gets the duplicate removal function, applied to the entries before
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
package net.luckperms.api.metastacking;
|
package net.luckperms.api.metastacking;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -51,7 +52,7 @@ public interface MetaStackFactory {
|
|||||||
* @param definitions the definition strings
|
* @param definitions the definition strings
|
||||||
* @return a list of parsed elements
|
* @return a list of parsed elements
|
||||||
*/
|
*/
|
||||||
@NonNull List<MetaStackElement> fromStrings(@NonNull List<String> definitions);
|
@NonNull @Unmodifiable List<MetaStackElement> fromStrings(@NonNull List<String> definitions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link MetaStackDefinition} with the given properties.
|
* Creates a new {@link MetaStackDefinition} with the given properties.
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link net.luckperms.api.metastacking.MetaStackDefinition Meta stacking} functionality.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.metastacking;
|
||||||
@@ -26,18 +26,25 @@
|
|||||||
package net.luckperms.api.model;
|
package net.luckperms.api.model;
|
||||||
|
|
||||||
import net.luckperms.api.cacheddata.CachedDataManager;
|
import net.luckperms.api.cacheddata.CachedDataManager;
|
||||||
|
import net.luckperms.api.context.ContextManager;
|
||||||
import net.luckperms.api.model.data.DataType;
|
import net.luckperms.api.model.data.DataType;
|
||||||
import net.luckperms.api.model.data.NodeMap;
|
import net.luckperms.api.model.data.NodeMap;
|
||||||
import net.luckperms.api.model.group.Group;
|
import net.luckperms.api.model.group.Group;
|
||||||
import net.luckperms.api.model.user.User;
|
import net.luckperms.api.model.user.User;
|
||||||
import net.luckperms.api.node.Node;
|
import net.luckperms.api.node.Node;
|
||||||
|
import net.luckperms.api.node.NodeType;
|
||||||
|
import net.luckperms.api.query.Flag;
|
||||||
import net.luckperms.api.query.QueryOptions;
|
import net.luckperms.api.query.QueryOptions;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic superinterface for an object which holds permissions.
|
* Generic superinterface for an object which holds permissions.
|
||||||
@@ -108,6 +115,24 @@ public interface PermissionHolder {
|
|||||||
*/
|
*/
|
||||||
@NonNull String getFriendlyName();
|
@NonNull String getFriendlyName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the most appropriate query options available at the time for the
|
||||||
|
* {@link PermissionHolder}.
|
||||||
|
*
|
||||||
|
* <p>For {@link User}s, the most appropriate query options will be their
|
||||||
|
* {@link ContextManager#getQueryOptions(User) current active query options} if the
|
||||||
|
* corresponding player is online, and otherwise, will fallback to
|
||||||
|
* {@link ContextManager#getStaticQueryOptions() the current static query options}
|
||||||
|
* if they are offline.</p>
|
||||||
|
*
|
||||||
|
* <p>For {@link Group}s, the most appropriate query options will always be
|
||||||
|
* {@link ContextManager#getStaticQueryOptions()} the current static query options.</p>
|
||||||
|
*
|
||||||
|
* @return query options
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
@NonNull QueryOptions getQueryOptions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the holders {@link CachedDataManager} cache.
|
* Gets the holders {@link CachedDataManager} cache.
|
||||||
*
|
*
|
||||||
@@ -121,7 +146,7 @@ public interface PermissionHolder {
|
|||||||
* @param dataType the data type
|
* @param dataType the data type
|
||||||
* @return the data
|
* @return the data
|
||||||
*/
|
*/
|
||||||
NodeMap getData(@NonNull DataType dataType);
|
@NonNull NodeMap getData(@NonNull DataType dataType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the holders {@link DataType#NORMAL} data.
|
* Gets the holders {@link DataType#NORMAL} data.
|
||||||
@@ -149,35 +174,60 @@ public interface PermissionHolder {
|
|||||||
@NonNull NodeMap transientData();
|
@NonNull NodeMap transientData();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a flattened/squashed view of the holders permissions.
|
* Gets a flattened view of the holders own {@link Node}s.
|
||||||
*
|
*
|
||||||
* <p>This list is constructed using the values
|
* <p>This list is constructed using the values of both the {@link #data() normal}
|
||||||
* of both the transient and enduring backing multimaps.</p>
|
* and {@link #transientData() transient} backing node maps.</p>
|
||||||
*
|
*
|
||||||
* <p>This means that it <b>may contain</b> duplicate entries.</p>
|
* <p>It <b>may contain</b> duplicate entries if the same node is added to both the normal
|
||||||
*
|
* and transient node maps. You can use {@link #getDistinctNodes()} for a view without
|
||||||
* <p>Use {@link #getDistinctNodes()} for a view without duplicates.</p>
|
* duplicates.</p>
|
||||||
*
|
*
|
||||||
* <p>This method <b>does not</b> resolve inheritance rules.</p>
|
* <p>This method <b>does not</b> resolve inheritance rules.</p>
|
||||||
*
|
*
|
||||||
* @return a list of the holders own nodes.
|
* @return a collection of the holders own nodes.
|
||||||
*/
|
*/
|
||||||
@NonNull Collection<Node> getNodes();
|
default @NonNull @Unmodifiable Collection<Node> getNodes() {
|
||||||
|
/* This default method is overridden in the implementation, and is just here
|
||||||
|
to demonstrate what this method does in the API sources. */
|
||||||
|
List<Node> nodes = new ArrayList<>();
|
||||||
|
nodes.addAll(data().toCollection());
|
||||||
|
nodes.addAll(transientData().toCollection());
|
||||||
|
return nodes;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a sorted set of all held nodes.
|
* Gets a flattened view of the holders own {@link Node}s of the given {@code type}.
|
||||||
|
*
|
||||||
|
* @param type the type of node to filter by
|
||||||
|
* @param <T> the node type
|
||||||
|
* @return a filtered collection of the holders own nodes
|
||||||
|
* @see #getNodes()
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
default <T extends Node> @NonNull @Unmodifiable Collection<T> getNodes(@NonNull NodeType<T> type) {
|
||||||
|
/* This default method is overridden in the implementation, and is just here
|
||||||
|
to demonstrate what this method does in the API sources. */
|
||||||
|
return getNodes().stream()
|
||||||
|
.filter(type::matches)
|
||||||
|
.map(type::cast)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a flattened and sorted view of the holders own distinct {@link Node}s.
|
||||||
*
|
*
|
||||||
* <p>Effectively a sorted version of {@link #getNodes()}, without duplicates. Use the
|
* <p>Effectively a sorted version of {@link #getNodes()}, without duplicates. Use the
|
||||||
* aforementioned method if you don't require either of these attributes.</p>
|
* aforementioned method if you don't require either of these attributes.</p>
|
||||||
*
|
*
|
||||||
* <p>This method <b>does not</b> resolve inheritance rules.</p>
|
* <p>This method <b>does not</b> resolve inheritance rules.</p>
|
||||||
*
|
*
|
||||||
* @return an immutable set of permissions in priority order
|
* @return a sorted set of the holders own distinct nodes
|
||||||
*/
|
*/
|
||||||
@NonNull SortedSet<Node> getDistinctNodes();
|
@NonNull @Unmodifiable SortedSet<Node> getDistinctNodes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively resolves this holders permissions.
|
* Gets a resolved view of the holders own and inherited {@link Node}s.
|
||||||
*
|
*
|
||||||
* <p>The returned list will contain every inherited
|
* <p>The returned list will contain every inherited
|
||||||
* node the holder has, in the order that they were inherited in.</p>
|
* node the holder has, in the order that they were inherited in.</p>
|
||||||
@@ -189,21 +239,65 @@ public interface PermissionHolder {
|
|||||||
* with the entries from the end of the inheritance tree appearing last.</p>
|
* with the entries from the end of the inheritance tree appearing last.</p>
|
||||||
*
|
*
|
||||||
* @param queryOptions the query options
|
* @param queryOptions the query options
|
||||||
* @return a list of nodes
|
* @return a list of the holders inherited nodes
|
||||||
*/
|
*/
|
||||||
@NonNull Collection<Node> resolveInheritedNodes(@NonNull QueryOptions queryOptions);
|
@NonNull @Unmodifiable Collection<Node> resolveInheritedNodes(@NonNull QueryOptions queryOptions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a mutable sorted set of the nodes that this object has and inherits, filtered by context
|
* Gets a resolved view of the holders own and inherited {@link Node}s of a given {@code type}.
|
||||||
*
|
*
|
||||||
* <p>Nodes are sorted into priority order. The order of inheritance is only important during
|
* @param type the type of node to filter by
|
||||||
* the process of flattening inherited entries.</p>
|
* @param queryOptions the query options
|
||||||
|
* @param <T> the node type
|
||||||
|
* @return a filtered list of the holders inherited nodes
|
||||||
|
* @see #resolveInheritedNodes(QueryOptions)
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
default <T extends Node> @NonNull @Unmodifiable Collection<T> resolveInheritedNodes(@NonNull NodeType<T> type, @NonNull QueryOptions queryOptions) {
|
||||||
|
/* This default method is overridden in the implementation, and is just here
|
||||||
|
to demonstrate what this method does in the API sources. */
|
||||||
|
return resolveInheritedNodes(queryOptions).stream()
|
||||||
|
.filter(type::matches)
|
||||||
|
.map(type::cast)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a resolved and sorted view of the holders own and inherited distinct {@link Node}s.
|
||||||
|
*
|
||||||
|
* <p>Effectively a sorted version of {@link #resolveInheritedNodes(QueryOptions)},
|
||||||
|
* without duplicates. Use the aforementioned method if you don't require either of these
|
||||||
|
* attributes.</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 queryOptions the query options
|
* @param queryOptions the query options
|
||||||
* @return an immutable sorted set of permissions
|
* @return a sorted set of the holders distinct inherited nodes
|
||||||
* @throws NullPointerException if the context is null
|
|
||||||
*/
|
*/
|
||||||
@NonNull SortedSet<Node> resolveDistinctInheritedNodes(@NonNull QueryOptions queryOptions);
|
@NonNull @Unmodifiable SortedSet<Node> resolveDistinctInheritedNodes(@NonNull QueryOptions queryOptions);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a collection of the {@link Group}s this holder inherits nodes from.
|
||||||
|
*
|
||||||
|
* <p>If {@link Flag#RESOLVE_INHERITANCE} is set, this will include holders inherited from both
|
||||||
|
* directly and indirectly (through directly inherited groups). It will effectively resolve the
|
||||||
|
* whole "inheritance tree".</p>
|
||||||
|
*
|
||||||
|
* <p>If {@link Flag#RESOLVE_INHERITANCE} is not set, then the traversal will only go one
|
||||||
|
* level up the inheritance tree, and return only directly inherited groups.</p>
|
||||||
|
*
|
||||||
|
* <p>The collection will be ordered according to the platforms inheritance rules. The groups
|
||||||
|
* which are inherited from first will appear earlier in the list.</p>
|
||||||
|
*
|
||||||
|
* <p>The list will not contain the holder.</p>
|
||||||
|
*
|
||||||
|
* @param queryOptions the query options
|
||||||
|
* @return a collection of the groups the holder inherits from
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
@NonNull @Unmodifiable Collection<Group> getInheritedGroups(@NonNull QueryOptions queryOptions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes any temporary permissions that have expired.
|
* Removes any temporary permissions that have expired.
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import net.luckperms.api.model.user.UserManager;
|
|||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -47,7 +48,7 @@ public interface PlayerSaveResult {
|
|||||||
*
|
*
|
||||||
* @return the status
|
* @return the status
|
||||||
*/
|
*/
|
||||||
@NonNull Set<Outcome> getOutcomes();
|
@NonNull @Unmodifiable Set<Outcome> getOutcomes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if the result includes a certain outcome.
|
* Gets if the result includes a certain outcome.
|
||||||
@@ -80,7 +81,7 @@ public interface PlayerSaveResult {
|
|||||||
* @return the other uuids
|
* @return the other uuids
|
||||||
* @see Outcome#OTHER_UNIQUE_IDS_PRESENT_FOR_USERNAME
|
* @see Outcome#OTHER_UNIQUE_IDS_PRESENT_FOR_USERNAME
|
||||||
*/
|
*/
|
||||||
@Nullable Set<UUID> getOtherUniqueIds();
|
@Nullable @Unmodifiable Set<UUID> getOtherUniqueIds();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The various states the result can take
|
* The various states the result can take
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import net.luckperms.api.node.NodeEqualityPredicate;
|
|||||||
import net.luckperms.api.util.Tristate;
|
import net.luckperms.api.util.Tristate;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -65,7 +66,7 @@ public interface NodeMap {
|
|||||||
*
|
*
|
||||||
* @return a map of nodes
|
* @return a map of nodes
|
||||||
*/
|
*/
|
||||||
@NonNull Map<ImmutableContextSet, Collection<Node>> toMap();
|
@NonNull @Unmodifiable Map<ImmutableContextSet, Collection<Node>> toMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a flattened view of {@link Node}s contained within this instance.
|
* Gets a flattened view of {@link Node}s contained within this instance.
|
||||||
@@ -75,7 +76,7 @@ public interface NodeMap {
|
|||||||
*
|
*
|
||||||
* @return a flattened collection of nodes
|
* @return a flattened collection of nodes
|
||||||
*/
|
*/
|
||||||
@NonNull Collection<Node> toCollection();
|
@NonNull @Unmodifiable Collection<Node> toCollection();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if this instance contains a given {@link Node}.
|
* Gets if this instance contains a given {@link Node}.
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link net.luckperms.api.model.PermissionHolder}
|
||||||
|
* ({@link net.luckperms.api.model.user.User}/{@link net.luckperms.api.model.group.Group}) data.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.model.data;
|
||||||
@@ -26,11 +26,16 @@
|
|||||||
package net.luckperms.api.model.group;
|
package net.luckperms.api.model.group;
|
||||||
|
|
||||||
import net.luckperms.api.node.HeldNode;
|
import net.luckperms.api.node.HeldNode;
|
||||||
|
import net.luckperms.api.node.Node;
|
||||||
|
import net.luckperms.api.node.matcher.NodeMatcher;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
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;
|
||||||
@@ -98,6 +103,27 @@ public interface GroupManager {
|
|||||||
*/
|
*/
|
||||||
@NonNull CompletableFuture<Void> deleteGroup(@NonNull Group group);
|
@NonNull CompletableFuture<Void> deleteGroup(@NonNull Group group);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads (or creates) a group from the plugin's storage provider, applies the given
|
||||||
|
* {@code action}, then saves the group's data back to storage.
|
||||||
|
*
|
||||||
|
* <p>This method effectively calls {@link #createAndLoadGroup(String)}, followed by the
|
||||||
|
* {@code action}, then {@link #saveGroup(Group)}, and returns an encapsulation of the whole
|
||||||
|
* process as a {@link CompletableFuture}. </p>
|
||||||
|
*
|
||||||
|
* @param name the name of the group
|
||||||
|
* @param action the action to apply to the group
|
||||||
|
* @return a future to encapsulate the operation
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
default @NonNull CompletableFuture<Void> modifyGroup(@NonNull String name, @NonNull Consumer<? super Group> action) {
|
||||||
|
/* This default method is overridden in the implementation, and is just here
|
||||||
|
to demonstrate what this method does in the API sources. */
|
||||||
|
return createAndLoadGroup(name)
|
||||||
|
.thenApplyAsync(group -> { action.accept(group); return group; })
|
||||||
|
.thenCompose(this::saveGroup);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all groups into memory.
|
* Loads all groups into memory.
|
||||||
*
|
*
|
||||||
@@ -105,14 +131,26 @@ public interface GroupManager {
|
|||||||
*/
|
*/
|
||||||
@NonNull CompletableFuture<Void> loadAllGroups();
|
@NonNull CompletableFuture<Void> loadAllGroups();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches the {@link Group#data() normal node maps} of all known {@link Group}s for {@link Node}
|
||||||
|
* entries matching the given {@link NodeMatcher matcher}.
|
||||||
|
*
|
||||||
|
* @param matcher the matcher
|
||||||
|
* @return the entries which matched
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
<T extends Node> @NonNull CompletableFuture<@Unmodifiable Map<String, Collection<T>>> searchAll(@NonNull NodeMatcher<? extends T> matcher);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for a list of groups with a given permission.
|
* Searches for a list of groups with a given permission.
|
||||||
*
|
*
|
||||||
* @param permission the permission to search for
|
* @param permission the permission to search for
|
||||||
* @return a list of held permissions, or null if the operation failed
|
* @return a list of held permissions, or null if the operation failed
|
||||||
* @throws NullPointerException if the permission is null
|
* @throws NullPointerException if the permission is null
|
||||||
|
* @deprecated Use {@link #searchAll(NodeMatcher)} instead
|
||||||
*/
|
*/
|
||||||
@NonNull CompletableFuture<List<HeldNode<String>>> getWithPermission(@NonNull String permission);
|
@Deprecated
|
||||||
|
@NonNull CompletableFuture<@Unmodifiable List<HeldNode<String>>> getWithPermission(@NonNull String permission);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a loaded group.
|
* Gets a loaded group.
|
||||||
@@ -128,7 +166,7 @@ public interface GroupManager {
|
|||||||
*
|
*
|
||||||
* @return a {@link Set} of {@link Group} objects
|
* @return a {@link Set} of {@link Group} objects
|
||||||
*/
|
*/
|
||||||
@NonNull Set<Group> getLoadedGroups();
|
@NonNull @Unmodifiable Set<Group> getLoadedGroups();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a group is loaded in memory
|
* Check if a group is loaded in memory
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link net.luckperms.api.model.group.Group} data model and functionality.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.model.group;
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main package for {@link net.luckperms.api.model.PermissionHolder}s
|
||||||
|
* ({@link net.luckperms.api.model.user.User}s and {@link net.luckperms.api.model.group.Group}s) and
|
||||||
|
* their corresponding {@link net.luckperms.api.model.data.NodeMap data}.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.model;
|
||||||
@@ -27,11 +27,16 @@ package net.luckperms.api.model.user;
|
|||||||
|
|
||||||
import net.luckperms.api.model.PlayerSaveResult;
|
import net.luckperms.api.model.PlayerSaveResult;
|
||||||
import net.luckperms.api.node.HeldNode;
|
import net.luckperms.api.node.HeldNode;
|
||||||
|
import net.luckperms.api.node.Node;
|
||||||
|
import net.luckperms.api.node.matcher.NodeMatcher;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
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;
|
||||||
@@ -59,7 +64,7 @@ public interface UserManager {
|
|||||||
/**
|
/**
|
||||||
* Loads a user from the plugin's storage provider into memory.
|
* Loads a user from the plugin's storage provider into memory.
|
||||||
*
|
*
|
||||||
* @param uniqueId the uuid of the user
|
* @param uniqueId 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
|
||||||
@@ -111,6 +116,27 @@ public interface UserManager {
|
|||||||
*/
|
*/
|
||||||
@NonNull CompletableFuture<Void> saveUser(@NonNull User user);
|
@NonNull CompletableFuture<Void> saveUser(@NonNull User user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads a user from the plugin's storage provider, applies the given {@code action},
|
||||||
|
* then saves the user's data back to storage.
|
||||||
|
*
|
||||||
|
* <p>This method effectively calls {@link #loadUser(UUID)}, followed by the {@code action},
|
||||||
|
* then {@link #saveUser(User)}, and returns an encapsulation of the whole process as a
|
||||||
|
* {@link CompletableFuture}. </p>
|
||||||
|
*
|
||||||
|
* @param uniqueId the uuid of the user
|
||||||
|
* @param action the action to apply to the user
|
||||||
|
* @return a future to encapsulate the operation
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
default @NonNull CompletableFuture<Void> modifyUser(@NonNull UUID uniqueId, @NonNull Consumer<? super User> action) {
|
||||||
|
/* This default method is overridden in the implementation, and is just here
|
||||||
|
to demonstrate what this method does in the API sources. */
|
||||||
|
return loadUser(uniqueId)
|
||||||
|
.thenApplyAsync(user -> { action.accept(user); return user; })
|
||||||
|
.thenCompose(this::saveUser);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves data about a player to the uuid caching system.
|
* Saves data about a player to the uuid caching system.
|
||||||
*
|
*
|
||||||
@@ -122,6 +148,17 @@ public interface UserManager {
|
|||||||
*/
|
*/
|
||||||
@NonNull CompletableFuture<PlayerSaveResult> savePlayerData(@NonNull UUID uniqueId, @NonNull String username);
|
@NonNull CompletableFuture<PlayerSaveResult> savePlayerData(@NonNull UUID uniqueId, @NonNull String username);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes any data about a given player from the uuid caching system.
|
||||||
|
*
|
||||||
|
* <p>Note that this method does not affect any saved user/permissions data.</p>
|
||||||
|
*
|
||||||
|
* @param uniqueId the users mojang unique id
|
||||||
|
* @return a future encapsulating the result of the operation
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
@NonNull CompletableFuture<Void> deletePlayerData(@NonNull UUID uniqueId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a set all "unique" user UUIDs.
|
* Gets a set all "unique" user UUIDs.
|
||||||
*
|
*
|
||||||
@@ -129,7 +166,17 @@ public interface UserManager {
|
|||||||
*
|
*
|
||||||
* @return a set of uuids
|
* @return a set of uuids
|
||||||
*/
|
*/
|
||||||
@NonNull CompletableFuture<Set<UUID>> getUniqueUsers();
|
@NonNull CompletableFuture<@Unmodifiable Set<UUID>> getUniqueUsers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches the {@link User#data() normal node maps} of all known {@link User}s for {@link Node}
|
||||||
|
* entries matching the given {@link NodeMatcher matcher}.
|
||||||
|
*
|
||||||
|
* @param matcher the matcher
|
||||||
|
* @return the entries which matched
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
<T extends Node> @NonNull CompletableFuture<@Unmodifiable Map<UUID, Collection<T>>> searchAll(@NonNull NodeMatcher<? extends T> matcher);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for a list of users with a given permission.
|
* Searches for a list of users with a given permission.
|
||||||
@@ -137,8 +184,10 @@ public interface UserManager {
|
|||||||
* @param permission the permission to search for
|
* @param permission the permission to search for
|
||||||
* @return a list of held permissions
|
* @return a list of held permissions
|
||||||
* @throws NullPointerException if the permission is null
|
* @throws NullPointerException if the permission is null
|
||||||
|
* @deprecated Use {@link #searchAll(NodeMatcher)} instead
|
||||||
*/
|
*/
|
||||||
@NonNull CompletableFuture<List<HeldNode<UUID>>> getWithPermission(@NonNull String permission);
|
@Deprecated
|
||||||
|
@NonNull CompletableFuture<@Unmodifiable List<HeldNode<UUID>>> getWithPermission(@NonNull String permission);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a loaded user.
|
* Gets a loaded user.
|
||||||
@@ -163,7 +212,7 @@ public interface UserManager {
|
|||||||
*
|
*
|
||||||
* @return a {@link Set} of {@link User} objects
|
* @return a {@link Set} of {@link User} objects
|
||||||
*/
|
*/
|
||||||
@NonNull Set<User> getLoadedUsers();
|
@NonNull @Unmodifiable Set<User> getLoadedUsers();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a user is loaded in memory
|
* Check if a user is loaded in memory
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link net.luckperms.api.model.user.User} data model and functionality.
|
||||||
|
*/
|
||||||
|
package net.luckperms.api.model.user;
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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 net.luckperms.api.node;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dummy implementation of {@link NodeEqualityPredicate}, used for the given constant
|
||||||
|
* implementations.
|
||||||
|
*
|
||||||
|
* <p>The implementation rule of not calling {@link Node#equals(Node, NodeEqualityPredicate)} is
|
||||||
|
* intentionally disregarded by this dummy implementation. The equals method has a special case for
|
||||||
|
* the dummy instances, preventing a stack overflow.</p>
|
||||||
|
*/
|
||||||
|
final class DummyNodeEqualityPredicate implements NodeEqualityPredicate {
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
DummyNodeEqualityPredicate(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areEqual(@NonNull Node o1, @NonNull Node o2) {
|
||||||
|
return o1.equals(o2, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "NodeEqualityPredicate#" + this.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,7 +33,9 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
* A relationship between a {@link PermissionHolder} and a {@link Node}.
|
* A relationship between a {@link PermissionHolder} and a {@link Node}.
|
||||||
*
|
*
|
||||||
* @param <T> the identifier type of the holder
|
* @param <T> the identifier type of the holder
|
||||||
|
* @deprecated The only usages of this interface are also deprecated.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public interface HeldNode<T> {
|
public interface HeldNode<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -39,7 +39,10 @@ import net.luckperms.api.node.types.WeightNode;
|
|||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
import org.jetbrains.annotations.ApiStatus.NonExtendable;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -63,15 +66,24 @@ import java.util.stream.Stream;
|
|||||||
* node, as well as methods to query and extract additional state and properties
|
* node, as well as methods to query and extract additional state and properties
|
||||||
* from these settings.</p>
|
* from these settings.</p>
|
||||||
*
|
*
|
||||||
* <p>Nodes have the following attributes:</p>
|
* <p>Nodes have the following 4 key attributes:</p>
|
||||||
* <p></p>
|
* <p></p>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@link #getKey() key} - the key of the node</li>
|
* <li>{@link #getKey() key} - the key of the node</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 #getContexts() context} - the contexts required for this node to apply </li>
|
* <li>{@link #getContexts() context} - the 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>These are the key attributes which are considered when evaluating node
|
||||||
|
* {@link #equals(Object) equality}.</p>
|
||||||
|
*
|
||||||
|
* <p>Nodes can also optionally have {@link #metadata(NodeMetadataKey) metadata} attached to them,
|
||||||
|
* added during construction using {@link NodeBuilder#withMetadata(NodeMetadataKey, Object)}, and
|
||||||
|
* queried using {@link #metadata(NodeMetadataKey)} and {@link #getMetadata(NodeMetadataKey)}.
|
||||||
|
* Such metadata is never considered when evaluating {@link #equals(Object)} or
|
||||||
|
* {@link #equals(Node, NodeEqualityPredicate)} (any form of equality check).</p>
|
||||||
|
*
|
||||||
* <p>There are a number of node types, all of which extend from this class:</p>
|
* <p>There are a number of node types, all of which extend from this class:</p>
|
||||||
* <p></p>
|
* <p></p>
|
||||||
* <ul>
|
* <ul>
|
||||||
@@ -87,6 +99,7 @@ import java.util.stream.Stream;
|
|||||||
*
|
*
|
||||||
* <p>The core node state must be immutable in all implementations.</p>
|
* <p>The core node state must be immutable in all implementations.</p>
|
||||||
*/
|
*/
|
||||||
|
@NonExtendable
|
||||||
public interface Node {
|
public interface Node {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,7 +108,7 @@ public interface Node {
|
|||||||
* @param key the key
|
* @param key the key
|
||||||
* @return the node builder
|
* @return the node builder
|
||||||
*/
|
*/
|
||||||
static @NonNull NodeBuilder builder(@NonNull String key) {
|
static @NonNull NodeBuilder<?, ?> builder(@NonNull String key) {
|
||||||
return LuckPermsProvider.get().getNodeBuilderRegistry().forKey(key);
|
return LuckPermsProvider.get().getNodeBuilderRegistry().forKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +154,7 @@ public interface Node {
|
|||||||
*
|
*
|
||||||
* @return a list of full nodes
|
* @return a list of full nodes
|
||||||
*/
|
*/
|
||||||
@NonNull Collection<String> resolveShorthand();
|
@NonNull @Unmodifiable Collection<String> resolveShorthand();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if this node is assigned temporarily.
|
* Gets if this node is assigned temporarily.
|
||||||
@@ -153,8 +166,8 @@ public interface Node {
|
|||||||
/**
|
/**
|
||||||
* Gets the time when this node will expire.
|
* Gets the time when this node will expire.
|
||||||
*
|
*
|
||||||
* @return the {@link Instant} when this node will expire, or null if it
|
* @return the {@link Instant} when this node will expire, or
|
||||||
* doesn't have an expiry time
|
* {@code null} if it doesn't have an expiry time
|
||||||
*/
|
*/
|
||||||
@Nullable Instant getExpiry();
|
@Nullable Instant getExpiry();
|
||||||
|
|
||||||
@@ -167,6 +180,17 @@ public interface Node {
|
|||||||
*/
|
*/
|
||||||
boolean hasExpired();
|
boolean hasExpired();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the time until this node will expire.
|
||||||
|
*
|
||||||
|
* <p>Returns {@code null} if the node doesn't have an expiry time,
|
||||||
|
* and a {@link Duration#isNegative() negative} duration if it has already expired.</p>
|
||||||
|
*
|
||||||
|
* @return the duration until the nodes expiry
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
@Nullable Duration getExpiryDuration();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the contexts required for this node to apply.
|
* Gets the contexts required for this node to apply.
|
||||||
*
|
*
|
||||||
@@ -177,11 +201,11 @@ public interface Node {
|
|||||||
/**
|
/**
|
||||||
* Gets the metadata corresponding to the given <code>key</code>, if present.
|
* Gets the metadata corresponding to the given <code>key</code>, if present.
|
||||||
*
|
*
|
||||||
* @param key the key
|
|
||||||
* @param <T> the metadata type
|
* @param <T> the metadata type
|
||||||
|
* @param key the key
|
||||||
* @return the data, if present
|
* @return the data, if present
|
||||||
*/
|
*/
|
||||||
<T> Optional<T> getMetadata(NodeMetadataKey<T> key);
|
<T> Optional<T> getMetadata(@NonNull NodeMetadataKey<T> key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the metadata corresponding to the given <code>key</code>, throwing an exception
|
* Gets the metadata corresponding to the given <code>key</code>, throwing an exception
|
||||||
@@ -192,7 +216,7 @@ public interface Node {
|
|||||||
* @return the data
|
* @return the data
|
||||||
* @throws IllegalStateException if data isn't present
|
* @throws IllegalStateException if data isn't present
|
||||||
*/
|
*/
|
||||||
default <T> T metadata(NodeMetadataKey<T> key) throws IllegalStateException {
|
default <T> T metadata(@NonNull NodeMetadataKey<T> key) throws IllegalStateException {
|
||||||
return getMetadata(key).orElseThrow(() -> new IllegalStateException("Node '" + getKey() + "' does not have '" + key.name() + "' attached."));
|
return getMetadata(key).orElseThrow(() -> new IllegalStateException("Node '" + getKey() + "' does not have '" + key.name() + "' attached."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,11 @@ import net.luckperms.api.node.metadata.NodeMetadataKey;
|
|||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
import org.jetbrains.annotations.ApiStatus.NonExtendable;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.temporal.TemporalAccessor;
|
import java.time.temporal.TemporalAccessor;
|
||||||
|
import java.time.temporal.TemporalAmount;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -41,6 +44,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* @param <N> the node type
|
* @param <N> the node type
|
||||||
* @param <B> the node builder type
|
* @param <B> the node builder type
|
||||||
*/
|
*/
|
||||||
|
@NonExtendable
|
||||||
public interface NodeBuilder<N extends ScopedNode<N, B>, B extends NodeBuilder<N, B>> {
|
public interface NodeBuilder<N extends ScopedNode<N, B>, B extends NodeBuilder<N, B>> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,20 +89,32 @@ public interface NodeBuilder<N extends ScopedNode<N, B>, B extends NodeBuilder<N
|
|||||||
/**
|
/**
|
||||||
* Sets the time when the node should expire.
|
* Sets the time when the node should expire.
|
||||||
*
|
*
|
||||||
* <p>The expiry timestamp is calculated relative to the current
|
* <p>The expiry time is calculated relative to the current
|
||||||
|
* system time.</p>
|
||||||
|
*
|
||||||
|
* @param duration how long the node should be added for
|
||||||
|
* @return the builder
|
||||||
|
* @see Node#getExpiry()
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
@NonNull B expiry(@Nullable TemporalAmount duration);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the time when the node should expire.
|
||||||
|
*
|
||||||
|
* <p>The expiry time is calculated relative to the current
|
||||||
* 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
|
||||||
*/
|
*/
|
||||||
default @NonNull B expiry(long duration, TimeUnit unit) {
|
default @NonNull B expiry(long duration, @NonNull TimeUnit unit) {
|
||||||
if (duration <= 0) {
|
if (duration <= 0) {
|
||||||
throw new IllegalArgumentException("duration must be positive");
|
throw new IllegalArgumentException("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;
|
return expiry(Duration.ofSeconds(seconds));
|
||||||
return expiry(timeNow + seconds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,7 +163,7 @@ public interface NodeBuilder<N extends ScopedNode<N, B>, B extends NodeBuilder<N
|
|||||||
* @param <T> the metadata type
|
* @param <T> the metadata type
|
||||||
* @return the builder
|
* @return the builder
|
||||||
*/
|
*/
|
||||||
@NonNull <T> B withMetadata(@NonNull NodeMetadataKey<T> key, @Nullable T metadata);
|
<T> @NonNull B withMetadata(@NonNull NodeMetadataKey<T> key, @Nullable T metadata);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link Node} instance from the builder.
|
* Creates a {@link Node} instance from the builder.
|
||||||
|
|||||||
@@ -35,74 +35,103 @@ import net.luckperms.api.node.types.SuffixNode;
|
|||||||
import net.luckperms.api.node.types.WeightNode;
|
import net.luckperms.api.node.types.WeightNode;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.ApiStatus.Internal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A registry of methods for obtaining {@link NodeBuilder}s for the various
|
* A registry of methods for obtaining {@link NodeBuilder}s for the various
|
||||||
* node types.
|
* node types.
|
||||||
*/
|
*/
|
||||||
|
@Internal
|
||||||
public interface NodeBuilderRegistry {
|
public interface NodeBuilderRegistry {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a {@link NodeBuilder} applicable for the given key.
|
* Gets a {@link NodeBuilder} applicable for the given key.
|
||||||
*
|
*
|
||||||
|
* <p>Prefer using the {@link Node#builder(String)} method.</p>
|
||||||
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
* @return the node builder
|
* @return the node builder
|
||||||
|
* @see Node#builder(String)
|
||||||
*/
|
*/
|
||||||
@NonNull NodeBuilder<?, ?> forKey(String key);
|
@NonNull NodeBuilder<?, ?> forKey(String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a {@link NodeBuilder} for {@link PermissionNode}s.
|
* Gets a {@link NodeBuilder} for {@link PermissionNode}s.
|
||||||
*
|
*
|
||||||
|
* <p>Prefer using the {@link PermissionNode#builder()} method.</p>
|
||||||
|
*
|
||||||
* @return the node builder
|
* @return the node builder
|
||||||
|
* @see PermissionNode#builder()
|
||||||
*/
|
*/
|
||||||
PermissionNode.@NonNull Builder forPermission();
|
PermissionNode.@NonNull Builder forPermission();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a {@link NodeBuilder} for {@link RegexPermissionNode}s.
|
* Gets a {@link NodeBuilder} for {@link RegexPermissionNode}s.
|
||||||
*
|
*
|
||||||
|
* <p>Prefer using the {@link RegexPermissionNode#builder()} method.</p>
|
||||||
|
*
|
||||||
* @return the node builder
|
* @return the node builder
|
||||||
|
* @see RegexPermissionNode#builder()
|
||||||
*/
|
*/
|
||||||
RegexPermissionNode.@NonNull Builder forRegexPermission();
|
RegexPermissionNode.@NonNull Builder forRegexPermission();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a {@link NodeBuilder} for {@link InheritanceNode}s.
|
* Gets a {@link NodeBuilder} for {@link InheritanceNode}s.
|
||||||
*
|
*
|
||||||
|
* <p>Prefer using the {@link InheritanceNode#builder()} method.</p>
|
||||||
|
*
|
||||||
* @return the node builder
|
* @return the node builder
|
||||||
|
* @see InheritanceNode#builder()
|
||||||
*/
|
*/
|
||||||
InheritanceNode.@NonNull Builder forInheritance();
|
InheritanceNode.@NonNull Builder forInheritance();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a {@link NodeBuilder} for {@link PrefixNode}s.
|
* Gets a {@link NodeBuilder} for {@link PrefixNode}s.
|
||||||
*
|
*
|
||||||
|
* <p>Prefer using the {@link PrefixNode#builder()} method.</p>
|
||||||
|
*
|
||||||
* @return the node builder
|
* @return the node builder
|
||||||
|
* @see PrefixNode#builder()
|
||||||
*/
|
*/
|
||||||
PrefixNode.@NonNull Builder forPrefix();
|
PrefixNode.@NonNull Builder forPrefix();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a {@link NodeBuilder} for {@link SuffixNode}s.
|
* Gets a {@link NodeBuilder} for {@link SuffixNode}s.
|
||||||
*
|
*
|
||||||
|
* <p>Prefer using the {@link SuffixNode#builder()} method.</p>
|
||||||
|
*
|
||||||
* @return the node builder
|
* @return the node builder
|
||||||
|
* @see SuffixNode#builder()
|
||||||
*/
|
*/
|
||||||
SuffixNode.@NonNull Builder forSuffix();
|
SuffixNode.@NonNull Builder forSuffix();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a {@link NodeBuilder} for {@link MetaNode}s.
|
* Gets a {@link NodeBuilder} for {@link MetaNode}s.
|
||||||
*
|
*
|
||||||
|
* <p>Prefer using the {@link MetaNode#builder()} method.</p>
|
||||||
|
*
|
||||||
* @return the node builder
|
* @return the node builder
|
||||||
|
* @see MetaNode#builder()
|
||||||
*/
|
*/
|
||||||
MetaNode.@NonNull Builder forMeta();
|
MetaNode.@NonNull Builder forMeta();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a {@link NodeBuilder} for {@link WeightNode}s.
|
* Gets a {@link NodeBuilder} for {@link WeightNode}s.
|
||||||
*
|
*
|
||||||
|
* <p>Prefer using the {@link WeightNode#builder()} method.</p>
|
||||||
|
*
|
||||||
* @return the node builder
|
* @return the node builder
|
||||||
|
* @see WeightNode#builder()
|
||||||
*/
|
*/
|
||||||
WeightNode.@NonNull Builder forWeight();
|
WeightNode.@NonNull Builder forWeight();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a {@link NodeBuilder} for {@link DisplayNameNode}s.
|
* Gets a {@link NodeBuilder} for {@link DisplayNameNode}s.
|
||||||
*
|
*
|
||||||
|
* <p>Prefer using the {@link DisplayNameNode#builder()} method.</p>
|
||||||
|
*
|
||||||
* @return the node builder
|
* @return the node builder
|
||||||
|
* @see DisplayNameNode#builder()
|
||||||
*/
|
*/
|
||||||
DisplayNameNode.@NonNull Builder forDisplayName();
|
DisplayNameNode.@NonNull Builder forDisplayName();
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,18 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A rule for determining if two nodes are equal.
|
* An equality test for determining if two nodes are to be considered equal.
|
||||||
|
*
|
||||||
|
* <p>Recall that {@link Node}s have 4 key attributes: key, value, context, expiry.</p>
|
||||||
|
*
|
||||||
|
* <p>In the default {@link Node#equals(Object)} implementation (equivalent to {@link #EXACT}),
|
||||||
|
* all 4 of these key attributes are considered. However, there are occasions where such strict
|
||||||
|
* equality checking is not desired, hence the use of this class.</p>
|
||||||
|
*
|
||||||
|
* <p>{@link NodeEqualityPredicate}s can either be used inline, by directly calling the
|
||||||
|
* {@link #areEqual(Node, Node)} method, or can be passed as a parameter to the
|
||||||
|
* {@link Node#equals(Node, NodeEqualityPredicate)} method. Either approach is valid, and both will
|
||||||
|
* result in the same result.</p>
|
||||||
*
|
*
|
||||||
* <p>Generally, implementations of this interface should fulfil the same
|
* <p>Generally, implementations 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>
|
||||||
@@ -61,60 +72,88 @@ public interface NodeEqualityPredicate {
|
|||||||
return other -> areEqual(node, other);
|
return other -> areEqual(node, other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Some 'default' implementations of NodeEqualityPredicate are provided below.
|
|
||||||
*
|
|
||||||
* These are implemented in the common code, by a special case in the
|
|
||||||
* implementation of Node#equals. As noted above, this should generally be
|
|
||||||
* avoided.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an exact match.
|
* Represents an exact match.
|
||||||
*
|
*
|
||||||
* <p>All attributes of the nodes must match for them to be considered
|
* <p>Returns true if: (and)</p>
|
||||||
* equal.</p>
|
* <p></p>
|
||||||
*/
|
* <ul>
|
||||||
NodeEqualityPredicate EXACT = new NodeEqualityPredicate() {
|
* <li>{@link Node#getKey() key} = key</li>
|
||||||
@Override public boolean areEqual(@NonNull Node o1, @NonNull Node o2) { return o1.equals(o2, this); }
|
* <li>{@link Node#getValue() value} = value</li>
|
||||||
};
|
* <li>{@link Node#getContexts() context} = context</li>
|
||||||
|
* <li>{@link Node#getExpiry() expiry} = expiry</li>
|
||||||
/**
|
* </ul>
|
||||||
* All attributes must match, except for
|
|
||||||
* {@link Node#getValue() value}, which is ignored.
|
|
||||||
*/
|
|
||||||
NodeEqualityPredicate IGNORE_VALUE = new NodeEqualityPredicate() {
|
|
||||||
@Override public boolean areEqual(@NonNull Node o1, @NonNull Node o2) { return o1.equals(o2, this); }
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* All attributes must match, except for the
|
|
||||||
* {@link Node#getExpiry() expiry time}, which is ignored.
|
|
||||||
*
|
*
|
||||||
* <p>Note that with this setting, whether a node is temporary or not is
|
* <p>All 4 attributes of the nodes must match to be considered equal.</p>
|
||||||
* still considered.</p>
|
*
|
||||||
|
* <p>This is the default form of equality, used by {@link Node#equals(Object)}.</p>
|
||||||
*/
|
*/
|
||||||
NodeEqualityPredicate IGNORE_EXPIRY_TIME = new NodeEqualityPredicate() {
|
NodeEqualityPredicate EXACT = new DummyNodeEqualityPredicate("EXACT");
|
||||||
@Override public boolean areEqual(@NonNull Node o1, @NonNull Node o2) { return o1.equals(o2, this); }
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All attributes must match, except for
|
* Only the {@link Node#getKey() key}s need match, all other attributes are ignored.
|
||||||
* {@link Node#getValue() value} and the
|
*/
|
||||||
|
NodeEqualityPredicate ONLY_KEY = new DummyNodeEqualityPredicate("ONLY_KEY");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All attributes must match, except for {@link Node#getValue() value}, which is ignored.
|
||||||
|
*
|
||||||
|
* <p>Returns true if: (and)</p>
|
||||||
|
* <p></p>
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link Node#getKey() key} = key</li>
|
||||||
|
* <li>{@link Node#getContexts() context} = context</li>
|
||||||
|
* <li>{@link Node#getExpiry() expiry} = expiry</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
NodeEqualityPredicate IGNORE_VALUE = new DummyNodeEqualityPredicate("IGNORE_VALUE");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All attributes must match, except for the {@link Node#getExpiry() expiry time}, which is
|
||||||
|
* ignored.
|
||||||
|
*
|
||||||
|
* <p>Note that with this setting, whether a node has an expiry or not is still considered.</p>
|
||||||
|
*
|
||||||
|
* <p>Returns true if: (and)</p>
|
||||||
|
* <p></p>
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link Node#getKey() key} = key</li>
|
||||||
|
* <li>{@link Node#getValue() value} = value</li>
|
||||||
|
* <li>{@link Node#getContexts() context} = context</li>
|
||||||
|
* <li>{@link Node#hasExpiry() has expiry} = has expiry</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
NodeEqualityPredicate IGNORE_EXPIRY_TIME = new DummyNodeEqualityPredicate("IGNORE_EXPIRY_TIME");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All attributes must match, except for {@link Node#getValue() value} and the
|
||||||
* {@link Node#getExpiry() expiry time}, which are ignored.
|
* {@link Node#getExpiry() expiry time}, which are ignored.
|
||||||
|
*
|
||||||
|
* <p>Note that with this setting, whether a node has an expiry or not is still considered.</p>
|
||||||
|
*
|
||||||
|
* <p>Returns true if: (and)</p>
|
||||||
|
* <p></p>
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link Node#getKey() key} = key</li>
|
||||||
|
* <li>{@link Node#getContexts() context} = context</li>
|
||||||
|
* <li>{@link Node#hasExpiry() has expiry} = has expiry</li>
|
||||||
|
* </ul>
|
||||||
*/
|
*/
|
||||||
NodeEqualityPredicate IGNORE_EXPIRY_TIME_AND_VALUE = new NodeEqualityPredicate() {
|
NodeEqualityPredicate IGNORE_EXPIRY_TIME_AND_VALUE = new DummyNodeEqualityPredicate("IGNORE_EXPIRY_TIME_AND_VALUE");
|
||||||
@Override public boolean areEqual(@NonNull Node o1, @NonNull Node o2) { return o1.equals(o2, this); }
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All attributes must match, except for
|
* All attributes must match, except for {@link Node#getValue() value} and the if the node
|
||||||
* {@link Node#getValue() value} and the if the node is
|
* {@link Node#hasExpiry() has an expiry}, which are ignored.
|
||||||
* {@link Node#hasExpiry() temporary}, which are ignored.
|
*
|
||||||
|
* <p>Effectively only considers the key and the context.</p>
|
||||||
|
*
|
||||||
|
* <p>Returns true if: (and)</p>
|
||||||
|
* <p></p>
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link Node#getKey() key} = key</li>
|
||||||
|
* <li>{@link Node#getContexts() context} = context</li>
|
||||||
|
* </ul>
|
||||||
*/
|
*/
|
||||||
NodeEqualityPredicate IGNORE_VALUE_OR_IF_TEMPORARY = new NodeEqualityPredicate() {
|
NodeEqualityPredicate IGNORE_VALUE_OR_IF_TEMPORARY = new DummyNodeEqualityPredicate("IGNORE_VALUE_OR_IF_TEMPORARY");
|
||||||
@Override public boolean areEqual(@NonNull Node o1, @NonNull Node o2) { return o1.equals(o2, this); }
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -35,6 +35,8 @@ import net.luckperms.api.node.types.RegexPermissionNode;
|
|||||||
import net.luckperms.api.node.types.SuffixNode;
|
import net.luckperms.api.node.types.SuffixNode;
|
||||||
import net.luckperms.api.node.types.WeightNode;
|
import net.luckperms.api.node.types.WeightNode;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -48,59 +50,105 @@ public interface NodeType<T extends Node> {
|
|||||||
/**
|
/**
|
||||||
* Node type for {@link PermissionNode}.
|
* Node type for {@link PermissionNode}.
|
||||||
*/
|
*/
|
||||||
NodeType<PermissionNode> PERMISSION = new SimpleNodeType<>("PERMISSION", n -> n instanceof PermissionNode, n -> ((PermissionNode) n));
|
NodeType<PermissionNode> PERMISSION = new SimpleNodeType<>(
|
||||||
|
"PERMISSION",
|
||||||
|
n -> n instanceof PermissionNode,
|
||||||
|
n -> (PermissionNode) n
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node type for {@link RegexPermissionNode}.
|
* Node type for {@link RegexPermissionNode}.
|
||||||
*/
|
*/
|
||||||
NodeType<RegexPermissionNode> REGEX_PERMISSION = new SimpleNodeType<>("REGEX_PERMISSION", n -> n instanceof RegexPermissionNode, n -> ((RegexPermissionNode) n));
|
NodeType<RegexPermissionNode> REGEX_PERMISSION = new SimpleNodeType<>(
|
||||||
|
"REGEX_PERMISSION",
|
||||||
|
n -> n instanceof RegexPermissionNode,
|
||||||
|
n -> (RegexPermissionNode) n
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node type for {@link InheritanceNode}.
|
* Node type for {@link InheritanceNode}.
|
||||||
*/
|
*/
|
||||||
NodeType<InheritanceNode> INHERITANCE = new SimpleNodeType<>("INHERITANCE", n -> n instanceof InheritanceNode, n -> ((InheritanceNode) n));
|
NodeType<InheritanceNode> INHERITANCE = new SimpleNodeType<>(
|
||||||
|
"INHERITANCE",
|
||||||
|
n -> n instanceof InheritanceNode,
|
||||||
|
n -> (InheritanceNode) n
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node type for {@link PrefixNode}.
|
* Node type for {@link PrefixNode}.
|
||||||
*/
|
*/
|
||||||
NodeType<PrefixNode> PREFIX = new SimpleNodeType<>("PREFIX", n -> n instanceof PrefixNode, n -> ((PrefixNode) n));
|
NodeType<PrefixNode> PREFIX = new SimpleNodeType<>(
|
||||||
|
"PREFIX",
|
||||||
|
n -> n instanceof PrefixNode,
|
||||||
|
n -> (PrefixNode) n
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node type for {@link SuffixNode}.
|
* Node type for {@link SuffixNode}.
|
||||||
*/
|
*/
|
||||||
NodeType<SuffixNode> SUFFIX = new SimpleNodeType<>("SUFFIX", n -> n instanceof SuffixNode, n -> ((SuffixNode) n));
|
NodeType<SuffixNode> SUFFIX = new SimpleNodeType<>(
|
||||||
|
"SUFFIX",
|
||||||
|
n -> n instanceof SuffixNode,
|
||||||
|
n -> (SuffixNode) n
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node type for {@link MetaNode}.
|
* Node type for {@link MetaNode}.
|
||||||
*/
|
*/
|
||||||
NodeType<MetaNode> META = new SimpleNodeType<>("META", n -> n instanceof MetaNode, n -> ((MetaNode) n));
|
NodeType<MetaNode> META = new SimpleNodeType<>(
|
||||||
|
"META",
|
||||||
|
n -> n instanceof MetaNode,
|
||||||
|
n -> (MetaNode) n
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node type for {@link WeightNode}.
|
* Node type for {@link WeightNode}.
|
||||||
*/
|
*/
|
||||||
NodeType<WeightNode> WEIGHT = new SimpleNodeType<>("WEIGHT", n -> n instanceof WeightNode, n -> ((WeightNode) n));
|
NodeType<WeightNode> WEIGHT = new SimpleNodeType<>(
|
||||||
|
"WEIGHT",
|
||||||
|
n -> n instanceof WeightNode,
|
||||||
|
n -> (WeightNode) n
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node type for {@link DisplayNameNode}.
|
* Node type for {@link DisplayNameNode}.
|
||||||
*/
|
*/
|
||||||
NodeType<DisplayNameNode> DISPLAY_NAME = new SimpleNodeType<>("DISPLAY_NAME", n -> n instanceof DisplayNameNode, n -> ((DisplayNameNode) n));
|
NodeType<DisplayNameNode> DISPLAY_NAME = new SimpleNodeType<>(
|
||||||
|
"DISPLAY_NAME",
|
||||||
|
n -> n instanceof DisplayNameNode,
|
||||||
|
n -> (DisplayNameNode) n
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node type for {@link ChatMetaNode}.
|
* Node type for {@link ChatMetaNode}.
|
||||||
|
*
|
||||||
|
* <p>This is an abstract type, and therefore will never
|
||||||
|
* be returned from {@link Node#getType()}.</p>
|
||||||
*/
|
*/
|
||||||
NodeType<ChatMetaNode<?, ?>> CHAT_META = new SimpleNodeType<>("CHAT_META", n -> n instanceof ChatMetaNode<?, ?>, n -> ((ChatMetaNode<?, ?>) n));
|
NodeType<ChatMetaNode<?, ?>> CHAT_META = new SimpleNodeType<>(
|
||||||
|
"CHAT_META",
|
||||||
|
n -> n instanceof ChatMetaNode<?, ?>,
|
||||||
|
n -> (ChatMetaNode<?, ?>) n
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node type for {@link ChatMetaNode} or {@link MetaNode}.
|
* Node type for {@link ChatMetaNode} or {@link MetaNode}.
|
||||||
|
*
|
||||||
|
* <p>This is an abstract type, and therefore will never
|
||||||
|
* be returned from {@link Node#getType()}.</p>
|
||||||
*/
|
*/
|
||||||
NodeType<Node> META_OR_CHAT_META = new SimpleNodeType<>("META_OR_CHAT_META", n -> META.matches(n) || CHAT_META.matches(n), Function.identity());
|
NodeType<Node> META_OR_CHAT_META = new SimpleNodeType<>(
|
||||||
|
"META_OR_CHAT_META",
|
||||||
|
n -> META.matches(n) || CHAT_META.matches(n),
|
||||||
|
Function.identity()
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a name for the node type.
|
* Gets a name for the node type.
|
||||||
*
|
*
|
||||||
* @return a name
|
* @return a name
|
||||||
*/
|
*/
|
||||||
String name();
|
@NonNull String name();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the passed node matches the type
|
* Returns if the passed node matches the type
|
||||||
@@ -108,7 +156,7 @@ public interface NodeType<T extends Node> {
|
|||||||
* @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
|
||||||
*/
|
*/
|
||||||
boolean matches(Node node);
|
boolean matches(@NonNull Node node);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Casts the given {@link Node} to the type defined by the {@link NodeType}.
|
* Casts the given {@link Node} to the type defined by the {@link NodeType}.
|
||||||
@@ -120,7 +168,7 @@ public interface NodeType<T extends Node> {
|
|||||||
* @return the casted node
|
* @return the casted node
|
||||||
* @throws IllegalArgumentException if the node to cast does not match the type
|
* @throws IllegalArgumentException if the node to cast does not match the type
|
||||||
*/
|
*/
|
||||||
T cast(Node node);
|
@NonNull T cast(@NonNull Node node);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to cast the given {@link Node} to the type defined by the
|
* Attempts to cast the given {@link Node} to the type defined by the
|
||||||
@@ -132,7 +180,7 @@ public interface NodeType<T extends Node> {
|
|||||||
* @param node the node to cast
|
* @param node the node to cast
|
||||||
* @return an optional, possibly containing a casted node
|
* @return an optional, possibly containing a casted node
|
||||||
*/
|
*/
|
||||||
default Optional<T> tryCast(Node node) {
|
default @NonNull Optional<T> tryCast(@NonNull Node node) {
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
if (!matches(node)) {
|
if (!matches(node)) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
@@ -147,7 +195,7 @@ public interface NodeType<T extends Node> {
|
|||||||
*
|
*
|
||||||
* @return a predicate for the {@link #matches(Node)} method.
|
* @return a predicate for the {@link #matches(Node)} method.
|
||||||
*/
|
*/
|
||||||
default Predicate<Node> predicate() {
|
default @NonNull Predicate<Node> predicate() {
|
||||||
return this::matches;
|
return this::matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +207,7 @@ public interface NodeType<T extends Node> {
|
|||||||
* @param and a predicate to AND with the result of the type match check
|
* @param and a predicate to AND with the result of the type match check
|
||||||
* @return a matching predicate, ANDed with the given predicate parameter
|
* @return a matching predicate, ANDed with the given predicate parameter
|
||||||
*/
|
*/
|
||||||
default Predicate<Node> predicate(Predicate<? super T> and) {
|
default @NonNull Predicate<Node> predicate(@NonNull Predicate<? super T> and) {
|
||||||
return node -> matches(node) && and.test(cast(node));
|
return node -> matches(node) && and.test(cast(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
package net.luckperms.api.node;
|
package net.luckperms.api.node;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
@@ -41,18 +44,18 @@ final class SimpleNodeType<T extends Node> implements NodeType<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NotNull String name() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Node node) {
|
public boolean matches(@NonNull Node node) {
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return this.matches.test(node);
|
return this.matches.test(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T cast(Node node) {
|
public @NotNull T cast(@NonNull Node node) {
|
||||||
if (!matches(node)) {
|
if (!matches(node)) {
|
||||||
throw new IllegalArgumentException("Node " + node.getClass() + " does not match " + this.name);
|
throw new IllegalArgumentException("Node " + node.getClass() + " does not match " + this.name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
* 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 net.luckperms.api.node.matcher;
|
||||||
|
|
||||||
|
import net.luckperms.api.LuckPermsProvider;
|
||||||
|
import net.luckperms.api.node.Node;
|
||||||
|
import net.luckperms.api.node.NodeEqualityPredicate;
|
||||||
|
import net.luckperms.api.node.NodeType;
|
||||||
|
import net.luckperms.api.node.types.MetaNode;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.ApiStatus.NonExtendable;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A predicate which matches certain {@link Node}s.
|
||||||
|
*
|
||||||
|
* <p>API users should not implement this interface directly.</p>
|
||||||
|
*
|
||||||
|
* @param <T> the node type matched
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
@NonExtendable
|
||||||
|
public interface NodeMatcher<T extends Node> extends Predicate<Node> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a {@link NodeMatcher} which matches nodes with the same {@link Node#getKey() key}.
|
||||||
|
*
|
||||||
|
* <p>The {@link String#equalsIgnoreCase(String)} method is used to test key equality.</p>
|
||||||
|
*
|
||||||
|
* @param key the key
|
||||||
|
* @return the matcher
|
||||||
|
*/
|
||||||
|
static @NonNull NodeMatcher<Node> key(@NonNull String key) {
|
||||||
|
return LuckPermsProvider.get().getNodeMatcherFactory().key(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a {@link NodeMatcher} which matches nodes with the same {@link Node#getKey() key}.
|
||||||
|
*
|
||||||
|
* <p>The {@link String#equalsIgnoreCase(String)} method is used to test key equality.</p>
|
||||||
|
*
|
||||||
|
* @param node the node to use for the key
|
||||||
|
* @param <T> the node type
|
||||||
|
* @return the matcher
|
||||||
|
*/
|
||||||
|
static <T extends Node> @NonNull NodeMatcher<T> key(@NonNull T node) {
|
||||||
|
return LuckPermsProvider.get().getNodeMatcherFactory().key(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a {@link NodeMatcher} which matches nodes with a {@link Node#getKey() key} starting
|
||||||
|
* with the given string.
|
||||||
|
*
|
||||||
|
* @param startingWith the string to match
|
||||||
|
* @return the matcher
|
||||||
|
*/
|
||||||
|
static @NonNull NodeMatcher<Node> keyStartsWith(@NonNull String startingWith) {
|
||||||
|
return LuckPermsProvider.get().getNodeMatcherFactory().keyStartsWith(startingWith);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a {@link NodeMatcher} which matches nodes which are
|
||||||
|
* {@link Node#equals(Node, NodeEqualityPredicate) equal to} the given {@code other} node
|
||||||
|
* according to the {@link NodeEqualityPredicate}.
|
||||||
|
*
|
||||||
|
* @param other the other node to test against
|
||||||
|
* @param equalityPredicate the equality predicate
|
||||||
|
* @param <T> the node type
|
||||||
|
* @return the matcher
|
||||||
|
*/
|
||||||
|
static <T extends Node> @NonNull NodeMatcher<T> equals(@NonNull T other, @NonNull NodeEqualityPredicate equalityPredicate) {
|
||||||
|
return LuckPermsProvider.get().getNodeMatcherFactory().equals(other, equalityPredicate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a {@link NodeMatcher} which matches {@link MetaNode}s with the same
|
||||||
|
* {@link MetaNode#getMetaKey() meta key}.
|
||||||
|
*
|
||||||
|
* <p>The {@link String#equalsIgnoreCase(String)} method is used to test key equality.</p>
|
||||||
|
*
|
||||||
|
* @param metaKey the meta key
|
||||||
|
* @return the matcher
|
||||||
|
*/
|
||||||
|
static @NonNull NodeMatcher<MetaNode> metaKey(@NonNull String metaKey) {
|
||||||
|
return LuckPermsProvider.get().getNodeMatcherFactory().metaKey(metaKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a {@link NodeMatcher} which matches {@link MetaNode}s with the same
|
||||||
|
* {@link MetaNode#getMetaKey() meta key}.
|
||||||
|
*
|
||||||
|
* <p>The {@link String#equalsIgnoreCase(String)} method is used to test key equality.</p>
|
||||||
|
*
|
||||||
|
* @param metaNode the meta node to use for the meta key
|
||||||
|
* @return the matcher
|
||||||
|
*/
|
||||||
|
static @NonNull NodeMatcher<MetaNode> metaKey(@NonNull MetaNode metaNode) {
|
||||||
|
return metaKey(metaNode.getMetaKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a {@link NodeMatcher} which matches {@link Node}s with the same
|
||||||
|
* type as the given {@link NodeType}.
|
||||||
|
*
|
||||||
|
* <p>{@link NodeType#PERMISSION}, {@link NodeType#CHAT_META} and
|
||||||
|
* {@link NodeType#META_OR_CHAT_META} are not supported by this method.</p>
|
||||||
|
*
|
||||||
|
* @param type the node type
|
||||||
|
* @param <T> the node type
|
||||||
|
* @return the matcher
|
||||||
|
*/
|
||||||
|
static <T extends Node> @NonNull NodeMatcher<T> type(@NonNull NodeType<? extends T> type) {
|
||||||
|
return LuckPermsProvider.get().getNodeMatcherFactory().type(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to see if the given {@link Node} matches.
|
||||||
|
*
|
||||||
|
* @param node the node to test
|
||||||
|
* @return true if the node matched
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
boolean test(@NonNull Node node);
|
||||||
|
}
|
||||||
Loaded 100 of 724 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user