Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5577e3f590 | ||
|
|
ffe6c24b53 | ||
|
|
4e4982a98d | ||
|
|
7f4f9bb917 | ||
|
|
8d8024ba5e | ||
|
|
2e16b15b0e | ||
|
|
1ebed37297 | ||
|
|
ff37ad176b | ||
|
|
d0c5d89e91 | ||
|
|
f49446011a | ||
|
|
d762a0aaa6 | ||
|
|
2dc211a91e | ||
|
|
2c62de9658 | ||
|
|
494ab6787f | ||
|
|
b81e8a40a4 | ||
|
|
2fd2f4fedb | ||
|
|
493e5d08be | ||
|
|
62a834e145 | ||
|
|
241f13c8f1 | ||
|
|
98ea255667 | ||
|
|
420ec2bf1a | ||
|
|
364a494ac6 | ||
|
|
821d1cb8dd | ||
|
|
544ffbad19 | ||
|
|
4fa6cd2577 | ||
|
|
37d1f5efab | ||
|
|
7cd8e8bf5b | ||
|
|
8eed4558f4 | ||
|
|
62ca2d9c79 | ||
|
|
c7a0d7026c | ||
|
|
ce74813ce5 | ||
|
|
d1511e43f2 | ||
|
|
6ef749c76a | ||
|
|
8846932cb6 | ||
|
|
12b861db3f | ||
|
|
0a50df6557 | ||
|
|
3726f6de41 | ||
|
|
d1ca7684d6 | ||
|
|
512b621a7a | ||
|
|
2cf919a17a | ||
|
|
46072eb465 | ||
|
|
ae63a42c2e | ||
|
|
8773ec07ab | ||
|
|
287cc308d6 | ||
|
|
beeb4fa169 | ||
|
|
4ef3d50965 | ||
|
|
dae64fc8c4 | ||
|
|
215031a1f3 | ||
|
|
85d2f0b51f | ||
|
|
d91355e4d6 | ||
|
|
1a690dabd7 | ||
|
|
526448ce40 | ||
|
|
43d04a97f5 | ||
|
|
307614e704 | ||
|
|
f6c0794691 | ||
|
|
83db00aef8 | ||
|
|
22252fa46d | ||
|
|
7b8426977a | ||
|
|
d9912cb93f | ||
|
|
5db999f995 | ||
|
|
b744e35ad8 | ||
|
|
b6769811a2 | ||
|
|
1d9fc568e4 | ||
|
|
3c0d1ba7a1 | ||
|
|
78a74510cf | ||
|
|
d3ae3324fa | ||
|
|
4b97c9419e | ||
|
|
db830a0bef | ||
|
|
797c195424 | ||
|
|
4788290615 | ||
|
|
d0c016f6b7 | ||
|
|
9b1c73ed23 | ||
|
|
048768007d | ||
|
|
ec7a5321a6 | ||
|
|
c396323308 | ||
|
|
6fc2321fad | ||
|
|
a0d04790a5 | ||
|
|
c4154c09da | ||
|
|
8eed3131f2 | ||
|
|
e5c4b710f6 | ||
|
|
2ccffc6e6d | ||
|
|
fc69002c86 | ||
|
|
e3a6db5f97 | ||
|
|
6d8077ffd0 | ||
|
|
784161d66d | ||
|
|
115f793733 | ||
|
|
2cb5e437fd | ||
|
|
8c57c2b46d | ||
|
|
879a88a398 | ||
|
|
7e50c3c777 | ||
|
|
4b1cf51530 | ||
|
|
de24817d9c | ||
|
|
085e7af681 | ||
|
|
1aabd7610e | ||
|
|
ef31db1431 | ||
|
|
757e9d6be6 | ||
|
|
b3a028e3ca | ||
|
|
e222e4e98c | ||
|
|
1213e58240 | ||
|
|
b7ff0824b9 | ||
|
|
7b5917660c | ||
|
|
1544487e92 | ||
|
|
c19ef84116 | ||
|
|
e8c4a55dc3 | ||
|
|
97d6aaed5c | ||
|
|
fe77834cef | ||
|
|
2da6298c53 | ||
|
|
e111270aed | ||
|
|
e07f8c0fbe | ||
|
|
90246afd03 | ||
|
|
9809e591ad | ||
|
|
26973461e7 | ||
|
|
759ec5d499 | ||
|
|
58ab3c325c | ||
|
|
44c8c67803 | ||
|
|
acb56d683a | ||
|
|
5dda522a62 | ||
|
|
79091c726b | ||
|
|
e5be06e07b | ||
|
|
f63992e209 | ||
|
|
9988011308 | ||
|
|
8584a9b72c | ||
|
|
42c8cb1354 | ||
|
|
aaeaf5cfa0 | ||
|
|
45b4e1463f | ||
|
|
be92a67544 | ||
|
|
5e0b8ebdf6 | ||
|
|
9d4ccd33e1 | ||
|
|
f5c42c70e5 | ||
|
|
dcc4656e5e | ||
|
|
ee2de3cff1 | ||
|
|
f96518b8e4 | ||
|
|
dac59966aa | ||
|
|
8115fbaa98 | ||
|
|
8b97439ffc | ||
|
|
fa83986250 | ||
|
|
e1b16465f8 | ||
|
|
57619dacb1 | ||
|
|
64e54d89eb | ||
|
|
aa4139f0b7 | ||
|
|
e2f1c1e16b | ||
|
|
1e7ef15e54 | ||
|
|
1cc156d6f6 | ||
|
|
1445a3faec | ||
|
|
1cf90692cf | ||
|
|
5656bea3f9 | ||
|
|
8e344cea76 | ||
|
|
5b1229c882 | ||
|
|
834649b390 | ||
|
|
d28170cc3f | ||
|
|
04e511026d | ||
|
|
11a3ecbba0 | ||
|
|
51b7bb93e2 | ||
|
|
9fd2028d9f | ||
|
|
75f0f40d70 | ||
|
|
3941c77826 | ||
|
|
4987ca3ba2 | ||
|
|
5fa481337a | ||
|
|
dd78e0e271 | ||
|
|
3c773e6823 | ||
|
|
54a9ff9256 | ||
|
|
eca6b09b18 | ||
|
|
b7f8ca6658 | ||
|
|
ffdeadac8a | ||
|
|
9e769904bf | ||
|
|
8d79ec6b07 | ||
|
|
3a123f9fa1 | ||
|
|
f0c0328919 | ||
|
|
274286032a | ||
|
|
76517374a2 | ||
|
|
2da027f3b5 | ||
|
|
fd712f131f | ||
|
|
38613e5f03 | ||
|
|
ec9060ba80 | ||
|
|
502d57e744 | ||
|
|
c59f2ab37a | ||
|
|
066189b486 | ||
|
|
37d4f92c33 | ||
|
|
55220e9d10 | ||
|
|
bd41286076 | ||
|
|
d84484c81c | ||
|
|
fec87d4c6a | ||
|
|
68ec6e2a37 | ||
|
|
a784ad435f | ||
|
|
cc9bb34873 | ||
|
|
2ddae5a96c | ||
|
|
40ad489c56 | ||
|
|
56c55d71fe | ||
|
|
56df15caf8 | ||
|
|
03720665b3 | ||
|
|
445429b510 | ||
|
|
c698587d53 | ||
|
|
b8466beee5 | ||
|
|
efa666445f | ||
|
|
59c7d77525 | ||
|
|
553da9baf6 | ||
|
|
486ddb3d42 | ||
|
|
381922fc02 | ||
|
|
4c891f0819 | ||
|
|
4b3d11ccab | ||
|
|
b1ab465991 | ||
|
|
952e41ad3d | ||
|
|
ae3adf23c8 | ||
|
|
c3cdf387c2 | ||
|
|
054f0c2c19 | ||
|
|
2f7fce2109 | ||
|
|
07469599bc | ||
|
|
08869da96e | ||
|
|
7540a6eb70 | ||
|
|
fa2d9357b8 | ||
|
|
247a40b65f | ||
|
|
01ffe6ad5a | ||
|
|
da3c2a073a | ||
|
|
c16630c32b | ||
|
|
bf64f465a8 | ||
|
|
c1e0b874d8 | ||
|
|
c780266139 | ||
|
|
08454d58d0 | ||
|
|
ee13540d78 | ||
|
|
b4ff54ffc8 | ||
|
|
6f96d9c7d1 | ||
|
|
5b66436519 | ||
|
|
379eb00b69 | ||
|
|
2036127612 | ||
|
|
957a918bd6 | ||
|
|
6b305972ac | ||
|
|
b8c06904ab | ||
|
|
6baa472567 | ||
|
|
9c449def57 | ||
|
|
e4acc133a9 | ||
|
|
8b181b877b | ||
|
|
194790110d | ||
|
|
c0cd197bd0 | ||
|
|
30ce269873 | ||
|
|
4d7be13c16 | ||
|
|
8cf0f7da5f | ||
|
|
bcb4e5ca64 | ||
|
|
07b003c77a | ||
|
|
f4e4f727dd | ||
|
|
644c53a074 | ||
|
|
c66622bd09 | ||
|
|
adf0589184 | ||
|
|
b7de0e6901 | ||
|
|
a90e59ec97 | ||
|
|
f4882c1c14 | ||
|
|
ed3b5a3cf1 | ||
|
|
45e2b7b12f | ||
|
|
1e73986c60 | ||
|
|
20f992110d | ||
|
|
18f09f9862 | ||
|
|
a0be1c7c48 | ||
|
|
5d34661a15 | ||
|
|
1639879106 | ||
|
|
a927ca659f | ||
|
|
804c884d8b | ||
|
|
51f215b8ac | ||
|
|
64838708ab | ||
|
|
91b7af52ac | ||
|
|
d3dded8791 | ||
|
|
022b385c0a | ||
|
|
7ee9b93365 | ||
|
|
c4c98aaabf | ||
|
|
10c0efaa5d | ||
|
|
d8a7d8de4a | ||
|
|
ab8b675bae | ||
|
|
194b602fd6 | ||
|
|
7da0c58b76 | ||
|
|
2dbbea4993 | ||
|
|
55d59bb1c4 | ||
|
|
a6facf7492 | ||
|
|
b8a1871cf1 | ||
|
|
f556c75d94 | ||
|
|
58bd7de66a | ||
|
|
4547b52748 | ||
|
|
b9acb84119 | ||
|
|
e3a783c546 | ||
|
|
2e136666be | ||
|
|
7d089cb5f0 | ||
|
|
3784d904fb | ||
|
|
fef6ebf793 | ||
|
|
316e177c1d | ||
|
|
4cdff14c7c | ||
|
|
97121bc719 | ||
|
|
1312aac349 | ||
|
|
8a5c9ddef2 | ||
|
|
55382519a1 | ||
|
|
cbb562b603 | ||
|
|
ba51f803ba | ||
|
|
d73543408e | ||
|
|
7d90dba08b | ||
|
|
f11ebe6166 | ||
|
|
1b917f0901 | ||
|
|
328353d053 | ||
|
|
4e87489dc1 | ||
|
|
8e5bcdd5ea | ||
|
|
882a29029e | ||
|
|
4704c5c975 | ||
|
|
957365ab91 | ||
|
|
f8d34d7f46 | ||
|
|
cb185e4827 | ||
|
|
f5c6b9e3d4 | ||
|
|
96f0f46b3e | ||
|
|
6a5b7ce3a1 | ||
|
|
f33c540efb | ||
|
|
7684ac5d3a | ||
|
|
c13b01da01 | ||
|
|
3453f05aca | ||
|
|
c8bb85a06b | ||
|
|
2aabc9902f | ||
|
|
6dba778e60 | ||
|
|
cbeaaca7af | ||
|
|
0e69c8902d | ||
|
|
f63d6cfced | ||
|
|
72f9de6cc7 | ||
|
|
509e89b9cf | ||
|
|
90cce19baf | ||
|
|
e4e93b1af1 | ||
|
|
8f30176edd | ||
|
|
4923d10b86 | ||
|
|
bd3a4e1ad7 | ||
|
|
0f99a6c5ca | ||
|
|
0150da94a8 | ||
|
|
b8da286f64 | ||
|
|
da797f154d | ||
|
|
926195efc4 | ||
|
|
8c1c5c820c | ||
|
|
f63f652edb | ||
|
|
174ef187e8 | ||
|
|
d1e76f401a | ||
|
|
d52983c5af | ||
|
|
4773934481 | ||
|
|
dbfc524180 | ||
|
|
60aa7c6104 | ||
|
|
907d716929 | ||
|
|
1689a8abe2 | ||
|
|
5db3820df4 | ||
|
|
f969e2e52b | ||
|
|
cde2306079 | ||
|
|
f6c440c172 | ||
|
|
1b98667365 | ||
|
|
bf69d5314e | ||
|
|
6d2ea659a4 | ||
|
|
0d89840179 | ||
|
|
f93e8fdccd | ||
|
|
68e4d36f40 | ||
|
|
cd5447de38 | ||
|
|
6c0bb61cb1 | ||
|
|
d9a45b1090 | ||
|
|
7549b3eb9e | ||
|
|
8f82ef7eb4 | ||
|
|
fbe84322b5 | ||
|
|
98fb9946e4 | ||
|
|
984bc5860f | ||
|
|
a42d27f056 | ||
|
|
aa4833ed74 | ||
|
|
6704ac4b46 | ||
|
|
4e4ec8e608 | ||
|
|
4f4a387f04 | ||
|
|
d0143f9e54 | ||
|
|
b2175e885f | ||
|
|
68dd96e563 | ||
|
|
168e712324 | ||
|
|
2889c28815 | ||
|
|
966bf8bf51 | ||
|
|
63ff3c34b3 | ||
|
|
736105cc12 | ||
|
|
b1fa4263ed | ||
|
|
31d435dc2b | ||
|
|
da9977a30f | ||
|
|
9c92522564 | ||
|
|
31e436868d | ||
|
|
794455d728 | ||
|
|
0adf85746d | ||
|
|
f1047df98e | ||
|
|
765f9d2545 | ||
|
|
0b5588a7dd | ||
|
|
4fda89d5c8 | ||
|
|
b8c5c60ece | ||
|
|
a3730aceeb | ||
|
|
df5240a67c | ||
|
|
620b0c898c | ||
|
|
02ac4bc48b | ||
|
|
d14310768c | ||
|
|
63f8e8849f | ||
|
|
7e7268bb5a | ||
|
|
173286d404 | ||
|
|
fd937e3209 | ||
|
|
31df29194b | ||
|
|
a1a2e189b6 | ||
|
|
5799a26cb7 | ||
|
|
fe200ca1ec | ||
|
|
7f7116e1c7 | ||
|
|
0cc1c4e5a7 | ||
|
|
2bc56de1c3 | ||
|
|
e28d15456c | ||
|
|
54dbede130 | ||
|
|
982254ff5e | ||
|
|
e1c60fa70f | ||
|
|
6923c4e247 | ||
|
|
0eba5f1cbc | ||
|
|
4858e59b70 | ||
|
|
1f70ad978f | ||
|
|
40294b10f5 | ||
|
|
8d045be0b0 | ||
|
|
e24a482deb | ||
|
|
f18d230ff6 | ||
|
|
72d4e5cf7a | ||
|
|
4c3e28ba85 | ||
|
|
821dc4ef56 | ||
|
|
612712f015 | ||
|
|
03a93b1186 | ||
|
|
04ffd00c0e | ||
|
|
a74475d4cd | ||
|
|
05ac7e6041 | ||
|
|
5ae90f2a4b | ||
|
|
b800db03fc | ||
|
|
662b958a7f | ||
|
|
7cd5eea6d3 | ||
|
|
ed223f0e4e | ||
|
|
8a374aed04 | ||
|
|
9ceacdb739 | ||
|
|
39daed23c4 | ||
|
|
19e6d4e4c8 | ||
|
|
22006617d0 | ||
|
|
3201d10bdd | ||
|
|
ea94bd8696 | ||
|
|
f646c04d09 | ||
|
|
17ff9ac328 | ||
|
|
283516614b | ||
|
|
6c8f04f829 | ||
|
|
505a10a8b1 | ||
|
|
4fd89e6a34 | ||
|
|
7bf666b062 | ||
|
|
764665cf15 | ||
|
|
b9dfd7db54 | ||
|
|
e09c5622f7 | ||
|
|
717347273d | ||
|
|
9bb1ba12b2 | ||
|
|
bff9715e7f | ||
|
|
cfcd896c59 | ||
|
|
aaa50cacda | ||
|
|
3413adf16f | ||
|
|
3d6aa69ca1 | ||
|
|
ab115c4a6b | ||
|
|
e1e7bc8e0d | ||
|
|
6602b23f09 | ||
|
|
862fe6e2e3 | ||
|
|
5a34fa182a | ||
|
|
0b72507e2d | ||
|
|
cc3ddd51fd | ||
|
|
f793fd5010 | ||
|
|
fb92fd9357 | ||
|
|
a415a2705f | ||
|
|
765f140121 | ||
|
|
cb47f9f94b | ||
|
|
d0fb9f6aee | ||
|
|
9d424f5122 | ||
|
|
f71237ea95 | ||
|
|
fb5925e1e8 | ||
|
|
f86bdb7619 | ||
|
|
ad5299d0cd | ||
|
|
904bb90385 | ||
|
|
2e7a08c006 | ||
|
|
38e75da92f | ||
|
|
97708c2c80 | ||
|
|
e5ce64266f | ||
|
|
a765be0a6f | ||
|
|
0bec93ab1c | ||
|
|
dfb1b8f841 | ||
|
|
322b522a52 | ||
|
|
9dd4f71526 | ||
|
|
94b4e3d366 | ||
|
|
bbb2897d20 | ||
|
|
a5e41e479a | ||
|
|
2baea0ce13 | ||
|
|
90cbff885f | ||
|
|
0d9034504e | ||
|
|
800749c5ed | ||
|
|
30f27f29b4 | ||
|
|
2985cf7237 | ||
|
|
003ddc51de | ||
|
|
c369ac6b90 | ||
|
|
e2b9e37867 | ||
|
|
1e105b4135 | ||
|
|
c5c253af4e | ||
|
|
717835e5c1 | ||
|
|
e9ba62dbd9 | ||
|
|
ad5c22ecdb | ||
|
|
2e92b97f01 | ||
|
|
ae8fe0fe1e | ||
|
|
d992d7f77c | ||
|
|
a7cb7ec1af | ||
|
|
3afeb30795 | ||
|
|
26feeb125e | ||
|
|
211fb219a7 | ||
|
|
e71ef834c0 | ||
|
|
29eba93ee3 | ||
|
|
52ebfe9309 | ||
|
|
b3e78c6dc1 | ||
|
|
cd0184970a | ||
|
|
6401480874 | ||
|
|
6ca9eb13dd | ||
|
|
987ea51264 | ||
|
|
df37491199 | ||
|
|
9a420403de | ||
|
|
17da2807cf | ||
|
|
22fba0c172 | ||
|
|
14005563a3 | ||
|
|
a115ff8ce2 | ||
|
|
d75b29f51d | ||
|
|
3e8f7911af | ||
|
|
175a21c0e4 | ||
|
|
a2801bff7c | ||
|
|
f1a50f433f | ||
|
|
76bfde4d77 | ||
|
|
d393a4c9ca | ||
|
|
9ea6b0b8bb | ||
|
|
c20b91d5ea | ||
|
|
fad8a38bdf | ||
|
|
2440a38e82 | ||
|
|
b7541c43c8 | ||
|
|
0f10bb0bc9 | ||
|
|
357717886e | ||
|
|
94a4051d29 | ||
|
|
0e581cbcf3 | ||
|
|
230d9725e8 | ||
|
|
dee41b315f | ||
|
|
72e6c75433 | ||
|
|
ebe12f838c | ||
|
|
7279fdc25f | ||
|
|
af5c859385 | ||
|
|
e8896fbdf7 | ||
|
|
54695b8046 | ||
|
|
c573c755d2 | ||
|
|
b299301b69 | ||
|
|
a3a7198777 | ||
|
|
ca8cc91f37 | ||
|
|
26c813c07b | ||
|
|
f109cb684a | ||
|
|
1baefaade4 | ||
|
|
5ac0f93214 | ||
|
|
ecfbed00b1 | ||
|
|
6e429d6c78 | ||
|
|
fa4bb0447a | ||
|
|
aa0be40124 | ||
|
|
04d5310c04 | ||
|
|
74069af309 | ||
|
|
6bfeec6d16 | ||
|
|
0f4c057395 | ||
|
|
2fd74f3b7e | ||
|
|
fb171a57c2 | ||
|
|
b26fc69e73 | ||
|
|
28961b1cfa | ||
|
|
597f2f7b1b | ||
|
|
00cd8bb3f3 | ||
|
|
5732e60510 | ||
|
|
7b271e21e3 | ||
|
|
1a5f9683c2 | ||
|
|
3b74d55442 | ||
|
|
8920396360 | ||
|
|
9c505e4402 | ||
|
|
de4c6b384c | ||
|
|
6dec1ba8af | ||
|
|
9e6788de2f | ||
|
|
1bd7e5c9c4 | ||
|
|
ec75fdddb5 | ||
|
|
f98aafb97c | ||
|
|
f4d2a0daf9 | ||
|
|
de8fb8de90 | ||
|
|
44d137b8f9 | ||
|
|
777c972bdc | ||
|
|
f9efa15781 | ||
|
|
1d1cd679dd | ||
|
|
a9ed4686dd | ||
|
|
5b742eb5b2 | ||
|
|
a3d78f4d0e | ||
|
|
214929e5e5 | ||
|
|
67602b8d85 | ||
|
|
2412edaa3a | ||
|
|
b1584aa2c3 | ||
|
|
a14a416193 | ||
|
|
f3251e9407 | ||
|
|
096885d91f | ||
|
|
368700156c | ||
|
|
81cf50520b | ||
|
|
649748c2d3 | ||
|
|
bf7a708440 | ||
|
|
8faa4d137b | ||
|
|
479bd91b74 | ||
|
|
6bc7f1fca2 | ||
|
|
dadd8e2c50 | ||
|
|
03f342a21c | ||
|
|
7fe5397e21 | ||
|
|
b6e1fd179e | ||
|
|
754c7d8e3b | ||
|
|
925d3ccd1b | ||
|
|
d60d0ac9c5 | ||
|
|
e1b51dd6af | ||
|
|
fbe9d9f128 | ||
|
|
509826949d | ||
|
|
39aaa8a292 | ||
|
|
069c76c53a | ||
|
|
f45c0caa45 | ||
|
|
41b0e10709 | ||
|
|
8e8da20c13 | ||
|
|
269aa39378 | ||
|
|
ae8be97db7 | ||
|
|
f0ad40825b | ||
|
|
36d292747a | ||
|
|
b65d2262bf | ||
|
|
a7ab0c6b36 | ||
|
|
c02fcb6508 | ||
|
|
07c38de44b | ||
|
|
188d62c99b | ||
|
|
76b203ad10 | ||
|
|
909844aef5 | ||
|
|
046202719a | ||
|
|
ed15e2838d | ||
|
|
82466c2e5d | ||
|
|
c598daf350 | ||
|
|
a40421fa1f | ||
|
|
d98b464ce9 | ||
|
|
1d5e3205ac | ||
|
|
07eb17f5d5 | ||
|
|
3951725852 | ||
|
|
77956d69ad | ||
|
|
5784458d03 | ||
|
|
3d2115ff3c | ||
|
|
8618a67e2e | ||
|
|
234b9cafd7 | ||
|
|
4ecd899bac | ||
|
|
ce2c943397 | ||
|
|
51898abb71 | ||
|
|
e2f800dd63 | ||
|
|
d9e5bc9345 | ||
|
|
e42cc101cc | ||
|
|
845367e847 | ||
|
|
90afd3c3ed | ||
|
|
b4aeb04d1b | ||
|
|
65b0d45738 | ||
|
|
3c44388883 | ||
|
|
400f3a9156 | ||
|
|
ad6e837aa5 | ||
|
|
cadd7545c5 | ||
|
|
b41dea9ee1 | ||
|
|
7a6c0ab154 | ||
|
|
1bb1f5ebb3 | ||
|
|
fce5b8430d | ||
|
|
0befa6a491 | ||
|
|
b12ce943f7 | ||
|
|
d23b29aeb1 | ||
|
|
42d48c8da2 | ||
|
|
9e83a5e4d9 | ||
|
|
d2bf940105 | ||
|
|
7d4aca68cc | ||
|
|
d7094909c0 | ||
|
|
7083d55a9b | ||
|
|
770db2fee0 | ||
|
|
b8e65c4f26 | ||
|
|
5cd5186092 | ||
|
|
fa0b66c2dc | ||
|
|
1b199fd2c7 | ||
|
|
2ffbeeef8e | ||
|
|
26ce8b8ab7 | ||
|
|
8e224c4a27 | ||
|
|
cf5318b92b | ||
|
|
e50fa17f7c | ||
|
|
8766e3b408 | ||
|
|
c4c7f06d83 | ||
|
|
413e304845 | ||
|
|
046daf23d0 | ||
|
|
c57947949c | ||
|
|
0acefde805 | ||
|
|
a9e751b4b8 | ||
|
|
3df1ae8ded | ||
|
|
b4a2da0ea8 | ||
|
|
5c5d1e8d0a | ||
|
|
ff0c988a1d | ||
|
|
b9fc8f4b5f | ||
|
|
2ecaa39cb6 | ||
|
|
7b8654339c | ||
|
|
306e252c31 | ||
|
|
87c3bd6293 | ||
|
|
307beebb58 | ||
|
|
4109863aa9 | ||
|
|
0febdbe3a4 | ||
|
|
139dd5302b | ||
|
|
cc907b6530 | ||
|
|
ca1dacf2b6 | ||
|
|
abc1c164cf | ||
|
|
dc801464ef | ||
|
|
99c6fe20c2 | ||
|
|
9d780ae24a | ||
|
|
a44dec0402 | ||
|
|
a081152baa | ||
|
|
9b50d48f46 | ||
|
|
5121fc6b1f | ||
|
|
d4ac261e85 | ||
|
|
2e9561371d | ||
|
|
942fd3c4ce | ||
|
|
8cf32752e9 | ||
|
|
b240ca9939 | ||
|
|
e25d99129c | ||
|
|
1fee47e087 | ||
|
|
e835b31277 | ||
|
|
6817945e12 | ||
|
|
030fb1262e | ||
|
|
fae49096f3 | ||
|
|
afd491ecea | ||
|
|
09bc100ad9 | ||
|
|
037f18ac56 | ||
|
|
a5746dfa21 | ||
|
|
cedc5108fc | ||
|
|
65af3d0f54 | ||
|
|
6c4fa65f91 | ||
|
|
4731ad8061 | ||
|
|
7dc41e15d3 | ||
|
|
8326539d40 | ||
|
|
163e6e0f2a | ||
|
|
f56bb251e9 | ||
|
|
152ca99276 | ||
|
|
7c398d2c67 | ||
|
|
a526c942ca | ||
|
|
af8fd15929 | ||
|
|
7bfd5d4bc8 | ||
|
|
4382d5c56d | ||
|
|
f43b9c96de | ||
|
|
c64f72e394 | ||
|
|
3d54f832c5 | ||
|
|
867ba24c6c | ||
|
|
9715c5394c | ||
|
|
67b5c72520 | ||
|
|
43450f6cc7 | ||
|
|
a3737d4f35 | ||
|
|
3314e94a9a | ||
|
|
a27436b086 | ||
|
|
fe5554ffb1 | ||
|
|
f305f8d822 | ||
|
|
1f54bc41cc | ||
|
|
c82d028429 | ||
|
|
be2a8b7b07 | ||
|
|
261fc82016 | ||
|
|
37b940f3a5 | ||
|
|
0504e904a2 | ||
|
|
71bfdd9bfd | ||
|
|
c7305f6b06 | ||
|
|
4fb07ff181 | ||
|
|
4631dcf857 | ||
|
|
f6f9840eb7 | ||
|
|
4de8165c95 | ||
|
|
242672f49d | ||
|
|
c32c975a71 | ||
|
|
82e759d708 | ||
|
|
9de44d2605 | ||
|
|
132d0cf578 | ||
|
|
029dc9f8d9 | ||
|
|
5567b1dad8 | ||
|
|
ea00ec64af | ||
|
|
7259e6be0a | ||
|
|
2e40557b39 | ||
|
|
e68fc7c558 | ||
|
|
055dfb000d | ||
|
|
b997ab6e3f | ||
|
|
25f31d0bb8 | ||
|
|
4cfd8a7e2c | ||
|
|
0ec19a8fee | ||
|
|
2749563f5d | ||
|
|
e7e2e3f7e0 | ||
|
|
0a33c0aac5 | ||
|
|
24e09fd2d9 | ||
|
|
4d0499a61e | ||
|
|
ae82807139 | ||
|
|
65147e1935 | ||
|
|
8e557d122b | ||
|
|
486b19aa90 | ||
|
|
14cb34ac95 | ||
|
|
abfc23b04d | ||
|
|
ebb24aefa1 | ||
|
|
2573f46f40 | ||
|
|
5dcb8cd73a | ||
|
|
e4bfe09882 | ||
|
|
eecbfe04db | ||
|
|
671e2adc32 | ||
|
|
1137e476dd | ||
|
|
cb63b321d0 | ||
|
|
c36b0d2975 | ||
|
|
f8ad562b95 | ||
|
|
c35ab38f36 | ||
|
|
073b775566 | ||
|
|
85c7a7db8d | ||
|
|
1e134df27d | ||
|
|
bdff84885a | ||
|
|
f1a9c3722c | ||
|
|
8b402f6423 | ||
|
|
a0aec52661 | ||
|
|
407ab43dd1 | ||
|
|
c2165e0196 | ||
|
|
2e75bc3f3b | ||
|
|
e91c2ca427 | ||
|
|
965ff04bcc | ||
|
|
ac4bd418f3 | ||
|
|
e9e844c1f7 | ||
|
|
aa2941fcdb | ||
|
|
dbc909a317 | ||
|
|
11465a4ce9 | ||
|
|
f5007f94dc | ||
|
|
d18ac2e6eb | ||
|
|
b9fc5c39ae | ||
|
|
9dc2278083 | ||
|
|
281060a972 | ||
|
|
91626f079d | ||
|
|
7305c6c54b | ||
|
|
bce7fa871d | ||
|
|
a35fd80763 | ||
|
|
b383f9dfbc | ||
|
|
680ad3c145 | ||
|
|
7b712e7f90 | ||
|
|
2462eac497 | ||
|
|
bb818c8942 | ||
|
|
ddc881af11 | ||
|
|
838fba9173 | ||
|
|
0b6f326c18 | ||
|
|
00895fc7ab | ||
|
|
07f38aa283 | ||
|
|
ecf1d3790c | ||
|
|
53c9e5bb4a | ||
|
|
b20b03113a | ||
|
|
ec8273aa9f | ||
|
|
2862f0dfae | ||
|
|
fd4963c74b | ||
|
|
df99ef4481 | ||
|
|
35d1057673 | ||
|
|
e6a90a18c4 | ||
|
|
26afb69a14 | ||
|
|
e8c0c43e9d | ||
|
|
1707f333bf | ||
|
|
6798fb21b2 | ||
|
|
89ff3b169b | ||
|
|
abddb265be | ||
|
|
b328fa74a7 | ||
|
|
f97aa651a0 | ||
|
|
8d86eed0a7 | ||
|
|
05f906a759 | ||
|
|
4b16be1b75 | ||
|
|
bd97a7c5d2 | ||
|
|
a3a23d8870 | ||
|
|
30bddceac5 | ||
|
|
989a2cc89c | ||
|
|
3f17e8c3c8 | ||
|
|
140e6b08ca | ||
|
|
6a39b721ba | ||
|
|
1df6f4b9df | ||
|
|
9493fb3a7a | ||
|
|
0d1f3b855f | ||
|
|
0982154a15 | ||
|
|
378f3f5efa | ||
|
|
9b8d6e1dc7 | ||
|
|
6540c695de | ||
|
|
1d71ec07be | ||
|
|
c837dd5cc8 | ||
|
|
bc52e4da0e | ||
|
|
f0b4040458 | ||
|
|
d804c4be2a | ||
|
|
ede413a213 | ||
|
|
9cee319ed9 | ||
|
|
f7b281f655 | ||
|
|
8dbb083b90 | ||
|
|
0be6d658ed | ||
|
|
1efce41767 | ||
|
|
da23b6ea9a | ||
|
|
a61d3b3fd4 | ||
|
|
ab9284b80f | ||
|
|
424af27a47 | ||
|
|
5039a05055 | ||
|
|
d150b22eae | ||
|
|
a617675771 | ||
|
|
f27034bb35 | ||
|
|
86b203c21b | ||
|
|
73c5a1ad9b | ||
|
|
81c71777cb | ||
|
|
599072eef6 | ||
|
|
02ea3afbe9 | ||
|
|
0c1a2e82bf | ||
|
|
f89fb87c92 | ||
|
|
98d6cf842a | ||
|
|
69dc02b2c2 | ||
|
|
7d1a3d32e9 | ||
|
|
d93cc826b2 | ||
|
|
8025f3a082 | ||
|
|
247871f678 | ||
|
|
327c8b83be | ||
|
|
0f8c334de8 | ||
|
|
292d4cd450 | ||
|
|
38d1c9974b | ||
|
|
0be7300677 | ||
|
|
c03585aeca | ||
|
|
d39dad3287 | ||
|
|
0a3ca3affe | ||
|
|
b7cf0e6bc7 | ||
|
|
7430013cc3 | ||
|
|
6dd093fe72 | ||
|
|
8a8d6f16ae | ||
|
|
2e16844141 | ||
|
|
a152cc47c7 | ||
|
|
241507228f | ||
|
|
8aa7d272fa | ||
|
|
01ac5382ea | ||
|
|
02b88a8357 | ||
|
|
c99d6556db | ||
|
|
1db777cd31 | ||
|
|
aea44fc8bc | ||
|
|
c0da9d49d9 | ||
|
|
ce42573f43 | ||
|
|
148fe4c729 | ||
|
|
32fd484b58 | ||
|
|
7d24e748b7 | ||
|
|
f1a1612f5d | ||
|
|
6501e5cf8d | ||
|
|
cd4a684613 | ||
|
|
d06fda6d9d | ||
|
|
139010e75b | ||
|
|
7638b07e34 | ||
|
|
f7bf4416c9 | ||
|
|
2b96b656a9 | ||
|
|
0fe251b6ec | ||
|
|
a1afc70bcb | ||
|
|
ced3e6959c | ||
|
|
1c229d54d9 | ||
|
|
dd50193c18 | ||
|
|
ab0f9bbdbd | ||
|
|
055d181c67 | ||
|
|
7042c45deb | ||
|
|
960c2291b6 | ||
|
|
773bfe1407 | ||
|
|
a23f995717 | ||
|
|
bd509b3c75 | ||
|
|
a0f8ba9afb | ||
|
|
a71e040c6d | ||
|
|
454abec468 | ||
|
|
96035d5257 | ||
|
|
9f2b59f2a2 | ||
|
|
a54046907d | ||
|
|
2ce5679373 | ||
|
|
2dad9f84fc | ||
|
|
a81a361a93 | ||
|
|
4660e68abf | ||
|
|
f8a77cf809 | ||
|
|
0abe9598f6 | ||
|
|
20de713716 | ||
|
|
9dbef6acc2 | ||
|
|
4c93bf7cf0 | ||
|
|
a8fea0fc49 | ||
|
|
2d5975d6e3 | ||
|
|
6874cfd5b1 | ||
|
|
d34013396a | ||
|
|
a35b0915ab | ||
|
|
b35f3b4375 | ||
|
|
f4f9612789 | ||
|
|
bfc79c6051 | ||
|
|
d3e60487bb | ||
|
|
f36f411a8d | ||
|
|
35f4aea69f | ||
|
|
8795383e7c | ||
|
|
fc4750706b | ||
|
|
0ae59bd3e6 | ||
|
|
61fd14c816 | ||
|
|
c7d3d87b09 | ||
|
|
5e68f7b58c | ||
|
|
8a692200d5 | ||
|
|
829eacb0fb | ||
|
|
9aeca91f22 | ||
|
|
1bdb512826 | ||
|
|
060fa6e5f7 | ||
|
|
171a54c0fc | ||
|
|
17406b448d | ||
|
|
b4b661a3ad | ||
|
|
4857969ca4 | ||
|
|
d9d01e09aa | ||
|
|
dadca97d8a | ||
|
|
8afba8b53d | ||
|
|
85dac1184c | ||
|
|
4167460d28 | ||
|
|
1d8a60749d | ||
|
|
31a597ca81 | ||
|
|
e5e77ffec5 | ||
|
|
41c3df41b4 | ||
|
|
053066f1a7 | ||
|
|
21135dac07 | ||
|
|
22ccce3208 | ||
|
|
70aa3964ee | ||
|
|
167489823a | ||
|
|
d1426f1b37 | ||
|
|
7dcdc59c8e | ||
|
|
1e13ee87af | ||
|
|
5101c1a759 | ||
|
|
74bb079625 | ||
|
|
2da7979d94 | ||
|
|
4ecb2c7c27 | ||
|
|
251f51b01c | ||
|
|
2fba9b83af | ||
|
|
1c97cb3cec | ||
|
|
25511f898c | ||
|
|
d820f153a9 | ||
|
|
77b06acad4 | ||
|
|
6760a96527 | ||
|
|
257f426ab9 | ||
|
|
3771a50f30 | ||
|
|
85ee211172 | ||
|
|
1b7a66b41a | ||
|
|
8f9a1aa931 | ||
|
|
8b60fd0e55 | ||
|
|
cd7b3b4f6e | ||
|
|
83b0f62d59 | ||
|
|
dd3a78ada8 | ||
|
|
307e2b889c | ||
|
|
a063f7664d | ||
|
|
b1ab857592 | ||
|
|
2b8bbc434f | ||
|
|
c6878c27b9 | ||
|
|
02ff4a4acb | ||
|
|
23f757e916 | ||
|
|
f0ababa409 | ||
|
|
331ff341f3 | ||
|
|
793a84edfb | ||
|
|
2893d4aebd | ||
|
|
b7ac7680d9 | ||
|
|
18dd59ed0f | ||
|
|
443906da55 | ||
|
|
a9f29da4f8 | ||
|
|
cf456cff81 | ||
|
|
69b3c96e09 | ||
|
|
61eb86b3a0 | ||
|
|
f0ad32bc37 | ||
|
|
aeeb2820f9 | ||
|
|
2d88405d69 | ||
|
|
f32ed5db89 | ||
|
|
f1606ac51b | ||
|
|
d13eb1a55d | ||
|
|
384fbf5464 | ||
|
|
4874f9d051 | ||
|
|
51732fa660 | ||
|
|
bb25632178 | ||
|
|
9a2cf82623 | ||
|
|
c0734fc29e | ||
|
|
c60067e733 | ||
|
|
6293634e36 | ||
|
|
a047695a84 | ||
|
|
db9d84ed76 | ||
|
|
e296b1df60 | ||
|
|
b72e5f5437 | ||
|
|
de09ae94b8 | ||
|
|
b36a33f015 | ||
|
|
d95891256b | ||
|
|
9c8097ecb9 | ||
|
|
18a3dfd604 | ||
|
|
59fd337e44 | ||
|
|
696cd235fd | ||
|
|
59c7efccb2 | ||
|
|
b031ebbffd | ||
|
|
67415babc2 | ||
|
|
563dd4683d | ||
|
|
e9131f729a | ||
|
|
c4ea626e33 | ||
|
|
fefba7976b | ||
|
|
2ce8555692 | ||
|
|
9fe9c386bb | ||
|
|
e8cd2c7548 | ||
|
|
158d8b086a | ||
|
|
1c534d7475 | ||
|
|
90f8dbe243 | ||
|
|
0c33b26fa9 | ||
|
|
d320679f69 | ||
|
|
8d5398b5a3 | ||
|
|
6cd8593fa5 | ||
|
|
5ebbc178a5 | ||
|
|
4f6e229943 | ||
|
|
3e846d9527 | ||
|
|
981d745b74 | ||
|
|
2dd0858960 | ||
|
|
f72819a664 | ||
|
|
5361b1e87b | ||
|
|
e15d03ed4e | ||
|
|
6c9041ce40 | ||
|
|
8da96e6e48 | ||
|
|
385aa6d438 | ||
|
|
79f24a5944 | ||
|
|
80570717f9 | ||
|
|
ebab79c4ca | ||
|
|
42882ebe11 | ||
|
|
d2de26f765 | ||
|
|
e2cebfbd16 | ||
|
|
a58cc6bdf3 | ||
|
|
36bc1553c0 | ||
|
|
17b06c39e9 | ||
|
|
ba2f6eb7be | ||
|
|
b93145f26d | ||
|
|
e88ea9c13d | ||
|
|
1275d0023d | ||
|
|
27f6f225c9 | ||
|
|
41362aa34a | ||
|
|
a99609e016 | ||
|
|
c0ea2d8ec3 | ||
|
|
bb6b31d715 | ||
|
|
21695dd2cb | ||
|
|
531835c948 | ||
|
|
77e3b351fd | ||
|
|
66f756575a | ||
|
|
7acc8bc7ed | ||
|
|
0a4d337a53 | ||
|
|
0198068a13 | ||
|
|
1c15f8462f | ||
|
|
3929ce0dfc | ||
|
|
7deeaf305d | ||
|
|
0f04c06e13 | ||
|
|
d1863fa714 | ||
|
|
46b122a167 | ||
|
|
ee3db1e5c5 | ||
|
|
bd830617c9 | ||
|
|
a9b6493091 | ||
|
|
9894e45516 | ||
|
|
2cfc82f3aa | ||
|
|
bb9eab0989 | ||
|
|
dc87ec1c82 | ||
|
|
98b7b65ce7 | ||
|
|
9f8f32b33e | ||
|
|
a80ec6d893 | ||
|
|
4d85930f5a | ||
|
|
f722f4112d | ||
|
|
383276f47a | ||
|
|
33c78e4a17 | ||
|
|
55a0de7899 | ||
|
|
6b3aab66bf | ||
|
|
77e70ef8d3 | ||
|
|
9b92143501 | ||
|
|
87f94f6b8f | ||
|
|
5d955e77b6 | ||
|
|
270a276b98 | ||
|
|
be7d914e39 | ||
|
|
37fc00cce8 | ||
|
|
0d515abadb | ||
|
|
daef01194e | ||
|
|
258bf1cc41 | ||
|
|
ce3d7829d7 | ||
|
|
c66a01c1a6 | ||
|
|
d113a92ce5 | ||
|
|
7b655d12df | ||
|
|
a4c872f1e8 | ||
|
|
0e7d9bf9c1 | ||
|
|
6252a5bc75 | ||
|
|
e4e80c9c31 | ||
|
|
165c5610c3 | ||
|
|
13fbc7dd39 | ||
|
|
02a75fc32a | ||
|
|
699c4d107b | ||
|
|
e4810302e1 | ||
|
|
73f10cad66 | ||
|
|
f1d670dc46 | ||
|
|
045539c752 | ||
|
|
782c09b686 | ||
|
|
6109718c67 | ||
|
|
cd758d7e48 | ||
|
|
fcb0fcadeb | ||
|
|
26fb506560 | ||
|
|
b6c4239322 | ||
|
|
74f9283f18 | ||
|
|
60e6ae6e23 | ||
|
|
83d9229295 | ||
|
|
e079b0f3ed | ||
|
|
d433a5461d | ||
|
|
2c43f6bf21 | ||
|
|
ac57509a29 | ||
|
|
c5ce655cf6 | ||
|
|
9fe05efb4e | ||
|
|
dcf207f5e5 | ||
|
|
11facab71c | ||
|
|
5b4975f34c | ||
|
|
069e535f1a | ||
|
|
1eb053447e | ||
|
|
93c7c06b2d | ||
|
|
b0085bc1e1 | ||
|
|
9133951446 | ||
|
|
7853d4686a | ||
|
|
ed5892eb56 | ||
|
|
687804de2c | ||
|
|
9d166041ab | ||
|
|
924041bff4 | ||
|
|
e9216d3e0f | ||
|
|
db8f1bca66 | ||
|
|
2429831153 | ||
|
|
80d2246634 | ||
|
|
56df2477ca | ||
|
|
9b4384dc33 | ||
|
|
bc65857831 | ||
|
|
de462d2385 | ||
|
|
90150428be | ||
|
|
2a7f951f4f | ||
|
|
82789328c1 | ||
|
|
13bccd1d3f | ||
|
|
43c514132d | ||
|
|
9e0fdcbfee | ||
|
|
008dc3fc52 | ||
|
|
9fde237d9b | ||
|
|
d626c08b4c | ||
|
|
58e223e74b | ||
|
|
1da1df156e | ||
|
|
3442372281 | ||
|
|
1b3b50c113 | ||
|
|
18e126b781 | ||
|
|
c88600adda | ||
|
|
4787361e66 | ||
|
|
b5ece8b5bd | ||
|
|
7ee3116f29 | ||
|
|
1fc0d77971 | ||
|
|
a32ab4bf7f | ||
|
|
2d8083bf18 | ||
|
|
63b9be9845 | ||
|
|
85a83d8c71 | ||
|
|
71b33a296c | ||
|
|
becdfd6f03 | ||
|
|
41744f9416 | ||
|
|
cb89a92ba9 | ||
|
|
93d54373c6 | ||
|
|
385addfe08 | ||
|
|
4c21957b04 | ||
|
|
ab6b011225 | ||
|
|
e72d91503c | ||
|
|
b9ee206908 | ||
|
|
4c9abba5fa | ||
|
|
3424b0542a | ||
|
|
fec90b8958 | ||
|
|
4da7fe4ff9 | ||
|
|
c53623dd67 | ||
|
|
6540ffa4dd | ||
|
|
5ee6db02ff | ||
|
|
d8221f466a | ||
|
|
462bea2a09 | ||
|
|
f452a97278 | ||
|
|
eb9d2be587 | ||
|
|
df1e747861 | ||
|
|
f48595b1ff | ||
|
|
12cd4e19cb | ||
|
|
a195e94522 | ||
|
|
02abb39dc2 | ||
|
|
f7a0b1ef78 | ||
|
|
7678f25879 |
No files matched your search
@@ -0,0 +1 @@
|
||||
patreon: luckperms
|
||||
+75
-33
@@ -1,37 +1,79 @@
|
||||
# built application files
|
||||
*.jar
|
||||
|
||||
# Java class files
|
||||
*.class
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
logs/
|
||||
|
||||
# Eclipse project files
|
||||
.classpath
|
||||
.project
|
||||
|
||||
# Intellij project files
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
### Intellij ###
|
||||
.idea/
|
||||
*.iws
|
||||
/out/
|
||||
*.iml
|
||||
.idea_modules/
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Gradle
|
||||
.gradletasknamecache
|
||||
.gradle/
|
||||
build/
|
||||
### Eclipse ###
|
||||
.metadata
|
||||
bin/
|
||||
gradle/
|
||||
gradlew*
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
.recommenders
|
||||
.externalToolBuilders/
|
||||
*.launch
|
||||
.factorypath
|
||||
.recommenders/
|
||||
.apt_generated/
|
||||
.project
|
||||
.classpath
|
||||
|
||||
# Maven
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
### Linux ###
|
||||
*~
|
||||
.fuse_hidden*
|
||||
.directory
|
||||
.Trash-*
|
||||
.nfs*
|
||||
|
||||
### macOS ###
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
Icon
|
||||
._*
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
### NetBeans ###
|
||||
nbproject/private/
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
.nb-gradle/
|
||||
|
||||
### Windows ###
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
*.stackdump
|
||||
[Dd]esktop.ini
|
||||
$RECYCLE.BIN/
|
||||
*.lnk
|
||||
|
||||
### Gradle ###
|
||||
.gradle
|
||||
/build/
|
||||
/out/
|
||||
gradle-app.setting
|
||||
!gradle-wrapper.jar
|
||||
.gradletasknamecache
|
||||
@@ -0,0 +1,26 @@
|
||||
### :speech_balloon: Looking for support?
|
||||
|
||||
Details about support for the project can be found [here, on the Wiki Homepage](https://github.com/lucko/LuckPerms/wiki#support).
|
||||
|
||||
### :bug: Reporting bugs?
|
||||
|
||||
Before reporting a bug or issue, please make sure that the issue is actually being caused by or related to LuckPerms. We get a lot of reports which are caused by other software - please double check!
|
||||
|
||||
If you're unsure, feel free to ask using the above resources BEFORE making a report.
|
||||
|
||||
Bugs or issues should be reported using the [GitHub Issues tab](https://github.com/lucko/LuckPerms/issues).
|
||||
|
||||
### :pencil: Want to contribute code?
|
||||
#### Pull Requests
|
||||
If you make any changes or improvements to the plugin which you think would be beneficial to others, please consider making a pull request to merge your changes back into the upstream project. (especially if your changes are bug fixes!)
|
||||
|
||||
LuckPerms loosely follows the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). Generally, try to copy the style of code found in the class you're editing.
|
||||
|
||||
If you're considering submitting a substantial pull request, please open an issue so we can discuss the change before starting work on the contribution. Most pull requests are happily accepted, but larger changes may have an inpact on the maintainability of the project, and require more consideration.
|
||||
|
||||
#### Project Layout
|
||||
The project is split up into a few seperate modules.
|
||||
|
||||
* **API** - The public, semantically versioned API used by other plugins wishing to integrate with and retrieve data from LuckPerms. This module (for the most part) does not contain any implementation itself, and is provided by the plugin.
|
||||
* **Common** - The common module contains most of the code which implements the respective LuckPerms plugins. This abstract module reduces duplicated code throughout the project.
|
||||
* **Bukkit, BungeeCord, Sponge, Nukkit & Velocity** - Each use the common module to implement plugins on the respective server platforms.
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
This file is part of LuckPerms, licensed under the MIT License.
|
||||
|
||||
Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
Copyright (c) contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,6 +1,7 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
Copyright (c) contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -18,4 +19,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
SOFTWARE.
|
||||
@@ -1,26 +1,50 @@
|
||||

|
||||
# LuckPerms [](https://ci.lucko.me/job/LuckPerms/)
|
||||
An advanced permissions implementation for Bukkit/Spigot, BungeeCord and Sponge.
|
||||

|
||||
# LuckPerms
|
||||
[](https://ci.lucko.me/job/LuckPerms/)
|
||||
[](https://javadoc.io/doc/me.lucko.luckperms/luckperms-api)
|
||||
[](https://search.maven.org/artifact/me.lucko.luckperms/luckperms-api)
|
||||
[](https://discord.gg/luckperms)
|
||||
|
||||
## Links
|
||||
* **Development Builds** - <https://ci.lucko.me/job/LuckPerms>
|
||||
* **Javadocs** - <https://jd.lucko.me/LuckPerms>
|
||||
* **Wiki** - <https://github.com/lucko/LuckPerms/wiki>
|
||||
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.
|
||||
|
||||
## Description
|
||||
LuckPerms is an advanced permissions implementation aiming to be a flexible, performant and reliable alternative to other permission systems, providing all the features you could ever possibly need in a permissions plugin, along with an extensive and well documented API for developers.
|
||||
LuckPerms also includes an extensive API for developers, and support for a variety of Minecraft server software & data storage options.
|
||||
|
||||
* [Spigot Plugin Page](https://www.spigotmc.org/resources/luckperms-an-advanced-permissions-system.28140/ "Spigot Plugin Page")
|
||||
* [Sponge Plugin Page](https://forums.spongepowered.org/t/luckperms-an-advanced-permissions-system/14274 "Sponge Plugin Page")
|
||||
Still not convinced? More information can be found on the wiki, under: [Why LuckPerms?](https://github.com/lucko/LuckPerms/wiki/Why-LuckPerms)
|
||||
|
||||
## LuckPerms vs Other Plugins
|
||||

|
||||
_Features checked on 23rd Aug 2016. If you find any inaccuracies, please do let me know. I tried to be as fair as possible, and copy all major features from the respective plugin pages._
|
||||
## Useful Links
|
||||
|
||||
The latest **downloads** can be found on the [project's homepage](https://luckperms.github.io/).
|
||||
|
||||
More information about the project & how to use the plugin can be found in the [wiki](https://github.com/lucko/LuckPerms/wiki).
|
||||
|
||||
## Building
|
||||
LuckPerms uses Gradle to handle dependencies & building.
|
||||
|
||||
#### Requirements
|
||||
* Java 8 JDK or newer
|
||||
* Git
|
||||
|
||||
#### Compiling from source
|
||||
```sh
|
||||
git clone https://github.com/lucko/LuckPerms.git
|
||||
cd LuckPerms/
|
||||
./gradlew build
|
||||
```
|
||||
|
||||
You can find the output jars in the `build/libs` directories.
|
||||
|
||||
## Contributing
|
||||
#### Pull Requests
|
||||
If you make any changes or improvements to the plugin which you think would be beneficial to others, please consider making a pull request to merge your changes back into the upstream project. (especially if your changes are bug fixes!)
|
||||
|
||||
LuckPerms loosely follows the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). Generally, try to copy the style of code found in the class you're editing.
|
||||
|
||||
#### Project Layout
|
||||
The project is split up into a few separate modules.
|
||||
|
||||
* **API** - The public, semantically versioned API used by other plugins wishing to integrate with and retrieve data from LuckPerms. This module (for the most part) does not contain any implementation itself, and is provided by the plugin.
|
||||
* **Common** - The common module contains most of the code which implements the respective LuckPerms plugins. This abstract module reduces duplicated code throughout the project.
|
||||
* **Bukkit, BungeeCord, Sponge, Nukkit & Velocity** - Each use the common module to implement plugins on the respective server platforms.
|
||||
|
||||
## License
|
||||
See LICENSE.md.
|
||||
|
||||
## Thanks to:
|
||||
[](http://www.ej-technologies.com/products/jprofiler/overview.html)
|
||||
|
||||
Thanks to ej-technologies for granting LuckPerms an open source licence to their [java profiling software](http://www.ej-technologies.com/products/jprofiler/overview.html "Java Profiler").
|
||||
LuckPerms is licensed under the permissive MIT license. Please see [`LICENSE.txt`](https://github.com/lucko/LuckPerms/blob/master/LICENSE.txt) for more info.
|
||||
@@ -0,0 +1,98 @@
|
||||
project.version = '4.4'
|
||||
|
||||
dependencies {
|
||||
compileOnly 'com.google.guava:guava:19.0'
|
||||
compileOnly 'org.checkerframework:checker-qual:2.5.5'
|
||||
}
|
||||
|
||||
// Only used occasionally for deployment - not needed for normal builds.
|
||||
/*
|
||||
if (project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')) {
|
||||
apply plugin: 'signing'
|
||||
|
||||
javadoc {
|
||||
options.encoding = 'UTF-8'
|
||||
options.charSet = 'UTF-8'
|
||||
options.links(
|
||||
'https://google.github.io/guava/releases/21.0/api/docs/',
|
||||
'https://docs.oracle.com/javase/8/docs/api/'
|
||||
)
|
||||
options.addStringOption('Xdoclint:none', '-quiet')
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||
classifier 'javadoc'
|
||||
from javadoc.destinationDir
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
classifier 'sources'
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives javadocJar
|
||||
archives sourcesJar
|
||||
}
|
||||
|
||||
signing {
|
||||
useGpgCmd()
|
||||
sign configurations.archives
|
||||
}
|
||||
|
||||
uploadArchives {
|
||||
repositories {
|
||||
mavenDeployer {
|
||||
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
|
||||
|
||||
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
|
||||
authentication(userName: sonatypeUsername, password: sonatypePassword)
|
||||
}
|
||||
|
||||
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') {
|
||||
authentication(userName: sonatypeUsername, password: sonatypePassword)
|
||||
}
|
||||
|
||||
pom {
|
||||
project {
|
||||
name 'LuckPerms API'
|
||||
description 'An advanced permissions plugin for Bukkit/Spigot, BungeeCord, Sponge, Nukkit and Velocity.'
|
||||
url 'https://luckperms.github.io'
|
||||
|
||||
licenses {
|
||||
license {
|
||||
name 'MIT'
|
||||
url 'https://opensource.org/licenses/MIT'
|
||||
}
|
||||
}
|
||||
|
||||
developers {
|
||||
developer {
|
||||
name 'Luck'
|
||||
email 'git@lucko.me'
|
||||
url 'https://github.com/lucko'
|
||||
}
|
||||
}
|
||||
|
||||
scm {
|
||||
connection 'scm:git:https://github.com/lucko/LuckPerms.git'
|
||||
developerConnection 'scm:git:git@github.com:lucko/LuckPerms.git'
|
||||
url 'https://github.com/lucko/LuckPerms'
|
||||
}
|
||||
|
||||
ciManagement {
|
||||
system 'Jenkins'
|
||||
url 'https://ci.lucko.me/job/LuckPerms'
|
||||
}
|
||||
|
||||
issueManagement {
|
||||
system 'GitHub'
|
||||
url 'https://github.com/lucko/LuckPerms/issues'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>luckperms</artifactId>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<version>2.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>luckperms-api</artifactId>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<!-- guava -->
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>19.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,41 +27,62 @@ package me.lucko.luckperms;
|
||||
|
||||
import me.lucko.luckperms.api.LuckPermsApi;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Static access to LuckPerms
|
||||
* Provides static access to the {@link LuckPermsApi}.
|
||||
*
|
||||
* <p>Ideally, the ServiceManager for the platform should be used to obtain an instance,
|
||||
* however, this provider can be used if you need static access.</p>
|
||||
*/
|
||||
public final class LuckPerms {
|
||||
private static LuckPermsApi api = null;
|
||||
private static LuckPermsApi instance = null;
|
||||
|
||||
/**
|
||||
* Gets an instance of {@link LuckPermsApi}
|
||||
* Gets an instance of the {@link LuckPermsApi},
|
||||
* throwing {@link IllegalStateException} if an instance is not yet loaded.
|
||||
*
|
||||
* <p>Will never return null.</p>
|
||||
*
|
||||
* @return an api instance
|
||||
* @throws IllegalStateException if the api is not loaded
|
||||
*/
|
||||
public static LuckPermsApi getApi() {
|
||||
if (api == null) {
|
||||
public static @NonNull LuckPermsApi getApi() {
|
||||
if (instance == null) {
|
||||
throw new IllegalStateException("API is not loaded.");
|
||||
}
|
||||
return api;
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an instance of {@link LuckPermsApi} safely. Unlike {@link LuckPerms#getApi}, this method will not throw an
|
||||
* {@link IllegalStateException} if the api is not loaded, rather return an empty {@link Optional}.
|
||||
* Gets an instance of {@link LuckPermsApi}, if it is loaded.
|
||||
*
|
||||
* <p>Unlike {@link LuckPerms#getApi}, this method will not throw an
|
||||
* {@link IllegalStateException} if an instance is not yet loaded, rather return
|
||||
* an empty {@link Optional}.
|
||||
*
|
||||
* @return an optional api instance
|
||||
*/
|
||||
public static Optional<LuckPermsApi> getApiSafe() {
|
||||
return Optional.ofNullable(api);
|
||||
public static @NonNull Optional<LuckPermsApi> getApiSafe() {
|
||||
return Optional.ofNullable(instance);
|
||||
}
|
||||
|
||||
static void registerProvider(LuckPermsApi luckPermsApi) {
|
||||
api = luckPermsApi;
|
||||
/**
|
||||
* Registers an instance of the {@link LuckPermsApi} with this provider.
|
||||
*
|
||||
* @param instance the instance
|
||||
*/
|
||||
static void registerProvider(LuckPermsApi instance) {
|
||||
LuckPerms.instance = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the current instance from this provider.
|
||||
*/
|
||||
static void unregisterProvider() {
|
||||
api = null;
|
||||
LuckPerms.instance = null;
|
||||
}
|
||||
|
||||
private LuckPerms() {
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* Represents the object responsible for handling action logging.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface ActionLogger {
|
||||
|
||||
/**
|
||||
* Returns a new {@link LogEntry.Builder} instance
|
||||
*
|
||||
* @return a new builder
|
||||
*/
|
||||
LogEntry.@NonNull Builder newEntryBuilder();
|
||||
|
||||
/**
|
||||
* Gets a {@link Log} instance from the plugin storage.
|
||||
*
|
||||
* @return a log instance
|
||||
* @see Storage#getLog()
|
||||
*/
|
||||
@NonNull CompletableFuture<Log> getLog();
|
||||
|
||||
/**
|
||||
* Submits a log entry to the plugin to be handled.
|
||||
*
|
||||
* <p>This method submits the log to the storage provider and broadcasts
|
||||
* it.</p>
|
||||
*
|
||||
* <p>It is therefore roughly equivalent to calling
|
||||
* {@link #submitToStorage(LogEntry)} and {@link #broadcastAction(LogEntry)},
|
||||
* however, using this method is preferred to making the calls individually.</p>
|
||||
*
|
||||
* <p>If you want to submit a log entry but don't know which method to pick,
|
||||
* use this one.</p>
|
||||
*
|
||||
* @param entry the entry to submit
|
||||
* @return a future which will complete when the action is done
|
||||
*/
|
||||
@NonNull CompletableFuture<Void> submit(@NonNull LogEntry entry);
|
||||
|
||||
/**
|
||||
* Submits a log entry to the plugins storage handler.
|
||||
*
|
||||
* <p>Performs the same action as {@link Storage#logAction(LogEntry)}.</p>
|
||||
*
|
||||
* @param entry the entry to submit
|
||||
* @return a future which will complete when the action is done
|
||||
*/
|
||||
@NonNull CompletableFuture<Void> submitToStorage(@NonNull LogEntry entry);
|
||||
|
||||
/**
|
||||
* Submits a log entry to the plugins log broadcasting handler.
|
||||
*
|
||||
* <p>If enabled, this method will also dispatch the log entry via the
|
||||
* plugins {@link MessagingService}.</p>
|
||||
*
|
||||
* @param entry the entry to submit
|
||||
* @return a future which will complete when the action is done
|
||||
*/
|
||||
@NonNull CompletableFuture<Void> broadcastAction(@NonNull LogEntry entry);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Represents a type of chat meta
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public enum ChatMetaType {
|
||||
|
||||
/**
|
||||
* Represents a prefix
|
||||
*/
|
||||
PREFIX("prefix") {
|
||||
@Override
|
||||
public boolean matches(@NonNull Node node) {
|
||||
return Objects.requireNonNull(node, "node").isPrefix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map.@NonNull Entry<Integer, String> getEntry(@NonNull Node node) {
|
||||
return Objects.requireNonNull(node, "node").getPrefix();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Represents a suffix
|
||||
*/
|
||||
SUFFIX("suffix") {
|
||||
@Override
|
||||
public boolean matches(@NonNull Node node) {
|
||||
return Objects.requireNonNull(node, "node").isSuffix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map.@NonNull Entry<Integer, String> getEntry(@NonNull Node node) {
|
||||
return Objects.requireNonNull(node, "node").getSuffix();
|
||||
}
|
||||
};
|
||||
|
||||
private final String str;
|
||||
|
||||
ChatMetaType(String str) {
|
||||
this.str = str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the passed node matches the type
|
||||
*
|
||||
* @param node the node to test
|
||||
* @return true if the node has the same type
|
||||
*/
|
||||
public abstract boolean matches(@NonNull Node node);
|
||||
|
||||
/**
|
||||
* Returns if the passed node should be ignored when searching for meta of this type
|
||||
*
|
||||
* @param node the node to test
|
||||
* @return true if the node does not share the same type
|
||||
*/
|
||||
public boolean shouldIgnore(@NonNull Node node) {
|
||||
return !matches(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the corresponding entry from the given node
|
||||
*
|
||||
* @param node the node to retrieve the entry from
|
||||
* @return the entry
|
||||
* @throws IllegalStateException if the node does not share the same type
|
||||
*/
|
||||
public abstract Map.@NonNull Entry<Integer, String> getEntry(@NonNull Node node);
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a ChatMetaType from the given node.
|
||||
*
|
||||
* @param node the node
|
||||
* @return the parsed chat meta type
|
||||
* @since 3.4
|
||||
*/
|
||||
public static @NonNull Optional<ChatMetaType> ofNode(@NonNull Node node) {
|
||||
if (node.isPrefix()) {
|
||||
return Optional.of(PREFIX);
|
||||
} else if (node.isSuffix()) {
|
||||
return Optional.of(SUFFIX);
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import me.lucko.luckperms.api.context.ContextSet;
|
||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Encapsulates the {@link ContextSet contexts} and {@link LookupSetting settings} for
|
||||
* a permission or meta lookup.
|
||||
*
|
||||
* <p>This class is immutable.</p>
|
||||
*
|
||||
* @since 2.11
|
||||
*/
|
||||
public class Contexts {
|
||||
|
||||
/**
|
||||
* The context key used to denote the subjects server
|
||||
*/
|
||||
public static final String SERVER_KEY = "server";
|
||||
|
||||
/**
|
||||
* The context key used to denote the subjects world
|
||||
*/
|
||||
public static final String WORLD_KEY = "world";
|
||||
|
||||
/**
|
||||
* The default {@link LookupSetting}s as a flag.
|
||||
*/
|
||||
private static final byte DEFAULT_SETTINGS_FLAG = LookupSetting.createFlag(
|
||||
LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER,
|
||||
LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD,
|
||||
LookupSetting.RESOLVE_INHERITANCE,
|
||||
LookupSetting.APPLY_PARENTS_SET_WITHOUT_SERVER,
|
||||
LookupSetting.APPLY_PARENTS_SET_WITHOUT_WORLD
|
||||
);
|
||||
|
||||
/**
|
||||
* A 'global' or default contexts instance.
|
||||
*
|
||||
* <p>Formed of an empty {@link ContextSet} and all inclusion and
|
||||
* inheritance {@link LookupSetting}s applied.</p>
|
||||
*/
|
||||
private static final Contexts GLOBAL = new Contexts(ImmutableContextSet.empty(), DEFAULT_SETTINGS_FLAG);
|
||||
|
||||
/**
|
||||
* Gets the {@link FullySatisfiedContexts} instance.
|
||||
*
|
||||
* @return a context that will satisfy all contextual requirements.
|
||||
*/
|
||||
public static @NonNull Contexts allowAll() {
|
||||
return FullySatisfiedContexts.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a 'global' or default contexts instance.
|
||||
*
|
||||
* <p>Formed of an empty {@link ContextSet} and all inclusion and
|
||||
* inheritance {@link LookupSetting}s applied.</p>
|
||||
*
|
||||
* @return the global contexts
|
||||
* @since 3.3
|
||||
*/
|
||||
public static @NonNull Contexts global() {
|
||||
return GLOBAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Contexts} instance.
|
||||
*
|
||||
* @param contextSet the context set
|
||||
* @param includeNodesSetWithoutServer the value of {@link LookupSetting#INCLUDE_NODES_SET_WITHOUT_SERVER}
|
||||
* @param includeNodesSetWithoutWorld the value of {@link LookupSetting#INCLUDE_NODES_SET_WITHOUT_WORLD}
|
||||
* @param resolveInheritance the value of {@link LookupSetting#RESOLVE_INHERITANCE}
|
||||
* @param applyParentsWithoutServer the value of {@link LookupSetting#APPLY_PARENTS_SET_WITHOUT_SERVER}
|
||||
* @param applyParentsWithoutWorld the value of {@link LookupSetting#APPLY_PARENTS_SET_WITHOUT_WORLD}
|
||||
* @param isOp the value of {@link LookupSetting#IS_OP}
|
||||
* @return a new instance
|
||||
*/
|
||||
public static @NonNull Contexts of(@NonNull ContextSet contextSet, boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) {
|
||||
Objects.requireNonNull(contextSet, "contextSet");
|
||||
byte settingsFlag = LookupSetting.createFlag(
|
||||
includeNodesSetWithoutServer,
|
||||
includeNodesSetWithoutWorld,
|
||||
resolveInheritance,
|
||||
applyParentsWithoutServer,
|
||||
applyParentsWithoutWorld,
|
||||
isOp
|
||||
);
|
||||
if (contextSet.isEmpty() && DEFAULT_SETTINGS_FLAG == settingsFlag) {
|
||||
return GLOBAL;
|
||||
}
|
||||
return new Contexts(contextSet.makeImmutable(), settingsFlag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Contexts} instance.
|
||||
*
|
||||
* @param contextSet the context set
|
||||
* @param settings the settings
|
||||
* @return a new instance
|
||||
*/
|
||||
public static Contexts of(@NonNull ContextSet contextSet, @NonNull Set<LookupSetting> settings) {
|
||||
Objects.requireNonNull(contextSet, "contextSet");
|
||||
Objects.requireNonNull(settings, "settings");
|
||||
|
||||
byte settingsFlag = LookupSetting.createFlag(settings);
|
||||
if (contextSet.isEmpty() && DEFAULT_SETTINGS_FLAG == settingsFlag) {
|
||||
return GLOBAL;
|
||||
}
|
||||
|
||||
return new Contexts(contextSet.makeImmutable(), settingsFlag);
|
||||
}
|
||||
|
||||
/**
|
||||
* The contexts that apply for this lookup
|
||||
*/
|
||||
private final ImmutableContextSet contextSet;
|
||||
|
||||
/**
|
||||
* The settings for this lookup
|
||||
*/
|
||||
private final byte settingsFlag;
|
||||
|
||||
// cache hashcode - this class is immutable, and is used as an index in the permission cache.
|
||||
private final int hashCode;
|
||||
|
||||
/**
|
||||
* Creates a new {@link Contexts} instance.
|
||||
*
|
||||
* @param contextSet the context set
|
||||
* @param includeNodesSetWithoutServer the value of {@link LookupSetting#INCLUDE_NODES_SET_WITHOUT_SERVER}
|
||||
* @param includeNodesSetWithoutWorld the value of {@link LookupSetting#INCLUDE_NODES_SET_WITHOUT_WORLD}
|
||||
* @param resolveInheritance the value of {@link LookupSetting#RESOLVE_INHERITANCE}
|
||||
* @param applyParentsWithoutServer the value of {@link LookupSetting#APPLY_PARENTS_SET_WITHOUT_SERVER}
|
||||
* @param applyParentsWithoutWorld the value of {@link LookupSetting#APPLY_PARENTS_SET_WITHOUT_WORLD}
|
||||
* @param isOp the value of {@link LookupSetting#IS_OP}
|
||||
* @deprecated in favour of {@link #of(ContextSet, boolean, boolean, boolean, boolean, boolean, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Contexts(@NonNull ContextSet contextSet, boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) {
|
||||
this.contextSet = Objects.requireNonNull(contextSet, "contextSet").makeImmutable();
|
||||
this.settingsFlag = LookupSetting.createFlag(
|
||||
includeNodesSetWithoutServer,
|
||||
includeNodesSetWithoutWorld,
|
||||
resolveInheritance,
|
||||
applyParentsWithoutServer,
|
||||
applyParentsWithoutWorld,
|
||||
isOp
|
||||
);
|
||||
this.hashCode = calculateHashCode();
|
||||
}
|
||||
|
||||
protected Contexts(@NonNull ImmutableContextSet contextSet, byte settingsFlag) {
|
||||
this.contextSet = contextSet;
|
||||
this.settingsFlag = settingsFlag;
|
||||
this.hashCode = calculateHashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link ContextSet set of context pairs} for this {@link Contexts} instance.
|
||||
*
|
||||
* @return an immutable context from this instance
|
||||
* @since 2.13
|
||||
*/
|
||||
public @NonNull ContextSet getContexts() {
|
||||
return this.contextSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the set of {@link LookupSetting}s for this {@link Contexts} instance.
|
||||
*
|
||||
* @return the settings
|
||||
* @since 4.2
|
||||
*/
|
||||
public @NonNull Set<LookupSetting> getSettings() {
|
||||
return LookupSetting.createSetFromFlag(this.settingsFlag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of this {@link Contexts} instance, but with the
|
||||
* {@link ContextSet set of context pairs} replaced by the given set.
|
||||
*
|
||||
* @param contextSet the context set
|
||||
* @return a new contexts instance representing the new settings
|
||||
* @since 4.4
|
||||
*/
|
||||
public @NonNull Contexts setContexts(@NonNull ContextSet contextSet) {
|
||||
ImmutableContextSet cs = Objects.requireNonNull(contextSet, "contextSet").makeImmutable();
|
||||
if (this.contextSet.equals(cs)) {
|
||||
return this;
|
||||
}
|
||||
return new Contexts(cs, this.settingsFlag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of this {@link Contexts} instance, but with the
|
||||
* {@link LookupSetting}s replaced by the given settings.
|
||||
*
|
||||
* @param settings the lookup settings
|
||||
* @return a new contexts instance representing the new settings
|
||||
* @since 4.4
|
||||
*/
|
||||
public @NonNull Contexts setSettings(@NonNull Set<LookupSetting> settings) {
|
||||
Objects.requireNonNull(settings, "settings");
|
||||
|
||||
byte settingsFlag = LookupSetting.createFlag(settings);
|
||||
if (this.settingsFlag == settingsFlag) {
|
||||
return this;
|
||||
}
|
||||
if (DEFAULT_SETTINGS_FLAG == settingsFlag && this.contextSet.isEmpty()) {
|
||||
return GLOBAL;
|
||||
}
|
||||
|
||||
return new Contexts(this.contextSet, settingsFlag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if the given {@link LookupSetting} is set.
|
||||
*
|
||||
* @param setting the setting
|
||||
* @return the value
|
||||
* @since 4.2
|
||||
*/
|
||||
public boolean hasSetting(@NonNull LookupSetting setting) {
|
||||
return LookupSetting.isSet(this.settingsFlag, setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of {@link LookupSetting#IS_OP}.
|
||||
*
|
||||
* @return the value
|
||||
* @see LookupSetting#IS_OP
|
||||
* @deprecated in favour of {@link #hasSetting(LookupSetting)}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isOp() {
|
||||
return hasSetting(LookupSetting.IS_OP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of {@link LookupSetting#INCLUDE_NODES_SET_WITHOUT_SERVER}.
|
||||
*
|
||||
* @return the value
|
||||
* @see LookupSetting#INCLUDE_NODES_SET_WITHOUT_SERVER
|
||||
* @deprecated in favour of {@link #hasSetting(LookupSetting)}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isIncludeGlobal() {
|
||||
return hasSetting(LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of {@link LookupSetting#INCLUDE_NODES_SET_WITHOUT_WORLD}.
|
||||
*
|
||||
* @return the value
|
||||
* @see LookupSetting#INCLUDE_NODES_SET_WITHOUT_WORLD
|
||||
* @deprecated in favour of {@link #hasSetting(LookupSetting)}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isIncludeGlobalWorld() {
|
||||
return hasSetting(LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of {@link LookupSetting#RESOLVE_INHERITANCE}.
|
||||
*
|
||||
* @return the value
|
||||
* @see LookupSetting#RESOLVE_INHERITANCE
|
||||
* @deprecated in favour of {@link #hasSetting(LookupSetting)}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isApplyGroups() {
|
||||
return hasSetting(LookupSetting.RESOLVE_INHERITANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of {@link LookupSetting#APPLY_PARENTS_SET_WITHOUT_SERVER}.
|
||||
*
|
||||
* @return the value
|
||||
* @see LookupSetting#APPLY_PARENTS_SET_WITHOUT_SERVER
|
||||
* @deprecated in favour of {@link #hasSetting(LookupSetting)}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isApplyGlobalGroups() {
|
||||
return hasSetting(LookupSetting.APPLY_PARENTS_SET_WITHOUT_SERVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of {@link LookupSetting#APPLY_PARENTS_SET_WITHOUT_WORLD}.
|
||||
*
|
||||
* @return the value
|
||||
* @see LookupSetting#APPLY_PARENTS_SET_WITHOUT_WORLD
|
||||
* @deprecated in favour of {@link #hasSetting(LookupSetting)}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isApplyGlobalWorldGroups() {
|
||||
return hasSetting(LookupSetting.APPLY_PARENTS_SET_WITHOUT_WORLD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String toString() {
|
||||
return "Contexts(contextSet=" + this.contextSet + ", settings=" + LookupSetting.createSetFromFlag(this.settingsFlag) + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) return true;
|
||||
if (o == allowAll()) return false;
|
||||
if (!(o instanceof Contexts)) return false;
|
||||
final Contexts that = (Contexts) o;
|
||||
return this.contextSet.equals(that.contextSet) && this.settingsFlag == that.settingsFlag;
|
||||
}
|
||||
|
||||
private int calculateHashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = 1;
|
||||
result = result * PRIME + this.contextSet.hashCode();
|
||||
result = result * PRIME + this.settingsFlag;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.hashCode;
|
||||
}
|
||||
|
||||
}
|
||||
+35
-27
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,38 +23,43 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.tracks;
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import me.lucko.luckperms.utils.AbstractManager;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TrackManager extends AbstractManager<String, Track> {
|
||||
/**
|
||||
* Represents the result of a data mutation call on a LuckPerms object.
|
||||
*
|
||||
* <p>Usually as the result to a call on a {@link PermissionHolder} or {@link Track}.</p>
|
||||
*/
|
||||
public enum DataMutateResult implements MutateResult {
|
||||
|
||||
/**
|
||||
* Returns a set of tracks that contain at least one of the groups from the Set provided
|
||||
* @param group the group to filter by
|
||||
* @return a set of tracks that the groups could be a member of
|
||||
* Indicates the mutation was a success
|
||||
*/
|
||||
public Set<Track> getApplicableTracks(String group) {
|
||||
return getAll().values().stream()
|
||||
.filter(t -> t.containsGroup(group))
|
||||
.collect(Collectors.toSet());
|
||||
SUCCESS(true),
|
||||
|
||||
/**
|
||||
* Indicates the mutation failed because the subject of the action already has something
|
||||
*/
|
||||
ALREADY_HAS(false),
|
||||
|
||||
/**
|
||||
* Indicates the mutation failed because the subject of the action lacks something
|
||||
*/
|
||||
LACKS(false),
|
||||
|
||||
/**
|
||||
* Indicates the mutation failed
|
||||
*/
|
||||
FAIL(false);
|
||||
|
||||
private final boolean success;
|
||||
|
||||
DataMutateResult(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(Track from, Track to) {
|
||||
to.setGroups(from.getGroups());
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a new track object
|
||||
* @param name The name of the track
|
||||
* @return a new {@link Track} object
|
||||
*/
|
||||
@Override
|
||||
public Track make(String name) {
|
||||
return new Track(name);
|
||||
public boolean wasSuccess() {
|
||||
return this.success;
|
||||
}
|
||||
}
|
||||
@@ -1,308 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import me.lucko.luckperms.api.data.Callback;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Interface for the internal Datastore instance
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public interface Datastore {
|
||||
|
||||
String getName();
|
||||
boolean isAcceptingLogins();
|
||||
|
||||
/**
|
||||
* Gets the {@link Sync} interface.
|
||||
*
|
||||
* All operations through this interface are called immediately and in the same thread as they are called.
|
||||
* Datastore operations are thread blocking, and Sync operations should not be called on the main server thread.
|
||||
* @return the sync interface
|
||||
*/
|
||||
Sync sync();
|
||||
|
||||
/**
|
||||
* Gets the {@link Async} interface.
|
||||
*
|
||||
* All operations through this interface are called in a new, separate asynchronous thread.
|
||||
* When the operation is complete, the provided callback method is called, in applicable, in the main server thread.
|
||||
* @return the async interface
|
||||
*/
|
||||
Async async();
|
||||
|
||||
/**
|
||||
* Gets the {@link Future} interface.
|
||||
*
|
||||
* All operations through this interface are called in a new, separate asynchronous thread, similar to {@link Async}.
|
||||
* The only difference is that instead of providing a callback, a {@link java.util.concurrent.Future} is returned.
|
||||
* See the Oracle JavaDocs for usage of the Future class.
|
||||
* @return the future interface
|
||||
*/
|
||||
Future future();
|
||||
|
||||
/**
|
||||
* All operations through this interface are called immediately and in the same thread as they are called.
|
||||
* Datastore operations are thread blocking, and Sync operations should not be called on the main server thread.
|
||||
*/
|
||||
interface Sync {
|
||||
|
||||
/**
|
||||
* Saves an action to the datastore
|
||||
* @param entry the log entry to be saved
|
||||
* @return true if the operation completed successfully.
|
||||
* @throws NullPointerException if entry is null
|
||||
*/
|
||||
boolean logAction(LogEntry entry);
|
||||
|
||||
/**
|
||||
* Loads and returns the log from the datastore
|
||||
* @return a log instance, could be null
|
||||
*/
|
||||
Log getLog();
|
||||
|
||||
/**
|
||||
* Either loads or creates a user object, and loads it into the plugins internal storage
|
||||
* @param uuid the uuid of the user
|
||||
* @param username the users username. (if you want to specify <code>null</code> here, just input "null" as a string.)
|
||||
* @return true if the operation completed successfully.
|
||||
* @throws NullPointerException if uuid or username is null
|
||||
* @throws IllegalArgumentException if either of the parameters are invalid
|
||||
* @deprecated functionality of this method is taken on by {@link #loadUser(UUID, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
boolean loadOrCreateUser(UUID uuid, String username);
|
||||
|
||||
/**
|
||||
* Loads a user from the datastore into the plugins internal storage.
|
||||
* @param uuid the uuid of the user to load
|
||||
* @return true if the user exists, and was loaded correctly.
|
||||
* @throws NullPointerException if uuid is null
|
||||
* @deprecated replaced by {@link #loadUser(UUID, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
boolean loadUser(UUID uuid);
|
||||
|
||||
/**
|
||||
* Loads a user's data into the plugins internal storage.
|
||||
* @param uuid the uuid of the user to load
|
||||
* @param username the users username. (if you want to specify <code>null</code> here, just input "null" as a string.)
|
||||
* @return if the operation was performed successfully
|
||||
* @throws NullPointerException if uuid or username is null
|
||||
* @since 2.6
|
||||
*/
|
||||
boolean loadUser(UUID uuid, String username);
|
||||
|
||||
/**
|
||||
* Saves a user object into the datastore. You should call this after you make any changes to a user.
|
||||
* @param user the user to save
|
||||
* @return true if the operation completed successfully.
|
||||
* @throws NullPointerException if user is null
|
||||
* @throws IllegalStateException if the user instance was not obtained from LuckPerms.
|
||||
*/
|
||||
boolean saveUser(User user);
|
||||
|
||||
/**
|
||||
* Removes users from the datastore who are "default". This is called every time the plugin loads.
|
||||
* @return true if the operation completed successfully
|
||||
* @since 2.6
|
||||
*/
|
||||
boolean cleanupUsers();
|
||||
|
||||
/**
|
||||
* Gets a set all user's UUIDs who are "unique", and aren't just a member of the "default" group.
|
||||
* @return a set of uuids, or null if the operation failed.
|
||||
* @since 2.6
|
||||
*/
|
||||
Set<UUID> getUniqueUsers();
|
||||
|
||||
/**
|
||||
* Creates and loads a group into the plugins internal storage
|
||||
* @param name the name of the group
|
||||
* @return true if the operation completed successfully
|
||||
* @throws NullPointerException if name is null
|
||||
* @throws IllegalArgumentException if the name is invalid
|
||||
*/
|
||||
boolean createAndLoadGroup(String name);
|
||||
|
||||
/**
|
||||
* Loads a group into the plugins internal storage.
|
||||
* @param name the name of the group
|
||||
* @return true if the operation completed successfully
|
||||
* @throws NullPointerException if name is null
|
||||
* @throws IllegalArgumentException if the name is invalid
|
||||
*/
|
||||
boolean loadGroup(String name);
|
||||
|
||||
/**
|
||||
* Loads all groups from the datastore into the plugins internal storage
|
||||
* @return true if the operation completed successfully.
|
||||
*/
|
||||
boolean loadAllGroups();
|
||||
|
||||
/**
|
||||
* Saves a group back to the datastore. You should call this after you make any changes to a group.
|
||||
* @param group the group to save
|
||||
* @return true if the operation completed successfully.
|
||||
* @throws NullPointerException if group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
*/
|
||||
boolean saveGroup(Group group);
|
||||
|
||||
/**
|
||||
* Permanently deletes a group from the datastore
|
||||
* @param group the group to delete
|
||||
* @return true if the operation completed successfully.
|
||||
* @throws NullPointerException if group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
*/
|
||||
boolean deleteGroup(Group group);
|
||||
|
||||
/**
|
||||
* Creates and loads a track into the plugins internal storage
|
||||
* @param name the name of the track
|
||||
* @return true if the operation completed successfully
|
||||
* @throws NullPointerException if name is null
|
||||
* @throws IllegalArgumentException if the name is invalid
|
||||
*/
|
||||
boolean createAndLoadTrack(String name);
|
||||
|
||||
/**
|
||||
* Loads a track into the plugins internal storage.
|
||||
* @param name the name of the track
|
||||
* @return true if the operation completed successfully
|
||||
* @throws NullPointerException if name is null
|
||||
* @throws IllegalArgumentException if the name is invalid
|
||||
*/
|
||||
boolean loadTrack(String name);
|
||||
|
||||
/**
|
||||
* Loads all tracks from the datastore into the plugins internal storage
|
||||
* @return true if the operation completed successfully.
|
||||
*/
|
||||
boolean loadAllTracks();
|
||||
|
||||
/**
|
||||
* Saves a track back to the datastore. You should call this after you make any changes to a track.
|
||||
* @param track the track to save
|
||||
* @return true if the operation completed successfully.
|
||||
* @throws NullPointerException if track is null
|
||||
* @throws IllegalStateException if the track instance was not obtained from LuckPerms.
|
||||
*/
|
||||
boolean saveTrack(Track track);
|
||||
|
||||
/**
|
||||
* Permanently deletes a track from the datastore
|
||||
* @param track the track to delete
|
||||
* @return true if the operation completed successfully.
|
||||
* @throws NullPointerException if track is null
|
||||
* @throws IllegalStateException if the track instance was not obtained from LuckPerms.
|
||||
*/
|
||||
boolean deleteTrack(Track track);
|
||||
|
||||
/**
|
||||
* Saves UUID caching data to the datastore
|
||||
* @param username the users username
|
||||
* @param uuid the users mojang unique id
|
||||
* @return true if the operation completed successfully.
|
||||
* @throws NullPointerException if either parameters are null
|
||||
* @throws IllegalArgumentException if the username is invalid
|
||||
*/
|
||||
boolean saveUUIDData(String username, UUID uuid);
|
||||
|
||||
/**
|
||||
* Gets a UUID from a username
|
||||
* @param username the corresponding username
|
||||
* @return a uuid object, could be null
|
||||
* @throws NullPointerException if either parameters are null
|
||||
* @throws IllegalArgumentException if the username is invalid
|
||||
*/
|
||||
UUID getUUID(String username);
|
||||
}
|
||||
|
||||
/**
|
||||
* All operations through this interface are called in a new, separate asynchronous thread.
|
||||
* When the operation is complete, the provided callback method is called, in applicable, in the main server thread.
|
||||
*
|
||||
* See {@link Sync} for method documentation.
|
||||
*/
|
||||
interface Async {
|
||||
void logAction(LogEntry entry, Callback<Boolean> callback);
|
||||
void getLog(Callback<Log> callback);
|
||||
@Deprecated
|
||||
void loadOrCreateUser(UUID uuid, String username, Callback<Boolean> callback);
|
||||
@Deprecated
|
||||
void loadUser(UUID uuid, Callback<Boolean> callback);
|
||||
void loadUser(UUID uuid, String username, Callback<Boolean> callback);
|
||||
void saveUser(User user, Callback<Boolean> callback);
|
||||
void cleanupUsers(Callback<Boolean> callback);
|
||||
void getUniqueUsers(Callback<Set<UUID>> callback);
|
||||
void createAndLoadGroup(String name, Callback<Boolean> callback);
|
||||
void loadGroup(String name, Callback<Boolean> callback);
|
||||
void loadAllGroups(Callback<Boolean> callback);
|
||||
void saveGroup(Group group, Callback<Boolean> callback);
|
||||
void deleteGroup(Group group, Callback<Boolean> callback);
|
||||
void createAndLoadTrack(String name, Callback<Boolean> callback);
|
||||
void loadTrack(String name, Callback<Boolean> callback);
|
||||
void loadAllTracks(Callback<Boolean> callback);
|
||||
void saveTrack(Track track, Callback<Boolean> callback);
|
||||
void deleteTrack(Track track, Callback<Boolean> callback);
|
||||
void saveUUIDData(String username, UUID uuid, Callback<Boolean> callback);
|
||||
void getUUID(String username, Callback<UUID> callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* All operations through this interface are called in a new, separate asynchronous thread, similar to {@link Async}.
|
||||
* The only difference is that instead of providing a callback, a {@link java.util.concurrent.Future} is returned.
|
||||
* See the Oracle JavaDocs for usage of the Future class.
|
||||
*
|
||||
* See {@link Sync} for method documentation.
|
||||
*/
|
||||
interface Future {
|
||||
java.util.concurrent.Future<Boolean> logAction(LogEntry entry);
|
||||
java.util.concurrent.Future<Log> getLog();
|
||||
@Deprecated
|
||||
java.util.concurrent.Future<Boolean> loadOrCreateUser(UUID uuid, String username);
|
||||
@Deprecated
|
||||
java.util.concurrent.Future<Boolean> loadUser(UUID uuid);
|
||||
java.util.concurrent.Future<Boolean> loadUser(UUID uuid, String username);
|
||||
java.util.concurrent.Future<Boolean> saveUser(User user);
|
||||
java.util.concurrent.Future<Boolean> cleanupUsers();
|
||||
java.util.concurrent.Future<Set<UUID>> getUniqueUsers();
|
||||
java.util.concurrent.Future<Boolean> createAndLoadGroup(String name);
|
||||
java.util.concurrent.Future<Boolean> loadGroup(String name);
|
||||
java.util.concurrent.Future<Boolean> loadAllGroups();
|
||||
java.util.concurrent.Future<Boolean> saveGroup(Group group);
|
||||
java.util.concurrent.Future<Boolean> deleteGroup(Group group);
|
||||
java.util.concurrent.Future<Boolean> createAndLoadTrack(String name);
|
||||
java.util.concurrent.Future<Boolean> loadTrack(String name);
|
||||
java.util.concurrent.Future<Boolean> loadAllTracks();
|
||||
java.util.concurrent.Future<Boolean> saveTrack(Track track);
|
||||
java.util.concurrent.Future<Boolean> deleteTrack(Track track);
|
||||
java.util.concurrent.Future<Boolean> saveUUIDData(String username, UUID uuid);
|
||||
java.util.concurrent.Future<UUID> getUUID(String username);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Encapsulates the result of {@link User}s demotion along a {@link Track}.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public interface DemotionResult extends MutateResult {
|
||||
|
||||
/**
|
||||
* Gets the status of the result.
|
||||
*
|
||||
* @return the status
|
||||
*/
|
||||
@NonNull Status getStatus();
|
||||
|
||||
@Override
|
||||
default boolean wasSuccess() {
|
||||
return getStatus().wasSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the group the user was demoted from, if applicable.
|
||||
*
|
||||
* <p>Will only be present for results with a {@link #getStatus() status} of
|
||||
* {@link Status#SUCCESS} or {@link Status#REMOVED_FROM_FIRST_GROUP}.</p>
|
||||
*
|
||||
* <p>The value will also be set for results with the {@link Status#MALFORMED_TRACK} status,
|
||||
* with this value marking the group which no longer exists.</p>
|
||||
*
|
||||
* @return the group the user was demoted from.
|
||||
*/
|
||||
@NonNull Optional<String> getGroupFrom();
|
||||
|
||||
/**
|
||||
* Gets the name of the group the user was demoted from, if applicable.
|
||||
*
|
||||
* <p>Will only be present for results with a {@link #getStatus() status} of
|
||||
* {@link Status#SUCCESS}.</p>
|
||||
*
|
||||
* @return the group the user was demoted to.
|
||||
*/
|
||||
@NonNull Optional<String> getGroupTo();
|
||||
|
||||
/**
|
||||
* The result status
|
||||
*/
|
||||
enum Status implements MutateResult {
|
||||
|
||||
/**
|
||||
* Indicates that the user was demoted normally.
|
||||
*/
|
||||
SUCCESS(true),
|
||||
|
||||
/**
|
||||
* Indicates that the user was removed from the first group in the track.
|
||||
*
|
||||
* <p>This usually occurs when the user is currently on the first group, and was demoted
|
||||
* "over the start" of the track.</p>
|
||||
*/
|
||||
REMOVED_FROM_FIRST_GROUP(true),
|
||||
|
||||
/**
|
||||
* Indicates that the previous group in the track no longer exists.
|
||||
*/
|
||||
MALFORMED_TRACK(false),
|
||||
|
||||
/**
|
||||
* Indicates that the user isn't a member of any of the groups on this track.
|
||||
*/
|
||||
NOT_ON_TRACK(false),
|
||||
|
||||
/**
|
||||
* Indicates that the implementation was unable to determine the users current position on
|
||||
* this track.
|
||||
*
|
||||
* <p>This usually occurs when the user is on more than one group on the track.</p>
|
||||
*/
|
||||
AMBIGUOUS_CALL(false),
|
||||
|
||||
/**
|
||||
* An undefined failure occurred.
|
||||
*/
|
||||
UNDEFINED_FAILURE(false);
|
||||
|
||||
private final boolean success;
|
||||
|
||||
Status(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wasSuccess() {
|
||||
return this.success;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents an entity on the server.
|
||||
*
|
||||
* <p>This does not relate directly to a "Minecraft Entity". The closest
|
||||
* comparison is to a "CommandSender" or "CommandSource" in Bukkit/Sponge.</p>
|
||||
*
|
||||
* <p>The various types of {@link Entity} are detailed in {@link Type}.</p>
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface Entity {
|
||||
|
||||
/**
|
||||
* Gets the unique id of the entity, if it has one.
|
||||
*
|
||||
* <p>For players, this returns their uuid assigned by the server.</p>
|
||||
*
|
||||
* @return the uuid of the object, if available
|
||||
*/
|
||||
@Nullable UUID getUniqueId();
|
||||
|
||||
/**
|
||||
* Gets the name of the object
|
||||
*
|
||||
* @return the object name
|
||||
*/
|
||||
@NonNull String getName();
|
||||
|
||||
/**
|
||||
* Gets the entities type.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
@NonNull Type getType();
|
||||
|
||||
/**
|
||||
* The different types of {@link Entity}
|
||||
*/
|
||||
enum Type {
|
||||
|
||||
/**
|
||||
* Represents a player connected to the server
|
||||
*/
|
||||
PLAYER,
|
||||
|
||||
/**
|
||||
* Represents the server console
|
||||
*/
|
||||
CONSOLE
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import me.lucko.luckperms.api.caching.CachedData;
|
||||
import me.lucko.luckperms.api.caching.MetaContexts;
|
||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* A special instance of {@link Contexts}, which when passed to:
|
||||
*
|
||||
* <p></p>
|
||||
* <ul>
|
||||
* <li>{@link CachedData#getPermissionData(Contexts)}</li>
|
||||
* <li>{@link CachedData#getMetaData(Contexts)}</li>
|
||||
* <li>{@link CachedData#getMetaData(MetaContexts)}</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>... will always satisfy all contextual requirements.</p>
|
||||
*
|
||||
* <p>This effectively allows you to do lookups which ignore context.</p>
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
public final class FullySatisfiedContexts extends Contexts {
|
||||
|
||||
// singleton
|
||||
private static final FullySatisfiedContexts INSTANCE = new FullySatisfiedContexts();
|
||||
|
||||
public static @NonNull Contexts getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private FullySatisfiedContexts() {
|
||||
super(ImmutableContextSet.empty(), LookupSetting.createFlag(Contexts.global().getSettings()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String toString() {
|
||||
return "FullySatisfiedContexts()";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
// this class is a singleton, so we can use object comparison to check equality.
|
||||
return o == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
// just use the system hashcode - we need to override the hashcode impl in super
|
||||
return System.identityHashCode(this);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,216 +25,66 @@
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import me.lucko.luckperms.api.caching.GroupData;
|
||||
import me.lucko.luckperms.api.context.ContextSet;
|
||||
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.OptionalInt;
|
||||
|
||||
/**
|
||||
* Interface for internal Group instances
|
||||
* An inheritable holder of permission data.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public interface Group extends PermissionHolder {
|
||||
|
||||
/**
|
||||
* Get the name of the group
|
||||
*
|
||||
* @return the name of the group
|
||||
*/
|
||||
String getName();
|
||||
@NonNull String getName();
|
||||
|
||||
/**
|
||||
* Check to see if a group inherits a group
|
||||
* @param group The group to check membership of
|
||||
* @return true if the group inherits the other group
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* Gets the groups "display name", if it has one that differs from it's actual name.
|
||||
*
|
||||
* <p>The lookup is made using the current servers active context.</p>
|
||||
*
|
||||
* <p>Will return <code>null</code> if the groups display name is equal to it's
|
||||
* {@link #getName() actual name}.</p>
|
||||
*
|
||||
* @return the display name
|
||||
* @since 4.3
|
||||
*/
|
||||
boolean inheritsGroup(Group group);
|
||||
@Nullable String getDisplayName();
|
||||
|
||||
/**
|
||||
* Check to see if the group inherits a group on a specific server
|
||||
* @param group The group to check membership of
|
||||
* @param server The server to check on
|
||||
* @return true if the group inherits the group on the server
|
||||
* @throws NullPointerException if the group or server is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the server is invalid
|
||||
* Gets the groups "display name", if it has one that differs from it's actual name.
|
||||
*
|
||||
* <p>Will return <code>null</code> if the groups display name is equal to it's
|
||||
* {@link #getName() actual name}.</p>
|
||||
*
|
||||
* @param contextSet the contexts to lookup in
|
||||
* @return the display name
|
||||
* @since 4.3
|
||||
*/
|
||||
boolean inheritsGroup(Group group, String server);
|
||||
@Nullable String getDisplayName(@NonNull ContextSet contextSet);
|
||||
|
||||
/**
|
||||
* Check to see if the group inherits a group on a specific server and world
|
||||
* @param group The group to check membership of
|
||||
* @param server The server to check on
|
||||
* @param world The world to check on
|
||||
* @return true if the group inherits the group on the server and world
|
||||
* @throws NullPointerException if the group, server or world is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the server or world is invalid
|
||||
* Gets the weight of this group, if present.
|
||||
*
|
||||
* @return the group weight
|
||||
* @since 2.17
|
||||
*/
|
||||
boolean inheritsGroup(Group group, String server, String world);
|
||||
@NonNull OptionalInt getWeight();
|
||||
|
||||
/**
|
||||
* Make this group inherit another group
|
||||
* @param group the group to be inherited
|
||||
* @throws ObjectAlreadyHasException if the group already inherits the group
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* Gets the groups's {@link GroupData} cache.
|
||||
*
|
||||
* @return the groups cached data.
|
||||
* @since 4.0
|
||||
*/
|
||||
void setInheritGroup(Group group) throws ObjectAlreadyHasException;
|
||||
@Override
|
||||
@NonNull GroupData getCachedData();
|
||||
|
||||
/**
|
||||
* Make this group inherit another group on a specific server
|
||||
* @param group the group to be inherited
|
||||
* @param server The server to inherit the group on
|
||||
* @throws ObjectAlreadyHasException if the group already inherits the group on that server
|
||||
* @throws NullPointerException if the group or server is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the server is invalid
|
||||
*/
|
||||
void setInheritGroup(Group group, String server) throws ObjectAlreadyHasException;
|
||||
|
||||
/**
|
||||
* Make this group inherit another group on a specific server and world
|
||||
* @param group the group to be inherited
|
||||
* @param server The server to inherit the group on
|
||||
* @param world The world to inherit the group on
|
||||
* @throws ObjectAlreadyHasException if the group already inherits the group on that server and world
|
||||
* @throws NullPointerException if the group, server or world is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the server or world is invalid
|
||||
*/
|
||||
void setInheritGroup(Group group, String server, String world) throws ObjectAlreadyHasException;
|
||||
|
||||
/**
|
||||
* Make this group inherit another group temporarily
|
||||
* @param group the group to be inherited
|
||||
* @param expireAt the unix time when the group should expire
|
||||
* @throws ObjectAlreadyHasException if the group already inherits the group temporarily
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the expiry time is in the past
|
||||
*/
|
||||
void setInheritGroup(Group group, long expireAt) throws ObjectAlreadyHasException;
|
||||
|
||||
/**
|
||||
* Make this group inherit another group on a specific server temporarily
|
||||
* @param group the group to be inherited
|
||||
* @param server The server inherit add the group on
|
||||
* @param expireAt when the group should expire
|
||||
* @throws ObjectAlreadyHasException if the group already inherits the group on that server temporarily
|
||||
* @throws NullPointerException if the group or server is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the expiry time is in the past or the server is invalid
|
||||
*/
|
||||
void setInheritGroup(Group group, String server, long expireAt) throws ObjectAlreadyHasException;
|
||||
|
||||
/**
|
||||
* Make this group inherit another group on a specific server and world temporarily
|
||||
* @param group the group to be inherited
|
||||
* @param server The server to inherit the group on
|
||||
* @param world The world to inherit the group on
|
||||
* @param expireAt when the group should expire
|
||||
* @throws ObjectAlreadyHasException if the group already inherits the group on that server and world temporarily
|
||||
* @throws NullPointerException if the group, server or world is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the expiry time is in the past or the server/world is invalid
|
||||
*/
|
||||
void setInheritGroup(Group group, String server, String world, long expireAt) throws ObjectAlreadyHasException;
|
||||
|
||||
/**
|
||||
* Remove a previously set inheritance rule
|
||||
* @param group the group to uninherit
|
||||
* @throws ObjectLacksException if the group does not already inherit the group
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
*/
|
||||
void unsetInheritGroup(Group group) throws ObjectLacksException;
|
||||
|
||||
/**
|
||||
* Remove a previously set inheritance rule
|
||||
* @param group the group to uninherit
|
||||
* @param temporary if the group being removed is temporary
|
||||
* @throws ObjectLacksException if the group does not already inherit the group
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
*/
|
||||
void unsetInheritGroup(Group group, boolean temporary) throws ObjectLacksException;
|
||||
|
||||
/**
|
||||
* Remove a previously set inheritance rule on a specific server
|
||||
* @param group the group to uninherit
|
||||
* @param server The server to remove the group on
|
||||
* @throws ObjectLacksException if the group does not already inherit the group on that server
|
||||
* @throws NullPointerException if the group or server is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the server is invalid
|
||||
*/
|
||||
void unsetInheritGroup(Group group, String server) throws ObjectLacksException;
|
||||
|
||||
/**
|
||||
* Remove a previously set inheritance rule on a specific server and world
|
||||
* @param group the group to uninherit
|
||||
* @param server The server to remove the group on
|
||||
* @param world The world to remove the group on
|
||||
* @throws ObjectLacksException if the group does not already inherit the group
|
||||
* @throws NullPointerException if the group, server or world is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the server or world is invalid
|
||||
*/
|
||||
void unsetInheritGroup(Group group, String server, String world) throws ObjectLacksException;
|
||||
|
||||
/**
|
||||
* Remove a previously set inheritance rule on a specific server
|
||||
* @param group the group to uninherit
|
||||
* @param server The server to remove the group on
|
||||
* @param temporary if the group being removed is temporary
|
||||
* @throws ObjectLacksException if the group does not already inherit the group
|
||||
* @throws NullPointerException if the group or server is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the expiry time is in the past or the server is invalid
|
||||
*/
|
||||
void unsetInheritGroup(Group group, String server, boolean temporary) throws ObjectLacksException;
|
||||
|
||||
/**
|
||||
* Remove a previously set inheritance rule on a specific server and world
|
||||
* @param group the group to uninherit
|
||||
* @param server The server to remove the group on
|
||||
* @param world The world to remove the group on
|
||||
* @param temporary if the group being removed was set temporarily
|
||||
* @throws ObjectLacksException if the group does not already inherit the group
|
||||
* @throws NullPointerException if the group, server or world is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the expiry time is in the past or the server/world is invalid
|
||||
*/
|
||||
void unsetInheritGroup(Group group, String server, String world, boolean temporary) throws ObjectLacksException;
|
||||
|
||||
/**
|
||||
* Clear all of the groups permission nodes
|
||||
*/
|
||||
void clearNodes();
|
||||
|
||||
/**
|
||||
* Get a {@link List} of all of the groups the group inherits, on all servers
|
||||
* @return a {@link List} of group names
|
||||
*/
|
||||
List<String> getGroupNames();
|
||||
|
||||
/**
|
||||
* Get a {@link List} of the groups the group inherits on a specific server
|
||||
* @param server the server to check
|
||||
* @param world the world to check
|
||||
* @return a {@link List} of group names
|
||||
* @throws NullPointerException if the server or world is null
|
||||
* @throws IllegalArgumentException if the server or world is invalid
|
||||
*/
|
||||
List<String> getLocalGroups(String server, String world);
|
||||
|
||||
/**
|
||||
* Get a {@link List} of the groups the group inherits on a specific server
|
||||
* @param server the server to check
|
||||
* @return a {@link List} of group names
|
||||
* @throws NullPointerException if the server is null
|
||||
* @throws IllegalArgumentException if the server is invalid
|
||||
*/
|
||||
List<String> getLocalGroups(String server);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import me.lucko.luckperms.api.context.ContextSet;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalLong;
|
||||
|
||||
/**
|
||||
* A relationship between a {@link PermissionHolder} and a permission.
|
||||
*
|
||||
* @param <T> the identifier type of the holder
|
||||
* @since 2.17
|
||||
*/
|
||||
public interface HeldPermission<T> {
|
||||
|
||||
/**
|
||||
* Gets the holder of the permission
|
||||
*
|
||||
* @return the holder
|
||||
*/
|
||||
@NonNull T getHolder();
|
||||
|
||||
/**
|
||||
* Gets the permission being held
|
||||
*
|
||||
* @return the permission
|
||||
*/
|
||||
@NonNull String getPermission();
|
||||
|
||||
/**
|
||||
* Gets the value of the permission
|
||||
*
|
||||
* @return the value
|
||||
*/
|
||||
boolean getValue();
|
||||
|
||||
/**
|
||||
* Gets the server where the permission is held
|
||||
*
|
||||
* @return the server
|
||||
*/
|
||||
@NonNull Optional<String> getServer();
|
||||
|
||||
/**
|
||||
* Gets the world where the permission is held
|
||||
*
|
||||
* @return the world
|
||||
*/
|
||||
@NonNull Optional<String> getWorld();
|
||||
|
||||
/**
|
||||
* Gets the time in unix time when the permission will expire
|
||||
*
|
||||
* @return the expiry time
|
||||
*/
|
||||
@NonNull OptionalLong getExpiry();
|
||||
|
||||
/**
|
||||
* Gets the extra context for the permission.
|
||||
*
|
||||
* @return the extra context
|
||||
*/
|
||||
@NonNull ContextSet getContexts();
|
||||
|
||||
/**
|
||||
* Converts this permission into a Node
|
||||
*
|
||||
* @return a Node copy of this permission
|
||||
*/
|
||||
@NonNull Node asNode();
|
||||
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,155 +25,93 @@
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import me.lucko.luckperms.api.data.DatastoreConfiguration;
|
||||
import me.lucko.luckperms.api.data.MySQLConfiguration;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A wrapper interface for the internal LuckPerms configuration, providing read only access.
|
||||
* Wrapper around parts of the LuckPerms configuration file
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public interface LPConfiguration {
|
||||
|
||||
/**
|
||||
* Gets the name of this server
|
||||
*
|
||||
* @return the name of this server
|
||||
*/
|
||||
String getServer();
|
||||
|
||||
/**
|
||||
* @return how often a sync task will run in minutes
|
||||
*/
|
||||
int getSyncTime();
|
||||
|
||||
/**
|
||||
* @return the default group, in a node representation
|
||||
* @deprecated as of 2.6, the default group is always "default"
|
||||
*/
|
||||
@Deprecated
|
||||
String getDefaultGroupNode();
|
||||
|
||||
/**
|
||||
* @return the name of the default group
|
||||
* @deprecated as of 2.6, the default group is always "default"
|
||||
*/
|
||||
@Deprecated
|
||||
String getDefaultGroupName();
|
||||
@NonNull String getServer();
|
||||
|
||||
/**
|
||||
* Gets if the users on this server will have their global permissions applied
|
||||
*
|
||||
* @return if the users on this server will have their global permissions applied
|
||||
*/
|
||||
boolean getIncludeGlobalPerms();
|
||||
|
||||
/**
|
||||
* Gets if the users on this server will have their global world permissions applied
|
||||
*
|
||||
* @return if the users on this server will have their global world permissions applied
|
||||
* @since 2.9
|
||||
*/
|
||||
boolean getIncludeGlobalWorldPerms();
|
||||
|
||||
/**
|
||||
* Gets if the platform is applying global groups
|
||||
*
|
||||
* @return true if the platform is applying global groups
|
||||
* @since 2.9
|
||||
*/
|
||||
boolean getApplyGlobalGroups();
|
||||
|
||||
/**
|
||||
* Gets if the platform is applying global world groups
|
||||
*
|
||||
* @return true if the platform is applying global world groups
|
||||
* @since 2.9
|
||||
*/
|
||||
boolean getApplyGlobalWorldGroups();
|
||||
|
||||
/**
|
||||
* @return the online mode setting in the config
|
||||
*/
|
||||
boolean getOnlineMode();
|
||||
|
||||
/**
|
||||
* @return if LuckPerms is applying wildcard permissions
|
||||
*/
|
||||
boolean getApplyWildcards();
|
||||
|
||||
/**
|
||||
* @return if LuckPerms is resolving and applying regex permissions
|
||||
*/
|
||||
boolean getApplyRegex();
|
||||
|
||||
/**
|
||||
* @return if LuckPerms is expanding shorthand permissions
|
||||
*/
|
||||
boolean getApplyShorthand();
|
||||
|
||||
/**
|
||||
* @return if LuckPerms will send notifications to users when permissions are modified
|
||||
* @since 2.7
|
||||
*/
|
||||
boolean getLogNotify();
|
||||
|
||||
/**
|
||||
* @return true if permission checks are being recorded / debugged
|
||||
* @since 2.9
|
||||
*/
|
||||
boolean getDebugPermissionChecks();
|
||||
|
||||
/**
|
||||
* @return true if the vanilla op system is enabled
|
||||
* @since 2.8
|
||||
*/
|
||||
boolean getEnableOps();
|
||||
|
||||
/**
|
||||
* @return true if opped players are allowed to use LuckPerms commands
|
||||
* @since 2.8
|
||||
*/
|
||||
boolean getCommandsAllowOp();
|
||||
|
||||
/**
|
||||
* @return true if auto op is enabled
|
||||
* @since 2.9
|
||||
*/
|
||||
boolean getAutoOp();
|
||||
|
||||
/**
|
||||
* @return the name of the server used within Vault operations
|
||||
* @since 2.7
|
||||
*/
|
||||
String getVaultServer();
|
||||
|
||||
/**
|
||||
* @return true if global permissions should be considered when retrieving meta or player groups
|
||||
* @since 2.7
|
||||
*/
|
||||
boolean getVaultIncludeGlobal();
|
||||
|
||||
/**
|
||||
* @return the database values set in the configuration
|
||||
* @deprecated use {@link #getDatastoreConfig()}
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
MySQLConfiguration getDatabaseValues();
|
||||
|
||||
/**
|
||||
* @return the values set for data storage in the configuration
|
||||
*/
|
||||
DatastoreConfiguration getDatastoreConfig();
|
||||
|
||||
/**
|
||||
* Gets the storage method string from the configuration
|
||||
*
|
||||
* @return the storage method string from the configuration
|
||||
*/
|
||||
String getStorageMethod();
|
||||
@NonNull String getStorageMethod();
|
||||
|
||||
/**
|
||||
* Gets true if split storage is enabled
|
||||
*
|
||||
* @return true if split storage is enabled
|
||||
* @since 2.7
|
||||
*/
|
||||
boolean getSplitStorage();
|
||||
|
||||
/**
|
||||
* @return a map of split storage options, where the key is the storage section, and the value is the storage method.
|
||||
* For example: key = user, value = json
|
||||
* Gets a map of split storage options
|
||||
*
|
||||
* @return a map of split storage options, where the key is the storage section, and the value is the storage
|
||||
* method. For example: key = user, value = json
|
||||
* @since 2.7
|
||||
*/
|
||||
Map<String, String> getSplitStorageOptions();
|
||||
@NonNull Map<String, String> getSplitStorageOptions();
|
||||
|
||||
@NonNull Unsafe unsafe();
|
||||
|
||||
interface Unsafe {
|
||||
|
||||
/**
|
||||
* Gets an Object from the config.
|
||||
*
|
||||
* <p>This method is nested under {@link Unsafe} because the keys
|
||||
* and return types may change between versions without warning.</p>
|
||||
*
|
||||
* @param key the key, as defined as a field name in
|
||||
* the "ConfigKeys" class.
|
||||
* @return the corresponding object, if one is present
|
||||
* @throws IllegalArgumentException if the key isn't known
|
||||
*/
|
||||
@NonNull Object getObject(String key);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* An extension of {@link Node}, providing information about
|
||||
* where the node originated from.
|
||||
*
|
||||
* @since 2.11
|
||||
*/
|
||||
public interface LocalizedNode extends Node {
|
||||
|
||||
/**
|
||||
* Gets the delegate node.
|
||||
*
|
||||
* <p>Result is never another {@link LocalizedNode} instance.</p>
|
||||
*
|
||||
* @return the node this instance is representing
|
||||
*/
|
||||
@NonNull Node getNode();
|
||||
|
||||
/**
|
||||
* Gets the location where the {@link Node} is inherited from.
|
||||
*
|
||||
* <p>The resultant string is the {@link PermissionHolder#getObjectName() object name} of the
|
||||
* permission holder the node was inherited from.</p>
|
||||
*
|
||||
* <p>If the node was not inherited, the {@link PermissionHolder#getObjectName() object name}
|
||||
* of the permission holder itself (the one that defined the node) will be returned.</p>
|
||||
*
|
||||
* @return where the node was inherited from.
|
||||
*/
|
||||
@NonNull String getLocation();
|
||||
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,140 +25,60 @@
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import java.util.SortedMap;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents the internal LuckPerms log.
|
||||
* All content internally is immutable. You can add to the log using the {@link Datastore}, and then request an updated copy.
|
||||
*
|
||||
* <p>The returned instance provides a copy of the data at the time of retrieval.</p>
|
||||
*
|
||||
* <p>Any changes made to log entries will only apply to this instance of the log.
|
||||
* You can add to the log using the {@link Storage}, and then request an updated copy.</p>
|
||||
*
|
||||
* <p>All methods are thread safe, and return immutable and thread safe collections.</p>
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public interface Log {
|
||||
|
||||
/**
|
||||
* @return a {@link SortedSet} of all of the {@link LogEntry} objects in this {@link Log}
|
||||
* Gets the {@link LogEntry}s that make up this log.
|
||||
*
|
||||
* @return the content
|
||||
*/
|
||||
SortedSet<LogEntry> getContent();
|
||||
|
||||
/**
|
||||
* @return all content in this log
|
||||
*/
|
||||
SortedSet<LogEntry> getRecent();
|
||||
|
||||
/**
|
||||
* Gets the recent content separated by page
|
||||
* @param pageNo the page number
|
||||
* @return the page content
|
||||
*/
|
||||
SortedMap<Integer, LogEntry> getRecent(int pageNo);
|
||||
|
||||
/**
|
||||
* @return the max page number allowed in the {@link #getRecent(int)} method
|
||||
*/
|
||||
int getRecentMaxPages();
|
||||
|
||||
@NonNull SortedSet<LogEntry> getContent();
|
||||
|
||||
/**
|
||||
* Gets the entries in the log performed by the given actor.
|
||||
*
|
||||
* @param actor the uuid of the actor to filter by
|
||||
* @return all content in this log where is actor = uuid
|
||||
* @return the content for the given actor
|
||||
*/
|
||||
SortedSet<LogEntry> getRecent(UUID actor);
|
||||
|
||||
/**
|
||||
* Gets the recent content for the uuid, separated into pages
|
||||
* @param pageNo the page number
|
||||
* @param actor the uuid of the actor to filter by
|
||||
* @return the page content
|
||||
*/
|
||||
SortedMap<Integer, LogEntry> getRecent(int pageNo, UUID actor);
|
||||
|
||||
/**
|
||||
* @param actor the actor to filter by
|
||||
* @return the max page number allowed in the {@link #getRecent(int, UUID)} method
|
||||
*/
|
||||
int getRecentMaxPages(UUID actor);
|
||||
|
||||
@NonNull SortedSet<LogEntry> getContent(@NonNull UUID actor);
|
||||
|
||||
/**
|
||||
* Gets the log content for a given user
|
||||
*
|
||||
* @param uuid the uuid to filter by
|
||||
* @return all content in this log where the user = uuid
|
||||
*/
|
||||
SortedSet<LogEntry> getUserHistory(UUID uuid);
|
||||
@NonNull SortedSet<LogEntry> getUserHistory(@NonNull UUID uuid);
|
||||
|
||||
/**
|
||||
* Gets the user history content, separated by pages
|
||||
* @param pageNo the page number
|
||||
* @param uuid the uuid of the acted user to filter by
|
||||
* @return the page content
|
||||
*/
|
||||
SortedMap<Integer, LogEntry> getUserHistory(int pageNo, UUID uuid);
|
||||
|
||||
/**
|
||||
* @param uuid the uuid to filter by
|
||||
* @return the max page number allowed in the {@link #getUserHistory(int, UUID)} method
|
||||
*/
|
||||
int getUserHistoryMaxPages(UUID uuid);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the log content for a given group
|
||||
*
|
||||
* @param name the name to filter by
|
||||
* @return all content in this log where the group = name
|
||||
*/
|
||||
SortedSet<LogEntry> getGroupHistory(String name);
|
||||
|
||||
/**
|
||||
* Gets the group history content, separated by pages
|
||||
* @param pageNo the page number
|
||||
* @param name the name of the acted group to filter by
|
||||
* @return the page content
|
||||
*/
|
||||
SortedMap<Integer, LogEntry> getGroupHistory(int pageNo, String name);
|
||||
|
||||
/**
|
||||
* @param name the name to filter by
|
||||
* @return the max page number allowed in the {@link #getGroupHistory(int, String)} method
|
||||
*/
|
||||
int getGroupHistoryMaxPages(String name);
|
||||
|
||||
@NonNull SortedSet<LogEntry> getGroupHistory(@NonNull String name);
|
||||
|
||||
/**
|
||||
* Gets the log content for a given track
|
||||
*
|
||||
* @param name the name to filter by
|
||||
* @return all content in this log where the track = name
|
||||
*/
|
||||
SortedSet<LogEntry> getTrackHistory(String name);
|
||||
@NonNull SortedSet<LogEntry> getTrackHistory(@NonNull String name);
|
||||
|
||||
/**
|
||||
* Gets the track history content, separated by pages
|
||||
* @param pageNo the page number
|
||||
* @param name the name of the acted track to filter by
|
||||
* @return the page content
|
||||
*/
|
||||
SortedMap<Integer, LogEntry> getTrackHistory(int pageNo, String name);
|
||||
|
||||
/**
|
||||
* @param name the name to filter by
|
||||
* @return the max page number allowed in the {@link #getTrackHistory(int, String)} method
|
||||
*/
|
||||
int getTrackHistoryMaxPages(String name);
|
||||
|
||||
/**
|
||||
* @param query the query to filter by
|
||||
* @return all content in this log where the content matches query
|
||||
*/
|
||||
SortedSet<LogEntry> getSearch(String query);
|
||||
|
||||
/**
|
||||
* Gets the search content, separated by pages
|
||||
* @param pageNo the page number
|
||||
* @param query the query to filter by
|
||||
* @return the page content
|
||||
*/
|
||||
SortedMap<Integer, LogEntry> getSearch(int pageNo, String query);
|
||||
|
||||
/**
|
||||
* @param query the query to filter by
|
||||
* @return the max page number allowed in the {@link #getSearch(int, String)} method
|
||||
*/
|
||||
int getSearchMaxPages(String query);
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,298 +25,214 @@
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents a single entry in a log
|
||||
* Represents a logged action.
|
||||
*
|
||||
* @see ActionLogger#newEntryBuilder() for creating an instance
|
||||
*/
|
||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||
public class LogEntry implements Comparable<LogEntry> {
|
||||
public static LogEntryBuilder builder() {
|
||||
return new LogEntryBuilder();
|
||||
}
|
||||
public interface LogEntry extends Comparable<LogEntry> {
|
||||
|
||||
private static final String FORMAT = "&8(&e%s&8) [&a%s&8] (&b%s&8) &7--> &f%s";
|
||||
/**
|
||||
* Gets the time in unix seconds when the action occurred.
|
||||
*
|
||||
* @return the timestamp
|
||||
*/
|
||||
long getTimestamp();
|
||||
|
||||
private long timestamp;
|
||||
private UUID actor;
|
||||
private String actorName;
|
||||
private char type;
|
||||
private UUID acted;
|
||||
private String actedName;
|
||||
private String action;
|
||||
/**
|
||||
* Gets the id of the object which performed the action.
|
||||
*
|
||||
* <p>This is the players uuid in most cases.</p>
|
||||
*
|
||||
* @return the actor id
|
||||
*/
|
||||
@NonNull UUID getActor();
|
||||
|
||||
public LogEntry(long timestamp, UUID actor, String actorName, char type, UUID acted, String actedName, String action) {
|
||||
if (actor == null) {
|
||||
throw new NullPointerException("actor");
|
||||
}
|
||||
if (actorName == null) {
|
||||
throw new NullPointerException("actorName");
|
||||
}
|
||||
if (actedName == null) {
|
||||
throw new NullPointerException("actedName");
|
||||
}
|
||||
if (action == null) {
|
||||
throw new NullPointerException("action");
|
||||
}
|
||||
/**
|
||||
* Gets the name describing the actor.
|
||||
*
|
||||
* @return the name of the actor
|
||||
*/
|
||||
@NonNull String getActorName();
|
||||
|
||||
this.timestamp = timestamp;
|
||||
this.actor = actor;
|
||||
this.actorName = actorName;
|
||||
this.type = type;
|
||||
this.acted = acted;
|
||||
this.actedName = actedName;
|
||||
this.action = action;
|
||||
}
|
||||
/**
|
||||
* Gets the type of action.
|
||||
*
|
||||
* @return the action type
|
||||
*/
|
||||
@NonNull Type getType();
|
||||
|
||||
protected LogEntry() {
|
||||
this.timestamp = 0L;
|
||||
this.actor = null;
|
||||
this.actorName = null;
|
||||
this.type = Character.MIN_VALUE;
|
||||
this.acted = null;
|
||||
this.actedName = null;
|
||||
this.action = null;
|
||||
}
|
||||
/**
|
||||
* Gets the uuid of the object which was acted upon.
|
||||
*
|
||||
* <p>Will only return a value for {@link Type#USER} entries.</p>
|
||||
*
|
||||
* @return the uuid of acted object
|
||||
*/
|
||||
@NonNull Optional<UUID> getActed();
|
||||
|
||||
@Override
|
||||
public int compareTo(LogEntry o) {
|
||||
return equals(o) ? 0 : (Long.compare(timestamp, o.getTimestamp()) == 0 ? 1 : Long.compare(timestamp, o.getTimestamp()));
|
||||
}
|
||||
/**
|
||||
* Gets the name describing the object which was acted upon
|
||||
*
|
||||
* @return the name of the acted object
|
||||
*/
|
||||
@NonNull String getActedName();
|
||||
|
||||
public boolean matchesSearch(String query) {
|
||||
query = query.toLowerCase();
|
||||
return actorName.toLowerCase().contains(query) || actedName.toLowerCase().contains(query)
|
||||
|| action.toLowerCase().contains(query);
|
||||
}
|
||||
/**
|
||||
* Returns a string describing the action which took place.
|
||||
*
|
||||
* <p>In most instances, this returns a variation of the command string which caused
|
||||
* the change.</p>
|
||||
*
|
||||
* @return the action
|
||||
*/
|
||||
@NonNull String getAction();
|
||||
|
||||
public String getFormatted() {
|
||||
return String.format(FORMAT,
|
||||
actorName,
|
||||
Character.toString(type),
|
||||
actedName,
|
||||
action
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Represents the type of a {@link LogEntry}.
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
enum Type {
|
||||
USER('U'), GROUP('G'), TRACK('T');
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public UUID getActor() {
|
||||
return actor;
|
||||
}
|
||||
|
||||
public String getActorName() {
|
||||
return actorName;
|
||||
}
|
||||
|
||||
public char getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public UUID getActed() {
|
||||
return acted;
|
||||
}
|
||||
|
||||
public String getActedName() {
|
||||
return actedName;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
void setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
void setActor(UUID actor) {
|
||||
this.actor = actor;
|
||||
}
|
||||
|
||||
void setActorName(String actorName) {
|
||||
this.actorName = actorName;
|
||||
}
|
||||
|
||||
void setType(char type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
void setActed(UUID acted) {
|
||||
this.acted = acted;
|
||||
}
|
||||
|
||||
void setActedName(String actedName) {
|
||||
this.actedName = actedName;
|
||||
}
|
||||
|
||||
void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LogEntry(timestamp=" + this.getTimestamp() + ", actor=" + this.getActor() + ", actorName=" +
|
||||
this.getActorName() + ", type=" + this.getType() + ", acted=" + this.getActed() + ", actedName=" +
|
||||
this.getActedName() + ", action=" + this.getAction() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof LogEntry)) return false;
|
||||
final LogEntry other = (LogEntry) o;
|
||||
if (this.getTimestamp() != other.getTimestamp()) return false;
|
||||
final Object this$actor = this.getActor();
|
||||
final Object other$actor = other.getActor();
|
||||
if (this$actor == null ? other$actor != null : !this$actor.equals(other$actor)) return false;
|
||||
final Object this$actorName = this.getActorName();
|
||||
final Object other$actorName = other.getActorName();
|
||||
if (this$actorName == null ? other$actorName != null : !this$actorName.equals(other$actorName)) return false;
|
||||
if (this.getType() != other.getType()) return false;
|
||||
final Object this$acted = this.getActed();
|
||||
final Object other$acted = other.getActed();
|
||||
if (this$acted == null ? other$acted != null : !this$acted.equals(other$acted)) return false;
|
||||
final Object this$actedName = this.getActedName();
|
||||
final Object other$actedName = other.getActedName();
|
||||
if (this$actedName == null ? other$actedName != null : !this$actedName.equals(other$actedName)) return false;
|
||||
final Object this$action = this.getAction();
|
||||
final Object other$action = other.getAction();
|
||||
return this$action == null ? other$action == null : this$action.equals(other$action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = 1;
|
||||
final long $timestamp = this.getTimestamp();
|
||||
result = result * PRIME + (int) ($timestamp >>> 32 ^ $timestamp);
|
||||
final Object $actor = this.getActor();
|
||||
result = result * PRIME + ($actor == null ? 43 : $actor.hashCode());
|
||||
final Object $actorName = this.getActorName();
|
||||
result = result * PRIME + ($actorName == null ? 43 : $actorName.hashCode());
|
||||
result = result * PRIME + this.getType();
|
||||
final Object $acted = this.getActed();
|
||||
result = result * PRIME + ($acted == null ? 43 : $acted.hashCode());
|
||||
final Object $actedName = this.getActedName();
|
||||
result = result * PRIME + ($actedName == null ? 43 : $actedName.hashCode());
|
||||
final Object $action = this.getAction();
|
||||
result = result * PRIME + ($action == null ? 43 : $action.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
public static class LogEntryBuilder extends AbstractLogEntryBuilder<LogEntry, LogEntry.LogEntryBuilder> {
|
||||
|
||||
@Override
|
||||
protected LogEntry createObj() {
|
||||
return new LogEntry();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LogEntryBuilder getThis() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class AbstractLogEntryBuilder<T extends LogEntry, B extends AbstractLogEntryBuilder<T, B>> {
|
||||
private T obj;
|
||||
private B thisObj;
|
||||
|
||||
public AbstractLogEntryBuilder() {
|
||||
obj = createObj();
|
||||
thisObj = getThis();
|
||||
}
|
||||
|
||||
protected abstract T createObj();
|
||||
protected abstract B getThis();
|
||||
|
||||
public long getTimestamp() {
|
||||
return obj.getTimestamp();
|
||||
}
|
||||
|
||||
public UUID getActor() {
|
||||
return obj.getActor();
|
||||
}
|
||||
|
||||
public String getActorName() {
|
||||
return obj.getActorName();
|
||||
}
|
||||
|
||||
public char getType() {
|
||||
return obj.getType();
|
||||
}
|
||||
|
||||
public UUID getActed() {
|
||||
return obj.getActed();
|
||||
}
|
||||
|
||||
public String getActedName() {
|
||||
return obj.getActedName();
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return obj.getAction();
|
||||
}
|
||||
|
||||
public B timestamp(long timestamp) {
|
||||
obj.setTimestamp(timestamp);
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
public B actor(UUID actor) {
|
||||
obj.setActor(actor);
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
public B actorName(String actorName) {
|
||||
obj.setActorName(actorName);
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
public B type(char type) {
|
||||
obj.setType(type);
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
public B acted(UUID acted) {
|
||||
obj.setActed(acted);
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
public B actedName(String actedName) {
|
||||
obj.setActedName(actedName);
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
public B action(String action) {
|
||||
obj.setAction(action);
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
public T build() {
|
||||
if (getActor() == null) {
|
||||
throw new NullPointerException("actor");
|
||||
/**
|
||||
* Parses a {@link Type} from a string.
|
||||
*
|
||||
* @param type the string
|
||||
* @return a type
|
||||
* @throws IllegalArgumentException if a type could not be parsed
|
||||
* @since 4.4
|
||||
*/
|
||||
public static @NonNull Type parse(String type) {
|
||||
try {
|
||||
return valueOf(type);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// ignore
|
||||
}
|
||||
if (getActorName() == null) {
|
||||
throw new NullPointerException("actorName");
|
||||
try {
|
||||
return valueOf(type.charAt(0));
|
||||
} catch (IllegalArgumentException e) {
|
||||
// ignore
|
||||
}
|
||||
if (getActedName() == null) {
|
||||
throw new NullPointerException("actedName");
|
||||
}
|
||||
if (getAction() == null) {
|
||||
throw new NullPointerException("action");
|
||||
}
|
||||
|
||||
return obj;
|
||||
throw new IllegalArgumentException("Unknown type: " + type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LogEntry.LogEntryBuilder(timestamp=" + getTimestamp() + ", actor=" + getActor() + ", actorName=" +
|
||||
getActorName() + ", type=" + getType() + ", acted=" + getActed() + ", actedName=" + getActedName() +
|
||||
", action=" + getAction() + ")";
|
||||
/**
|
||||
* Returns a {@link Type} by its code.
|
||||
*
|
||||
* @param code the code - see {@link Type#getCode()}.
|
||||
* @return a type
|
||||
* @throws IllegalArgumentException if a type could not be resolved
|
||||
*/
|
||||
public static @NonNull Type valueOf(char code) {
|
||||
switch (code) {
|
||||
case 'U':
|
||||
case 'u':
|
||||
return USER;
|
||||
case 'G':
|
||||
case 'g':
|
||||
return GROUP;
|
||||
case 'T':
|
||||
case 't':
|
||||
return TRACK;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown code: " + code);
|
||||
}
|
||||
}
|
||||
|
||||
private final char code;
|
||||
|
||||
Type(char code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public char getCode() {
|
||||
return this.code;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a LogEntry instance
|
||||
*/
|
||||
interface Builder {
|
||||
|
||||
/**
|
||||
* Sets the timestamp of the entry.
|
||||
*
|
||||
* @param timestamp the timestamp
|
||||
* @return the builder
|
||||
* @see LogEntry#getTimestamp()
|
||||
*/
|
||||
@NonNull Builder setTimestamp(long timestamp);
|
||||
|
||||
/**
|
||||
* Sets the actor of the entry.
|
||||
*
|
||||
* @param actor the actor
|
||||
* @return the builder
|
||||
* @see LogEntry#getActor()
|
||||
*/
|
||||
@NonNull Builder setActor(@NonNull UUID actor);
|
||||
|
||||
/**
|
||||
* Sets the actor name of the entry.
|
||||
*
|
||||
* @param actorName the actor name
|
||||
* @return the builder
|
||||
* @see LogEntry#getActorName()
|
||||
*/
|
||||
@NonNull Builder setActorName(@NonNull String actorName);
|
||||
|
||||
/**
|
||||
* Sets the type of the entry.
|
||||
*
|
||||
* @param type the type
|
||||
* @return the builder
|
||||
* @see LogEntry#getType()
|
||||
*/
|
||||
@NonNull Builder setType(@NonNull Type type);
|
||||
|
||||
/**
|
||||
* Sets the acted object for the entry.
|
||||
*
|
||||
* @param acted the acted object
|
||||
* @return the builder
|
||||
* @see LogEntry#getActed()
|
||||
*/
|
||||
@NonNull Builder setActed(@Nullable UUID acted);
|
||||
|
||||
/**
|
||||
* Sets the acted name for the entry.
|
||||
*
|
||||
* @param actedName the acted name
|
||||
* @return the builder
|
||||
* @see LogEntry#getActedName()
|
||||
*/
|
||||
@NonNull Builder setActedName(@NonNull String actedName);
|
||||
|
||||
/**
|
||||
* Sets the action of the entry.
|
||||
*
|
||||
* @param action the action
|
||||
* @return the builder
|
||||
* @see LogEntry#getAction()
|
||||
*/
|
||||
@NonNull Builder setAction(@NonNull String action);
|
||||
|
||||
/**
|
||||
* Creates a {@link LogEntry} instance from the builder.
|
||||
*
|
||||
* @return a new log entry instance
|
||||
*/
|
||||
@NonNull LogEntry build();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* The various lookup setting flags for {@link Contexts}.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public enum LookupSetting {
|
||||
|
||||
/**
|
||||
* If the target subject is OP
|
||||
*/
|
||||
IS_OP,
|
||||
|
||||
/**
|
||||
* If global or non-server-specific nodes should be applied
|
||||
*/
|
||||
INCLUDE_NODES_SET_WITHOUT_SERVER,
|
||||
|
||||
/**
|
||||
* If global or non-world-specific nodes should be applied
|
||||
*/
|
||||
INCLUDE_NODES_SET_WITHOUT_WORLD,
|
||||
|
||||
/**
|
||||
* If parent groups should be resolved
|
||||
*/
|
||||
RESOLVE_INHERITANCE,
|
||||
|
||||
/**
|
||||
* If global or non-server-specific group memberships should be applied
|
||||
*/
|
||||
APPLY_PARENTS_SET_WITHOUT_SERVER,
|
||||
|
||||
/**
|
||||
* If global or non-world-specific group memberships should be applied
|
||||
*/
|
||||
APPLY_PARENTS_SET_WITHOUT_WORLD;
|
||||
|
||||
|
||||
|
||||
/* bitwise utility methods */
|
||||
|
||||
static boolean isSet(byte b, LookupSetting setting) {
|
||||
return ((b >> setting.ordinal()) & 1) == 1;
|
||||
}
|
||||
|
||||
static byte createFlag(LookupSetting... settings) {
|
||||
byte b = 0;
|
||||
for (LookupSetting setting : settings) {
|
||||
b |= (1 << setting.ordinal());
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
static byte createFlag(Set<LookupSetting> settings) {
|
||||
byte b = 0;
|
||||
for (LookupSetting setting : settings) {
|
||||
b |= (1 << setting.ordinal());
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
static Set<LookupSetting> createSetFromFlag(byte b) {
|
||||
EnumSet<LookupSetting> settings = EnumSet.noneOf(LookupSetting.class);
|
||||
for (LookupSetting setting : LookupSetting.values()) {
|
||||
if (((b >> setting.ordinal()) & 1) == 1) {
|
||||
settings.add(setting);
|
||||
}
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
static byte createFlag(boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) {
|
||||
byte b = 0;
|
||||
if (includeNodesSetWithoutServer) {
|
||||
b |= (1 << LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER.ordinal());
|
||||
}
|
||||
if (includeNodesSetWithoutWorld) {
|
||||
b |= (1 << LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD.ordinal());
|
||||
}
|
||||
if (resolveInheritance) {
|
||||
b |= (1 << LookupSetting.RESOLVE_INHERITANCE.ordinal());
|
||||
}
|
||||
if (applyParentsWithoutServer) {
|
||||
b |= (1 << LookupSetting.APPLY_PARENTS_SET_WITHOUT_SERVER.ordinal());
|
||||
}
|
||||
if (applyParentsWithoutWorld) {
|
||||
b |= (1 << LookupSetting.APPLY_PARENTS_SET_WITHOUT_WORLD.ordinal());
|
||||
}
|
||||
if (isOp) {
|
||||
b |= (1 << LookupSetting.IS_OP.ordinal());
|
||||
}
|
||||
return b;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,200 +25,473 @@
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import me.lucko.luckperms.api.event.LPListener;
|
||||
import me.lucko.luckperms.LuckPerms;
|
||||
import me.lucko.luckperms.api.caching.CachedData;
|
||||
import me.lucko.luckperms.api.context.ContextCalculator;
|
||||
import me.lucko.luckperms.api.context.ContextManager;
|
||||
import me.lucko.luckperms.api.context.ContextSet;
|
||||
import me.lucko.luckperms.api.event.EventBus;
|
||||
import me.lucko.luckperms.api.manager.CachedDataManager;
|
||||
import me.lucko.luckperms.api.manager.GroupManager;
|
||||
import me.lucko.luckperms.api.manager.TrackManager;
|
||||
import me.lucko.luckperms.api.manager.UserManager;
|
||||
import me.lucko.luckperms.api.messenger.MessengerProvider;
|
||||
import me.lucko.luckperms.api.metastacking.MetaStackFactory;
|
||||
import me.lucko.luckperms.api.platform.PlatformInfo;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* The root API interface in LuckPerms
|
||||
* The LuckPerms API.
|
||||
*
|
||||
* <p>This interface is the base of the entire API package. All API functions
|
||||
* are accessed via this interface.</p>
|
||||
*
|
||||
* <p>An instance can be obtained via {@link LuckPerms#getApi()}, or the platforms
|
||||
* Services Manager.</p>
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public interface LuckPermsApi {
|
||||
|
||||
/**
|
||||
* Schedules an update task to run
|
||||
* Gets information about the platform LuckPerms is running on.
|
||||
*
|
||||
* @return the platform info
|
||||
* @since 4.0
|
||||
*/
|
||||
void runUpdateTask();
|
||||
@NonNull PlatformInfo getPlatformInfo();
|
||||
|
||||
/**
|
||||
* @return the version of the API running on the platform
|
||||
* @since 2.6
|
||||
* Gets the {@link UserManager}, responsible for managing
|
||||
* {@link User} instances.
|
||||
*
|
||||
* <p>This manager can be used to retrieve instances of {@link User} by uuid
|
||||
* or name, or query all loaded users.</p>
|
||||
*
|
||||
* <p>The {@link #getStorage() storage} instance should be used to
|
||||
* load/create/save users.</p>
|
||||
*
|
||||
* @return the user manager
|
||||
* @since 4.0
|
||||
*/
|
||||
double getApiVersion();
|
||||
@NonNull UserManager getUserManager();
|
||||
|
||||
/**
|
||||
* @return the version of the plugin running on the platform
|
||||
* Gets the {@link GroupManager}, responsible for managing
|
||||
* {@link Group} instances.
|
||||
*
|
||||
* <p>This manager can be used to retrieve instances of {@link Group} by
|
||||
* name, or query all loaded groups.</p>
|
||||
*
|
||||
* <p>The {@link #getStorage() storage} instance should be used to
|
||||
* load/create/save/delete groups.</p>
|
||||
*
|
||||
* @return the group manager
|
||||
* @since 4.0
|
||||
*/
|
||||
String getVersion();
|
||||
@NonNull GroupManager getGroupManager();
|
||||
|
||||
/**
|
||||
* @return the platform LuckPerms is running on
|
||||
* @since 2.7
|
||||
* Gets the {@link TrackManager}, responsible for managing
|
||||
* {@link Track} instances.
|
||||
*
|
||||
* <p>This manager can be used to retrieve instances of {@link Track} by
|
||||
* name, or query all loaded tracks.</p>
|
||||
*
|
||||
* <p>The {@link #getStorage() storage} instance should be used to
|
||||
* load/create/save/delete tracks.</p>
|
||||
*
|
||||
* @return the track manager
|
||||
* @since 4.0
|
||||
*/
|
||||
PlatformType getPlatformType();
|
||||
@NonNull TrackManager getTrackManager();
|
||||
|
||||
/**
|
||||
* Registers a listener to be sent LuckPerms events
|
||||
* @param listener the listener instance
|
||||
* @throws NullPointerException if the listener is null
|
||||
* Gets the {@link CachedDataManager}, responsible for managing
|
||||
* {@link CachedData} instances.
|
||||
*
|
||||
* @return the cached data manager
|
||||
* @since 4.5
|
||||
*/
|
||||
void registerListener(LPListener listener);
|
||||
@NonNull CachedDataManager getCachedDataManager();
|
||||
|
||||
/**
|
||||
* Unregisters a previously registered listener from the EventBus
|
||||
* @param listener the listener instance to unregister
|
||||
* @throws NullPointerException if the listener is null
|
||||
* Schedules the execution of an update task, and returns an encapsulation
|
||||
* of the task as a {@link CompletableFuture}.
|
||||
*
|
||||
* <p>The exact actions performed in an update task remains an
|
||||
* implementation detail of the plugin, however, as a minimum, it is
|
||||
* expected to perform a full reload of user, group and track data, and
|
||||
* ensure that any changes are fully applied and propagated.</p>
|
||||
*
|
||||
* @return a future
|
||||
* @since 4.0
|
||||
*/
|
||||
void unregisterListener(LPListener listener);
|
||||
@NonNull CompletableFuture<Void> runUpdateTask();
|
||||
|
||||
/**
|
||||
* Gets a wrapped {@link LPConfiguration} instance, with read only access
|
||||
* @return a configuration instance
|
||||
* Gets the {@link EventBus}, used for subscribing to internal LuckPerms
|
||||
* events.
|
||||
*
|
||||
* @return the event bus
|
||||
* @since 3.0
|
||||
*/
|
||||
LPConfiguration getConfiguration();
|
||||
@NonNull EventBus getEventBus();
|
||||
|
||||
/**
|
||||
* Gets a wrapped {@link Datastore} instance, with somewhat limited access
|
||||
* @return a datastore instance
|
||||
* Gets a representation of the plugins configuration
|
||||
*
|
||||
* @return the configuration
|
||||
*/
|
||||
Datastore getDatastore();
|
||||
@NonNull LPConfiguration getConfiguration();
|
||||
|
||||
/**
|
||||
* Gets the {@link Logger} wrapping used by the platform
|
||||
* @return the logger instance
|
||||
* Gets an object representing the plugins primary {@link Storage} backend.
|
||||
*
|
||||
* <p>The instance propagates calls to the internal DAO (Data Access Object),
|
||||
* and applies any changes to the storage provider.</p>
|
||||
*
|
||||
* @return a storage instance
|
||||
* @since 2.14
|
||||
*/
|
||||
Logger getLogger();
|
||||
@NonNull Storage getStorage();
|
||||
|
||||
/**
|
||||
* Gets a wrapped {@link UuidCache} instance, providing read access to the LuckPerms internal uuid caching system
|
||||
* @return a uuidcache instance
|
||||
* Gets the {@link MessagingService}, if present.
|
||||
*
|
||||
* <p>The MessagingService is used to dispatch updates throughout a network
|
||||
* of servers running the plugin.</p>
|
||||
*
|
||||
* <p>Not all instances of LuckPerms will have a messaging service setup and
|
||||
* configured, but it is recommended that all users of the API account for
|
||||
* and make use of this.</p>
|
||||
*
|
||||
* @return the messaging service instance, if present.
|
||||
*/
|
||||
UuidCache getUuidCache();
|
||||
@NonNull Optional<MessagingService> getMessagingService();
|
||||
|
||||
/**
|
||||
* Registers a {@link MessengerProvider} for use by the platform.
|
||||
*
|
||||
* <p>Note that the mere action of registering a provider doesn't
|
||||
* necessarily mean that it will be used.</p>
|
||||
*
|
||||
* @param messengerProvider the messenger provider.
|
||||
* @since 4.1
|
||||
*/
|
||||
void registerMessengerProvider(@NonNull MessengerProvider messengerProvider);
|
||||
|
||||
/**
|
||||
* Gets the {@link ActionLogger}.
|
||||
*
|
||||
* <p>The action logger is responsible for saving and broadcasting defined
|
||||
* actions occurring on the platform.</p>
|
||||
*
|
||||
* @return the action logger
|
||||
* @since 4.1
|
||||
*/
|
||||
@NonNull ActionLogger getActionLogger();
|
||||
|
||||
/**
|
||||
* Gets a {@link UuidCache}.
|
||||
*
|
||||
* <p>The uuid cache provides read access to the internal LuckPerms uuid
|
||||
* mapping system.</p>
|
||||
*
|
||||
* @return the uuid cache
|
||||
* @deprecated this feature is now handled internally - and the API returns a
|
||||
* No-op implementation of this class.
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull UuidCache getUuidCache();
|
||||
|
||||
/**
|
||||
* Gets the {@link ContextManager}.
|
||||
*
|
||||
* <p>The context manager manages {@link ContextCalculator}s, and calculates
|
||||
* applicable contexts for a given type.</p>
|
||||
*
|
||||
* @return the context manager
|
||||
* @since 4.0
|
||||
*/
|
||||
@NonNull ContextManager getContextManager();
|
||||
|
||||
/**
|
||||
* Gets a {@link Collection} of all known permission strings.
|
||||
*
|
||||
* @return a collection of the known permissions
|
||||
* @since 4.4
|
||||
*/
|
||||
@NonNull Collection<String> getKnownPermissions();
|
||||
|
||||
/**
|
||||
* Gets the {@link NodeFactory}.
|
||||
*
|
||||
* <p>The node factory provides methods for building {@link Node} instances.</p>
|
||||
*
|
||||
* @return the node factory
|
||||
*/
|
||||
@NonNull NodeFactory getNodeFactory();
|
||||
|
||||
/**
|
||||
* Gets the {@link MetaStackFactory}.
|
||||
*
|
||||
* <p>The metastack factory provides methods for retrieving
|
||||
* {@link me.lucko.luckperms.api.metastacking.MetaStackElement}s and constructing
|
||||
* {@link me.lucko.luckperms.api.metastacking.MetaStackDefinition}s.</p>
|
||||
*
|
||||
* @return the meta stack factory
|
||||
* @since 3.2
|
||||
*/
|
||||
@NonNull MetaStackFactory getMetaStackFactory();
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The following methods are provided only for convenience, and offer no
|
||||
* additional functionality.
|
||||
*
|
||||
* They are implemented as "default" methods, using the manager and factory
|
||||
* instances provided by the methods above.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets a wrapped user object from the user storage
|
||||
*
|
||||
* @param uuid the uuid of the user to get
|
||||
* @return a {@link User} object, if one matching the uuid is loaded, or null if not
|
||||
* @throws NullPointerException if the uuid is null
|
||||
*/
|
||||
User getUser(UUID uuid);
|
||||
default @Nullable User getUser(@NonNull UUID uuid) {
|
||||
return getUserManager().getUser(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a wrapped user object from the user storage. This method does not return null, unlike {@link #getUser(UUID)}
|
||||
* Gets a wrapped user object from the user storage.
|
||||
*
|
||||
* @param uuid the uuid of the user to get
|
||||
* @return an optional {@link User} object
|
||||
* @throws NullPointerException if the uuid is null
|
||||
*/
|
||||
Optional<User> getUserSafe(UUID uuid);
|
||||
default @NonNull Optional<User> getUserSafe(@NonNull UUID uuid) {
|
||||
return getUserManager().getUserOpt(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a wrapped user object from the user storage
|
||||
*
|
||||
* @param name the username of the user to get
|
||||
* @return a {@link User} object, if one matching the uuid is loaded, or null if not
|
||||
* @throws NullPointerException if the name is null
|
||||
*/
|
||||
User getUser(String name);
|
||||
default @Nullable User getUser(@NonNull String name) {
|
||||
return getUserManager().getUser(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a wrapped user object from the user storage. This method does not return null, unlike {@link #getUser(String)}
|
||||
* Gets a wrapped user object from the user storage.
|
||||
*
|
||||
* @param name the username of the user to get
|
||||
* @return an optional {@link User} object
|
||||
* @throws NullPointerException if the name is null
|
||||
*/
|
||||
Optional<User> getUserSafe(String name);
|
||||
default @NonNull Optional<User> getUserSafe(@NonNull String name) {
|
||||
return getUserManager().getUserOpt(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a set of all loaded users.
|
||||
*
|
||||
* @return a {@link Set} of {@link User} objects
|
||||
*/
|
||||
Set<User> getUsers();
|
||||
default @NonNull Set<User> getUsers() {
|
||||
return getUserManager().getLoadedUsers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user is loaded in memory
|
||||
*
|
||||
* @param uuid the uuid to check for
|
||||
* @return true if the user is loaded
|
||||
* @throws NullPointerException if the uuid is null
|
||||
*/
|
||||
boolean isUserLoaded(UUID uuid);
|
||||
default boolean isUserLoaded(@NonNull UUID uuid) {
|
||||
return getUserManager().isLoaded(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload a user from the internal storage, if they're not currently online.
|
||||
*
|
||||
* @param user the user to unload
|
||||
* @throws NullPointerException if the user is null
|
||||
* @since 2.6
|
||||
*/
|
||||
void cleanupUser(User user);
|
||||
default void cleanupUser(@NonNull User user) {
|
||||
getUserManager().cleanupUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a wrapped group object from the group storage
|
||||
*
|
||||
* @param name the name of the group to get
|
||||
* @return a {@link Group} object, if one matching the name exists, or null if not
|
||||
* @throws NullPointerException if the name is null
|
||||
*/
|
||||
Group getGroup(String name);
|
||||
default @Nullable Group getGroup(@NonNull String name) {
|
||||
return getGroupManager().getGroup(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a wrapped group object from the group storage. This method does not return null, unlike {@link #getGroup}
|
||||
* Gets a wrapped group object from the group storage.
|
||||
*
|
||||
* <p>This method does not return null, unlike {@link #getGroup}</p>
|
||||
*
|
||||
* @param name the name of the group to get
|
||||
* @return an optional {@link Group} object
|
||||
* @throws NullPointerException if the name is null
|
||||
*/
|
||||
Optional<Group> getGroupSafe(String name);
|
||||
default @NonNull Optional<Group> getGroupSafe(@NonNull String name) {
|
||||
return getGroupManager().getGroupOpt(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a set of all loaded groups.
|
||||
*
|
||||
* @return a {@link Set} of {@link Group} objects
|
||||
*/
|
||||
Set<Group> getGroups();
|
||||
default @NonNull Set<Group> getGroups() {
|
||||
return getGroupManager().getLoadedGroups();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a group is loaded in memory
|
||||
*
|
||||
* @param name the name to check for
|
||||
* @return true if the group is loaded
|
||||
* @throws NullPointerException if the name is null
|
||||
*/
|
||||
boolean isGroupLoaded(String name);
|
||||
default boolean isGroupLoaded(@NonNull String name) {
|
||||
return getGroupManager().isLoaded(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a wrapped track object from the track storage
|
||||
*
|
||||
* @param name the name of the track to get
|
||||
* @return a {@link Track} object, if one matching the name exists, or null if not
|
||||
* @return a {@link Track} object, if one matching the name exists, or null
|
||||
* if not
|
||||
* @throws NullPointerException if the name is null
|
||||
*/
|
||||
Track getTrack(String name);
|
||||
default @Nullable Track getTrack(@NonNull String name) {
|
||||
return getTrackManager().getTrack(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a wrapped track object from the track storage. This method does not return null, unlike {@link #getTrack}
|
||||
* Gets a wrapped track object from the track storage.
|
||||
*
|
||||
* <p>This method does not return null, unlike {@link #getTrack}</p>
|
||||
*
|
||||
* @param name the name of the track to get
|
||||
* @return an optional {@link Track} object
|
||||
* @throws NullPointerException if the name is null
|
||||
*/
|
||||
Optional<Track> getTrackSafe(String name);
|
||||
default @NonNull Optional<Track> getTrackSafe(@NonNull String name) {
|
||||
return getTrackManager().getTrackOpt(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a set of all loaded tracks.
|
||||
*
|
||||
* @return a {@link Set} of {@link Track} objects
|
||||
*/
|
||||
Set<Track> getTracks();
|
||||
default @NonNull Set<Track> getTracks() {
|
||||
return getTrackManager().getLoadedTracks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a track is loaded in memory
|
||||
*
|
||||
* @param name the name to check for
|
||||
* @return true if the track is loaded
|
||||
* @throws NullPointerException if the name is null
|
||||
*/
|
||||
boolean isTrackLoaded(String name);
|
||||
default boolean isTrackLoaded(@NonNull String name) {
|
||||
return getTrackManager().isLoaded(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new LogEntry Builder instance
|
||||
*
|
||||
* @return a new builder
|
||||
* @since 4.0
|
||||
*/
|
||||
default LogEntry.@NonNull Builder newLogEntryBuilder() {
|
||||
return getActionLogger().newEntryBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a permission builder instance
|
||||
*
|
||||
* @param permission the main permission node to build
|
||||
* @return a {@link Node.Builder} instance
|
||||
* @throws IllegalArgumentException if the permission is invalid
|
||||
* @throws NullPointerException if the permission is null
|
||||
* @throws NullPointerException if the permission is null
|
||||
* @since 2.6
|
||||
*/
|
||||
Node.Builder buildNode(String permission) throws IllegalArgumentException;
|
||||
default Node.@NonNull Builder buildNode(@NonNull String permission) throws IllegalArgumentException {
|
||||
return getNodeFactory().newBuilder(permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom context calculator to the server
|
||||
*
|
||||
* @param calculator the context calculator to register. The type MUST be the player class of the platform.
|
||||
* @throws ClassCastException if the type is not the player class of the platform.
|
||||
*/
|
||||
default void registerContextCalculator(@NonNull ContextCalculator<?> calculator) {
|
||||
getContextManager().registerCalculator(calculator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a calculated context instance for the user using the rules of the platform.
|
||||
*
|
||||
* <p> These values are calculated using the options in the configuration, and the provided calculators.
|
||||
*
|
||||
* @param user the user to get contexts for
|
||||
* @return an optional containing contexts. Will return empty if the user is not online.
|
||||
*/
|
||||
default @NonNull Optional<Contexts> getContextForUser(@NonNull User user) {
|
||||
return getContextManager().lookupApplicableContexts(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets set of contexts applicable to a player using the platforms {@link ContextCalculator}s.
|
||||
*
|
||||
* @param player the player to calculate for. Must be the player instance for the platform.
|
||||
* @return a set of contexts.
|
||||
* @since 2.17
|
||||
*/
|
||||
default @NonNull ContextSet getContextForPlayer(@NonNull Object player) {
|
||||
return getContextManager().getApplicableContext(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Contexts instance for the player using the platforms {@link ContextCalculator}s.
|
||||
*
|
||||
* @param player the player to calculate for. Must be the player instance for the platform.
|
||||
* @return a set of contexts.
|
||||
* @since 3.3
|
||||
*/
|
||||
default @NonNull Contexts getContextsForPlayer(@NonNull Object player) {
|
||||
return getContextManager().getApplicableContexts(player);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* A means to push changes to other servers using the platforms networking
|
||||
*
|
||||
* @since 2.14
|
||||
*/
|
||||
public interface MessagingService {
|
||||
|
||||
/**
|
||||
* Gets the name of this messaging service
|
||||
*
|
||||
* @return the name of this messaging service
|
||||
* @since 4.1
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Uses the messaging service to inform other servers about a general
|
||||
* change.
|
||||
*
|
||||
* <p>The standard response by other servers will be to execute a overall
|
||||
* sync of all live data, equivalent to calling
|
||||
* {@link LuckPermsApi#runUpdateTask()}.</p>
|
||||
*
|
||||
* <p>This will push the update asynchronously, and this method will return
|
||||
* immediately. Note that this method will not cause an update to be
|
||||
* processed on the local server.</p>
|
||||
*/
|
||||
void pushUpdate();
|
||||
|
||||
/**
|
||||
* Uses the messaging service to inform other servers about a change to a
|
||||
* specific user.
|
||||
*
|
||||
* <p>The standard response by other servers is undefined, however the
|
||||
* current implementation will reload the corresponding users data if they
|
||||
* are online.</p>
|
||||
*
|
||||
* <p>This will push the update asynchronously, and this method will return
|
||||
* immediately. Note that this method will not cause an update to be
|
||||
* processed on the local server.</p>
|
||||
*
|
||||
* @param user the user to push the update for
|
||||
* @since 4.1
|
||||
*/
|
||||
void pushUserUpdate(@NonNull User user);
|
||||
|
||||
}
|
||||
@@ -1,316 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import me.lucko.luckperms.LuckPerms;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A collection of utilities to help retrieve meta values for {@link PermissionHolder}s
|
||||
* @since 2.7
|
||||
*/
|
||||
public class MetaUtils {
|
||||
|
||||
private MetaUtils(){}
|
||||
|
||||
/**
|
||||
* Escapes special characters used within LuckPerms, so the string can be saved without issues
|
||||
* @param s the string to escape
|
||||
* @return an escaped string
|
||||
* @throws NullPointerException if the string is null
|
||||
*/
|
||||
public static String escapeCharacters(String s) {
|
||||
if (s == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
s = s.replace(".", "{SEP}");
|
||||
s = s.replace("/", "{FSEP}");
|
||||
s = s.replace("$", "{DSEP}");
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unescapes special characters used within LuckPerms, the inverse of {@link #escapeCharacters(String)}
|
||||
* @param s the string to unescape
|
||||
* @return an unescaped string
|
||||
* @throws NullPointerException if the string is null
|
||||
*/
|
||||
public static String unescapeCharacters(String s) {
|
||||
if (s == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
s = s.replace("{SEP}", ".");
|
||||
s = s.replace("{FSEP}", "/");
|
||||
s = s.replace("{DSEP}", "$");
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a meta value on a holder
|
||||
* @param holder the holder to apply the meta node to
|
||||
* @param server the server to apply the meta on, can be null
|
||||
* @param world the world to apply the meta on, can be null
|
||||
* @param node the meta node
|
||||
* @param value the meta value
|
||||
* @throws NullPointerException if the holder, node or value is null
|
||||
* @throws IllegalArgumentException if the node or value is empty
|
||||
*/
|
||||
public static void setMeta(PermissionHolder holder, String server, String world, String node, String value) {
|
||||
if (holder == null) {
|
||||
throw new NullPointerException("holder");
|
||||
}
|
||||
|
||||
if (node == null) {
|
||||
throw new NullPointerException("node");
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
throw new NullPointerException("value");
|
||||
}
|
||||
|
||||
if (node.equals("")) {
|
||||
throw new IllegalArgumentException("node is empty");
|
||||
}
|
||||
|
||||
if (value.equals("")) {
|
||||
throw new IllegalArgumentException("value is empty");
|
||||
}
|
||||
|
||||
if (server == null || server.equals("")) {
|
||||
server = "global";
|
||||
}
|
||||
|
||||
node = escapeCharacters(node);
|
||||
value = escapeCharacters(value);
|
||||
|
||||
Set<Node> toRemove = new HashSet<>();
|
||||
for (Node n : holder.getEnduringPermissions()) {
|
||||
if (n.isMeta() && n.getMeta().getKey().equals(node)) {
|
||||
toRemove.add(n);
|
||||
}
|
||||
}
|
||||
|
||||
for (Node n : toRemove) {
|
||||
try {
|
||||
holder.unsetPermission(n);
|
||||
} catch (ObjectLacksException ignored) {}
|
||||
}
|
||||
|
||||
Node.Builder metaNode = LuckPerms.getApi().buildNode("meta." + node + "." + value).setValue(true);
|
||||
if (!server.equalsIgnoreCase("global")) {
|
||||
metaNode.setServer(server);
|
||||
}
|
||||
if (world != null && !world.equals("")) {
|
||||
metaNode.setServer(server).setWorld(world);
|
||||
}
|
||||
|
||||
try {
|
||||
holder.setPermission(metaNode.build());
|
||||
} catch (ObjectAlreadyHasException ignored) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a meta value for the holder
|
||||
* @param holder the holder to get the meta from
|
||||
* @param server the server to retrieve the meta on, can be null
|
||||
* @param world the world to retrieve the meta on, can be null
|
||||
* @param node the node to get
|
||||
* @param defaultValue the default value to return if the node is not set
|
||||
* @param includeGlobal if global nodes should be considered when retrieving the meta
|
||||
* @return a meta string, or the default value if the user does not have the meta node
|
||||
* @throws NullPointerException if the holder or node is null
|
||||
* @throws IllegalArgumentException if the node is empty
|
||||
*/
|
||||
public static String getMeta(PermissionHolder holder, String server, String world, String node, String defaultValue, boolean includeGlobal) {
|
||||
if (holder == null) {
|
||||
throw new NullPointerException("holder");
|
||||
}
|
||||
|
||||
if (server == null || server.equals("")) {
|
||||
server = "global";
|
||||
}
|
||||
|
||||
if (node == null) {
|
||||
throw new NullPointerException("node");
|
||||
}
|
||||
|
||||
if (node.equals("")) {
|
||||
throw new IllegalArgumentException("node is empty");
|
||||
}
|
||||
|
||||
node = escapeCharacters(node);
|
||||
|
||||
for (Node n : holder.getPermissions()) {
|
||||
if (!n.getValue()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!n.isMeta()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!server.equalsIgnoreCase("global")) {
|
||||
if (!n.shouldApplyOnServer(server, includeGlobal, false)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!n.shouldApplyOnWorld(world, includeGlobal, false)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Map.Entry<String, String> meta = n.getMeta();
|
||||
if (meta.getKey().equalsIgnoreCase(node)) {
|
||||
return unescapeCharacters(meta.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
private static void setChatMeta(boolean prefix, PermissionHolder holder, String value, int priority, String server, String world) {
|
||||
if (holder == null) {
|
||||
throw new NullPointerException("holder");
|
||||
}
|
||||
|
||||
if (value == null || value.equals("")) {
|
||||
throw new IllegalArgumentException("value is null/empty");
|
||||
}
|
||||
|
||||
Node.Builder node = LuckPerms.getApi().buildNode(prefix ? "prefix" : "suffix" + "." + priority + "." + escapeCharacters(value));
|
||||
node.setValue(true);
|
||||
if (!server.equalsIgnoreCase("global")) {
|
||||
node.setServer(server);
|
||||
}
|
||||
if (world != null && !world.equals("")) {
|
||||
node.setServer(server).setWorld(world);
|
||||
}
|
||||
|
||||
try {
|
||||
holder.setPermission(node.build());
|
||||
} catch (ObjectAlreadyHasException ignored) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a prefix to a holder on a specific server and world
|
||||
* @param holder the holder to set the prefix for
|
||||
* @param prefix the prefix value
|
||||
* @param priority the priority to set the prefix at
|
||||
* @param server the server to set the prefix on, can be null
|
||||
* @param world the world to set the prefix on, can be null
|
||||
* @throws NullPointerException if the holder is null
|
||||
* @throws IllegalArgumentException if the prefix is null or empty
|
||||
*/
|
||||
public static void setPrefix(PermissionHolder holder, String prefix, int priority, String server, String world) {
|
||||
setChatMeta(true, holder, prefix, priority, server, world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a suffix to a holder on a specific server and world
|
||||
* @param holder the holder to set the suffix for
|
||||
* @param suffix the suffix value
|
||||
* @param priority the priority to set the suffix at
|
||||
* @param server the server to set the suffix on, can be null
|
||||
* @param world the world to set the suffix on, can be null
|
||||
* @throws NullPointerException if the holder is null
|
||||
* @throws IllegalArgumentException if the suffix is null or empty
|
||||
*/
|
||||
public static void setSuffix(PermissionHolder holder, String suffix, int priority, String server, String world) {
|
||||
setChatMeta(false, holder, suffix, priority, server, world);
|
||||
}
|
||||
|
||||
private static String getChatMeta(boolean prefix, PermissionHolder holder, String server, String world, boolean includeGlobal) {
|
||||
if (holder == null) {
|
||||
throw new NullPointerException("holder");
|
||||
}
|
||||
if (server == null) {
|
||||
server = "global";
|
||||
}
|
||||
|
||||
int priority = Integer.MIN_VALUE;
|
||||
String meta = null;
|
||||
for (Node n : holder.getAllNodes()) {
|
||||
if (!n.getValue()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!server.equalsIgnoreCase("global")) {
|
||||
if (!n.shouldApplyOnServer(server, includeGlobal, false)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!n.shouldApplyOnWorld(world, includeGlobal, false)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prefix ? !n.isPrefix() : !n.isSuffix()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Map.Entry<Integer, String> value = prefix ? n.getPrefix() : n.getSuffix();
|
||||
if (value.getKey() > priority) {
|
||||
meta = value.getValue();
|
||||
priority = value.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
return meta == null ? "" : unescapeCharacters(meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a holders highest priority prefix, if they have one
|
||||
* @param holder the holder
|
||||
* @param server the server to retrieve the prefix on
|
||||
* @param world the world to retrieve the prefix on
|
||||
* @param includeGlobal if global nodes should be considered when retrieving the prefix
|
||||
* @return a prefix string, if the holder has one, or an empty string if not.
|
||||
* @throws NullPointerException if the holder is null
|
||||
*/
|
||||
public static String getPrefix(PermissionHolder holder, String server, String world, boolean includeGlobal) {
|
||||
return getChatMeta(true, holder, server, world, includeGlobal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a holders highest priority suffix, if they have one
|
||||
* @param holder the holder
|
||||
* @param server the server to retrieve the suffix on
|
||||
* @param world the world to retrieve the suffix on
|
||||
* @param includeGlobal if global nodes should be considered when retrieving the suffix
|
||||
* @return a suffix string, if the holder has one, or an empty string if not.
|
||||
* @throws NullPointerException if the holder is null
|
||||
*/
|
||||
public static String getSuffix(PermissionHolder holder, String server, String world, boolean includeGlobal) {
|
||||
return getChatMeta(false, holder, server, world, includeGlobal);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
/**
|
||||
* Represents the result to a "mutation" on an object.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public interface MutateResult {
|
||||
|
||||
/**
|
||||
* Instance of {@link MutateResult} which always reports success.
|
||||
*/
|
||||
MutateResult GENERIC_SUCCESS = () -> true;
|
||||
|
||||
/**
|
||||
* Instance of {@link MutateResult} which always reports failure.
|
||||
*/
|
||||
MutateResult GENERIC_FAILURE = () -> false;
|
||||
|
||||
/**
|
||||
* Gets if the operation which produced this result completed successfully.
|
||||
*
|
||||
* @return if the result indicates a success
|
||||
*/
|
||||
boolean wasSuccess();
|
||||
|
||||
/**
|
||||
* Gets if the operation which produced this result failed.
|
||||
*
|
||||
* @return if the result indicates a failure
|
||||
*/
|
||||
default boolean wasFailure() {
|
||||
return !wasSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a boolean representation of the result.
|
||||
*
|
||||
* <p>A value of <code>true</code> marks that the operation {@link #wasSuccess() was a success}
|
||||
* and a value of <code>false</code> marks that the operation
|
||||
* {@link #wasFailure() was a failure}.</p>
|
||||
*
|
||||
* @return a boolean representation
|
||||
*/
|
||||
default boolean asBoolean() {
|
||||
return wasSuccess();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,280 +25,646 @@
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import me.lucko.luckperms.api.context.ContextSet;
|
||||
import me.lucko.luckperms.api.nodetype.NodeType;
|
||||
import me.lucko.luckperms.api.nodetype.NodeTypeKey;
|
||||
import me.lucko.luckperms.api.nodetype.types.DisplayNameType;
|
||||
import me.lucko.luckperms.api.nodetype.types.InheritanceType;
|
||||
import me.lucko.luckperms.api.nodetype.types.MetaType;
|
||||
import me.lucko.luckperms.api.nodetype.types.PrefixType;
|
||||
import me.lucko.luckperms.api.nodetype.types.SuffixType;
|
||||
import me.lucko.luckperms.api.nodetype.types.WeightType;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Represents an immutable node object
|
||||
* <p> Use {@link LuckPermsApi#buildNode(String)} to get an instance.
|
||||
* Represents a LuckPerms "node".
|
||||
*
|
||||
* <p>The {@link Node} class encapsulates more than just permission assignments.
|
||||
* Nodes are used to store data about inherited groups, as well as assigned
|
||||
* prefixes, suffixes and meta values.</p>
|
||||
*
|
||||
* <p>Combining these various states into one object (a "node") means that a
|
||||
* holder only has to have one type of data set (a set of nodes) in order to
|
||||
* take on various properties.</p>
|
||||
*
|
||||
* <p>It is recommended that users of the API make use of {@link Stream}s
|
||||
* to manipulate data and obtain the required information.</p>
|
||||
*
|
||||
* <p>This interface provides a number of methods to read the attributes of the
|
||||
* node, as well as methods to query and extract additional state and properties
|
||||
* from these settings.</p>
|
||||
*
|
||||
* <p>Nodes have the following attributes:</p>
|
||||
* <p></p>
|
||||
* <ul>
|
||||
* <li>{@link #getPermission() permission} - the actual permission string</li>
|
||||
* <li>{@link #getValue() value} - the value of the node (false for negated)</li>
|
||||
* <li>{@link #isOverride() override} - if the node is marked as having special priority over other nodes</li>
|
||||
* <li>{@link #getServer() server} - the specific server where this node should apply</li>
|
||||
* <li>{@link #getWorld() world} - the specific world where this node should apply</li>
|
||||
* <li>{@link #getContexts() context} - the additional contexts required for this node to apply </li>
|
||||
* <li>{@link #getExpiry() expiry} - the time when this node should expire</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>The 'permission' property of a {@link Node} is also used in some cases to represent state
|
||||
* beyond a granted permission. This state is encapsulated by extra {@link NodeType} data which
|
||||
* can be obtained from this instance using {@link #getTypeData(NodeTypeKey)}.</p>
|
||||
*
|
||||
* <p>Type data is mapped by {@link NodeTypeKey}s, which are usually stored as static members of the
|
||||
* corresponding {@link NodeType} class under the <code>KEY</code> field.</p>
|
||||
*
|
||||
* <p>The current types are:</p>
|
||||
* <p></p>
|
||||
* <ul>
|
||||
* <li>normal - just a regular permission</li>
|
||||
* <li>{@link InheritanceType} - an "inheritance node" marks that the holder should inherit data from another group</li>
|
||||
* <li>{@link PrefixType} - represents an assigned prefix</li>
|
||||
* <li>{@link SuffixType} - represents an assigned suffix</li>
|
||||
* <li>{@link MetaType} - represents an assigned meta option</li>
|
||||
* <li>{@link WeightType} - marks the weight of the object holding this node</li>
|
||||
* <li>{@link DisplayNameType} - marks the display name of the object holding this node</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>The core node state must be immutable in all implementations.</p>
|
||||
*
|
||||
* @see NodeFactory for obtaining and constructing instances.
|
||||
* @since 2.6
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public interface Node extends Map.Entry<String, Boolean> {
|
||||
public interface Node {
|
||||
|
||||
/**
|
||||
* Gets the permission string this node encapsulates.
|
||||
*
|
||||
* <p>The exact value of this string may vary for nodes which aren't regular
|
||||
* permission settings.</p>
|
||||
*
|
||||
* @return the actual permission node
|
||||
*/
|
||||
String getPermission();
|
||||
@NonNull String getPermission();
|
||||
|
||||
/**
|
||||
* Get what value the permission is set to. A negated node would return <code>false</code>.
|
||||
* @return the permission's value
|
||||
* Gets the value of the node.
|
||||
*
|
||||
* <p>A negated setting would result in a value of <code>false</code>.</p>
|
||||
*
|
||||
* @return the nodes value
|
||||
*/
|
||||
@Override
|
||||
Boolean getValue();
|
||||
boolean getValue();
|
||||
|
||||
/**
|
||||
* Gets the value of this node as a {@link Tristate}.
|
||||
*
|
||||
* @return the value of this node as a Tristate
|
||||
*/
|
||||
Tristate getTristate();
|
||||
default @NonNull Tristate getTristate() {
|
||||
return Tristate.fromBoolean(getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if the node is negated.
|
||||
*
|
||||
* <p>This is the inverse of the {@link #getValue() value}.</p>
|
||||
*
|
||||
* @return true if the node is negated
|
||||
*/
|
||||
boolean isNegated();
|
||||
default boolean isNegated() {
|
||||
return !getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* If this node is set to override explicitly.
|
||||
* This value does not persist across saves, and is therefore only useful for transient nodes
|
||||
* Gets if this node is set to override explicitly.
|
||||
*
|
||||
* <p>This value does not persist across saves, and is therefore only
|
||||
* useful for transient nodes.</p>
|
||||
*
|
||||
* @return true if this node is set to override explicitly
|
||||
*/
|
||||
boolean isOverride();
|
||||
|
||||
/**
|
||||
* Gets the server this node applies on, if the node is server specific
|
||||
* Gets the server this node applies on, if the node is server specific.
|
||||
*
|
||||
* @return an {@link Optional} containing the server, if one is defined
|
||||
*/
|
||||
Optional<String> getServer();
|
||||
@NonNull Optional<String> getServer();
|
||||
|
||||
/**
|
||||
* Gets the world this node applies on, if the node is world specific
|
||||
* Gets the world this node applies on, if the node is world specific.
|
||||
*
|
||||
* @return an {@link Optional} containing the world, if one is defined
|
||||
*/
|
||||
Optional<String> getWorld();
|
||||
@NonNull Optional<String> getWorld();
|
||||
|
||||
/**
|
||||
* Gets if this node is server specific.
|
||||
*
|
||||
* @return true if this node is server specific
|
||||
*/
|
||||
boolean isServerSpecific();
|
||||
|
||||
/**
|
||||
* Gets if this node is server specific.
|
||||
*
|
||||
* @return true if this node is server specific
|
||||
*/
|
||||
boolean isWorldSpecific();
|
||||
|
||||
/**
|
||||
* If this node should apply on a specific server
|
||||
* @param server the name of the server
|
||||
* @param includeGlobal if global permissions should apply
|
||||
* @param applyRegex if regex should be applied
|
||||
* Gets if this node applies globally, and therefore has no specific context.
|
||||
*
|
||||
* @return true if this node applies globally, and has no specific context
|
||||
* @since 3.1
|
||||
*/
|
||||
boolean appliesGlobally();
|
||||
|
||||
/**
|
||||
* Gets if this node has any specific context in order for it to apply.
|
||||
*
|
||||
* @return true if this node has specific context
|
||||
* @since 3.1
|
||||
*/
|
||||
boolean hasSpecificContext();
|
||||
|
||||
/**
|
||||
* Gets if this node should apply in the given context
|
||||
*
|
||||
* @param contextSet the context set
|
||||
* @return true if the node should apply
|
||||
* @since 2.13
|
||||
*/
|
||||
boolean shouldApplyOnServer(String server, boolean includeGlobal, boolean applyRegex);
|
||||
boolean shouldApplyWithContext(@NonNull ContextSet contextSet);
|
||||
|
||||
/**
|
||||
* If this node should apply on a specific world
|
||||
* @param world the name of the world
|
||||
* @param includeGlobal if global permissions should apply
|
||||
* @param applyRegex if regex should be applied
|
||||
* @return true if the node should apply
|
||||
*/
|
||||
boolean shouldApplyOnWorld(String world, boolean includeGlobal, boolean applyRegex);
|
||||
|
||||
/**
|
||||
* If this node should apply given the specific context
|
||||
* @param context the context key value pairs
|
||||
* @return true if the node should apply
|
||||
*/
|
||||
boolean shouldApplyWithContext(Map<String, String> context);
|
||||
|
||||
/**
|
||||
* Similar to {@link #shouldApplyOnServer(String, boolean, boolean)}, except this method accepts a List
|
||||
* @param servers the list of servers
|
||||
* @param includeGlobal if global permissions should apply
|
||||
* @return true if the node should apply
|
||||
*/
|
||||
boolean shouldApplyOnAnyServers(List<String> servers, boolean includeGlobal);
|
||||
|
||||
/**
|
||||
* Similar to {@link #shouldApplyOnWorld(String, boolean, boolean)}, except this method accepts a List
|
||||
* @param worlds the list of world
|
||||
* @param includeGlobal if global permissions should apply
|
||||
* @return true if the node should apply
|
||||
*/
|
||||
boolean shouldApplyOnAnyWorlds(List<String> worlds, boolean includeGlobal);
|
||||
|
||||
/**
|
||||
* Resolves a list of wildcards that match this node
|
||||
* @param possibleNodes a list of possible permission nodes
|
||||
* @return a list of permissions that match this wildcard
|
||||
*/
|
||||
List<String> resolveWildcard(List<String> possibleNodes);
|
||||
|
||||
/**
|
||||
* Resolves any shorthand parts of this node and returns the full list
|
||||
* Resolves any shorthand parts of this node and returns the full list of
|
||||
* resolved nodes.
|
||||
*
|
||||
* <p>The list will not contain the exact permission itself.</p>
|
||||
*
|
||||
* @return a list of full nodes
|
||||
*/
|
||||
List<String> resolveShorthand();
|
||||
@NonNull List<String> resolveShorthand();
|
||||
|
||||
/**
|
||||
* Gets if this node is assigned temporarily.
|
||||
*
|
||||
* @return true if this node will expire in the future
|
||||
*/
|
||||
boolean isTemporary();
|
||||
|
||||
/**
|
||||
* Gets if this node is permanent (will not expire).
|
||||
*
|
||||
* @return true if this node will not expire
|
||||
*/
|
||||
boolean isPermanent();
|
||||
default boolean isPermanent() {
|
||||
return !isTemporary();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the unix timestamp (in seconds) when this node will expire.
|
||||
*
|
||||
* @return the time in Unix time when this node will expire
|
||||
* @throws IllegalStateException if the node is not temporary
|
||||
*/
|
||||
long getExpiryUnixTime();
|
||||
long getExpiryUnixTime() throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* Gets the date when this node will expire.
|
||||
*
|
||||
* @return the {@link Date} when this node will expire
|
||||
* @throws IllegalStateException if the node is not temporary
|
||||
*/
|
||||
Date getExpiry();
|
||||
@NonNull Date getExpiry() throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* Gets the number of seconds until this permission will expire.
|
||||
*
|
||||
* <p>Will return a negative value if the node has already expired.</p>
|
||||
*
|
||||
* @return the number of seconds until this permission will expire
|
||||
* @throws IllegalStateException if the node is not temporary
|
||||
*/
|
||||
long getSecondsTilExpiry();
|
||||
long getSecondsTilExpiry() throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* Return true if the node has expired.
|
||||
* This also returns false if the node is not temporary
|
||||
* Gets if the node has expired.
|
||||
*
|
||||
* <p>This returns false if the node is not temporary.</p>
|
||||
*
|
||||
* @return true if this node has expired
|
||||
*/
|
||||
boolean hasExpired();
|
||||
|
||||
/**
|
||||
* Gets the extra contexts required for this node to apply.
|
||||
*
|
||||
* @return the extra contexts required for this node to apply
|
||||
* @since 2.13
|
||||
*/
|
||||
Map<String, String> getExtraContexts();
|
||||
@NonNull ContextSet getContexts();
|
||||
|
||||
/**
|
||||
* Converts this node into a serialized form
|
||||
* @return a serialized node string
|
||||
* The same as {@link #getContexts()}, but also includes context pairs for
|
||||
* "server" and "world" keys if present.
|
||||
*
|
||||
* @return the full contexts required for this node to apply
|
||||
* @see Contexts#SERVER_KEY
|
||||
* @see Contexts#WORLD_KEY
|
||||
* @since 3.1
|
||||
*/
|
||||
String toSerializedNode();
|
||||
@NonNull ContextSet getFullContexts();
|
||||
|
||||
/**
|
||||
* @return true if this is a group node
|
||||
*/
|
||||
boolean isGroupNode();
|
||||
|
||||
/**
|
||||
* @return the name of the group
|
||||
* @throws IllegalStateException if this is not a group node. See {@link #isGroupNode()}
|
||||
*/
|
||||
String getGroupName();
|
||||
|
||||
/**
|
||||
* @return true is this node is a wildcard node
|
||||
* Gets if this node is a wildcard permission.
|
||||
*
|
||||
* @return true if this node is a wildcard permission
|
||||
*/
|
||||
boolean isWildcard();
|
||||
|
||||
/**
|
||||
* Gets the level of this wildcard, higher is more specific
|
||||
* Gets the level of this wildcard.
|
||||
*
|
||||
* <p>The node <code>luckperms.*</code> has a wildcard level of 1.</p>
|
||||
* <p>The node <code>luckperms.user.permission.*</code> has a wildcard level of 3.</p>
|
||||
*
|
||||
* <p>Nodes with a higher wildcard level are more specific and have priority over
|
||||
* less specific nodes (nodes with a lower wildcard level).</p>
|
||||
*
|
||||
* @return the wildcard level
|
||||
* @throws IllegalStateException if this is not a wildcard
|
||||
*/
|
||||
int getWildcardLevel();
|
||||
int getWildcardLevel() throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* @return true if this node is a meta node
|
||||
* Gets if this node has any extra {@link NodeType} data attached to it.
|
||||
*
|
||||
* @return if this node has any type data
|
||||
* @since 4.2
|
||||
*/
|
||||
boolean isMeta();
|
||||
boolean hasTypeData();
|
||||
|
||||
/**
|
||||
* Gets the meta value from this node
|
||||
* @return the meta value
|
||||
* @throws IllegalStateException if this node is not a meta node
|
||||
* Gets the type data corresponding to the given <code>key</code>, if present.
|
||||
*
|
||||
* @param key the key
|
||||
* @param <T> the {@link NodeType} type
|
||||
* @return the data, if present
|
||||
* @since 4.2
|
||||
*/
|
||||
Map.Entry<String, String> getMeta();
|
||||
<T extends NodeType> Optional<T> getTypeData(NodeTypeKey<T> key);
|
||||
|
||||
/**
|
||||
* Gets the type data corresponding to the given <code>key</code>, throwing an exception
|
||||
* if no data is present.
|
||||
*
|
||||
* @param key the key
|
||||
* @param <T> the {@link NodeType} type
|
||||
* @return the data
|
||||
* @throws IllegalStateException if data isn't present
|
||||
* @since 4.2
|
||||
*/
|
||||
default <T extends NodeType> T typeData(NodeTypeKey<T> key) throws IllegalStateException {
|
||||
return getTypeData(key).orElseThrow(() -> new IllegalStateException("Node '" + getPermission() + "' does not have the '" + key.getTypeName() + "' type."));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if this node has {@link InheritanceType} type data.
|
||||
*
|
||||
* @return true if this is a inheritance (group) node.
|
||||
*/
|
||||
default boolean isGroupNode() {
|
||||
return getTypeData(InheritanceType.KEY).isPresent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the inherited group if this node has {@link InheritanceType} type data,
|
||||
* throwing an exception if the data is not present.
|
||||
*
|
||||
* @return the name of the group
|
||||
* @throws IllegalStateException if this node doesn't have {@link InheritanceType} data
|
||||
*/
|
||||
default @NonNull String getGroupName() throws IllegalStateException {
|
||||
return typeData(InheritanceType.KEY).getGroupName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if this node has {@link MetaType} type data.
|
||||
*
|
||||
* @return true if this is a meta node.
|
||||
*/
|
||||
default boolean isMeta() {
|
||||
return getTypeData(MetaType.KEY).isPresent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the meta entry if this node has {@link MetaType} type data,
|
||||
* throwing an exception if the data is not present.
|
||||
*
|
||||
* @return the meta entry
|
||||
* @throws IllegalStateException if this node doesn't have {@link MetaType} data
|
||||
*/
|
||||
default Map.@NonNull Entry<String, String> getMeta() throws IllegalStateException {
|
||||
return typeData(MetaType.KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if this node has {@link PrefixType} type data.
|
||||
*
|
||||
* @return true if this node is a prefix node
|
||||
*/
|
||||
boolean isPrefix();
|
||||
default boolean isPrefix() {
|
||||
return getTypeData(PrefixType.KEY).isPresent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the prefix value from this node
|
||||
* @return the prefix value
|
||||
* @throws IllegalStateException if this node is a not a prefix node
|
||||
* Gets the prefix entry if this node has {@link PrefixType} type data,
|
||||
* throwing an exception if the data is not present.
|
||||
*
|
||||
* @return the meta entry
|
||||
* @throws IllegalStateException if this node doesn't have {@link PrefixType} data
|
||||
*/
|
||||
Map.Entry<Integer, String> getPrefix();
|
||||
default Map.@NonNull Entry<Integer, String> getPrefix() throws IllegalStateException {
|
||||
return typeData(PrefixType.KEY).getAsEntry();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if this node has {@link SuffixType} type data.
|
||||
*
|
||||
* @return true if this node is a suffix node
|
||||
*/
|
||||
boolean isSuffix();
|
||||
default boolean isSuffix() {
|
||||
return getTypeData(SuffixType.KEY).isPresent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the suffix value from this node
|
||||
* @return the suffix value
|
||||
* @throws IllegalStateException if this node is a not a suffix node
|
||||
* Gets the suffix entry if this node has {@link SuffixType} type data,
|
||||
* throwing an exception if the data is not present.
|
||||
*
|
||||
* @return the meta entry
|
||||
* @throws IllegalStateException if this node doesn't have {@link SuffixType} data
|
||||
*/
|
||||
Map.Entry<Integer, String> getSuffix();
|
||||
default Map.@NonNull Entry<Integer, String> getSuffix() throws IllegalStateException {
|
||||
return typeData(SuffixType.KEY).getAsEntry();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this Node is equal to another node
|
||||
* Gets if this Node is equal to another node.
|
||||
*
|
||||
* @param obj the other node
|
||||
* @return true if this node is equal to the other provided
|
||||
* @see #equalsIgnoringValue(Node) for a less strict implementation of this method
|
||||
* @see StandardNodeEquality#EXACT
|
||||
*/
|
||||
@Override
|
||||
boolean equals(Object obj);
|
||||
|
||||
/**
|
||||
* Similar to {@link Node#equals(Object)}, except doesn't take note of the value
|
||||
* @param other the other node
|
||||
* @return true if the two nodes are almost equal
|
||||
* Gets if this Node is equal to another node as defined by the given
|
||||
* {@link NodeEqualityPredicate}.
|
||||
*
|
||||
* @param other the other node
|
||||
* @param equalityPredicate the predicate
|
||||
* @return true if this node is considered equal
|
||||
* @since 4.1
|
||||
*/
|
||||
boolean equalsIgnoringValue(Node other);
|
||||
boolean equals(Node other, NodeEqualityPredicate equalityPredicate);
|
||||
|
||||
/**
|
||||
* Similar to {@link Node#equals(Object)}, except doesn't take note of the expiry time or value
|
||||
* Similar to {@link Node#equals(Object)}, except doesn't take note of the
|
||||
* value.
|
||||
*
|
||||
* @param other the other node
|
||||
* @return true if the two nodes are almost equal
|
||||
* @see StandardNodeEquality#IGNORE_VALUE
|
||||
* @deprecated in favour of {@link #equals(Node, NodeEqualityPredicate)}
|
||||
*/
|
||||
boolean almostEquals(Node other);
|
||||
@Deprecated
|
||||
default boolean equalsIgnoringValue(@NonNull Node other) {
|
||||
return equals(other, StandardNodeEquality.IGNORE_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to {@link Node#equals(Object)}, except doesn't take note of the value or if the node is temporary
|
||||
* Similar to {@link Node#equals(Object)}, except doesn't take note of the
|
||||
* expiry time or value.
|
||||
*
|
||||
* @param other the other node
|
||||
* @return true if the two nodes are almost equal
|
||||
* @see StandardNodeEquality#IGNORE_EXPIRY_TIME_AND_VALUE
|
||||
* @deprecated in favour of {@link #equals(Node, NodeEqualityPredicate)}
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean almostEquals(@NonNull Node other) {
|
||||
return equals(other, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to {@link Node#equals(Object)}, except doesn't take note of the
|
||||
* value or if the node is temporary.
|
||||
*
|
||||
* @param other the other node
|
||||
* @return true if the two nodes are almost equal
|
||||
* @see StandardNodeEquality#IGNORE_VALUE_OR_IF_TEMPORARY
|
||||
* @since 2.8
|
||||
* @deprecated in favour of {@link #equals(Node, NodeEqualityPredicate)}
|
||||
*/
|
||||
boolean equalsIgnoringValueOrTemp(Node other);
|
||||
@Deprecated
|
||||
default boolean equalsIgnoringValueOrTemp(@NonNull Node other) {
|
||||
return equals(other, StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new builder initially containing the current properties of
|
||||
* this node.
|
||||
*
|
||||
* @return a new builder
|
||||
* @since 4.1
|
||||
*/
|
||||
Builder toBuilder();
|
||||
|
||||
/**
|
||||
* Builds a Node instance
|
||||
*/
|
||||
interface Builder {
|
||||
Builder setNegated(boolean negated);
|
||||
Builder setValue(boolean value);
|
||||
|
||||
/**
|
||||
* Warning: this value does not persist, and disappears when the holder is re-loaded.
|
||||
* It is therefore only useful for transient nodes.
|
||||
* Copies the attributes from the given node and applies them to this
|
||||
* builder.
|
||||
*
|
||||
* <p>Note that this copies all attributes <strong>except</strong> the
|
||||
* permission itself.</p>
|
||||
*
|
||||
* @param node the node to copy from
|
||||
* @return the builder
|
||||
* @since 4.2
|
||||
*/
|
||||
Builder setOverride(boolean override);
|
||||
Builder copyFrom(@NonNull Node node);
|
||||
|
||||
Builder setExpiry(long expireAt);
|
||||
Builder setWorld(String world);
|
||||
Builder setServer(String server) throws IllegalArgumentException;
|
||||
Builder withExtraContext(String key, String value);
|
||||
Builder withExtraContext(Map<String, String> map);
|
||||
Builder withExtraContext(Map.Entry<String, String> entry);
|
||||
Node build();
|
||||
/**
|
||||
* Sets the value of negated for the node.
|
||||
*
|
||||
* @param negated the value
|
||||
* @return the builder
|
||||
* @see Node#isNegated()
|
||||
*/
|
||||
@NonNull Builder setNegated(boolean negated);
|
||||
|
||||
/**
|
||||
* Sets the value of the node.
|
||||
*
|
||||
* @param value the value
|
||||
* @return the builder
|
||||
* @see Node#getValue()
|
||||
*/
|
||||
@NonNull Builder setValue(boolean value);
|
||||
|
||||
/**
|
||||
* Sets the override property for the node.
|
||||
*
|
||||
* <p>Warning: this value does not persist, and disappears when the holder is re-loaded.
|
||||
* It is therefore only useful for transient nodes.</p>
|
||||
*
|
||||
* @param override the override state
|
||||
* @return the builder
|
||||
* @see Node#isOverride()
|
||||
*/
|
||||
@NonNull Builder setOverride(boolean override);
|
||||
|
||||
/**
|
||||
* Sets the time when the node should expire.
|
||||
*
|
||||
* <p>The parameter passed to this method must be the unix timestamp
|
||||
* (in seconds) when the node should expire.</p>
|
||||
*
|
||||
* @param expiryUnixTimestamp the expiry timestamp (unix seconds)
|
||||
* @return the builder
|
||||
* @see Node#getExpiryUnixTime()
|
||||
*/
|
||||
@NonNull Builder setExpiry(long expiryUnixTimestamp);
|
||||
|
||||
/**
|
||||
* Sets the time when the node should expire.
|
||||
*
|
||||
* <p>The expiry timestamp is calculated relative to the current
|
||||
* system time.</p>
|
||||
*
|
||||
* @param duration how long the node should be added for
|
||||
* @param unit the unit <code>duration</code> is measured in
|
||||
* @return the builder
|
||||
* @since 4.2
|
||||
*/
|
||||
default @NonNull Builder setExpiry(long duration, TimeUnit unit) {
|
||||
Preconditions.checkArgument(duration > 0, "duration must be positive");
|
||||
long seconds = Objects.requireNonNull(unit, "unit").toSeconds(duration);
|
||||
long timeNow = System.currentTimeMillis() / 1000L;
|
||||
return setExpiry(timeNow + seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks that the node being built should never expire.
|
||||
*
|
||||
* @return the builder
|
||||
* @since 4.2
|
||||
*/
|
||||
@NonNull Builder clearExpiry();
|
||||
|
||||
/**
|
||||
* Sets the world value for the node.
|
||||
*
|
||||
* @param world the world value
|
||||
* @return the builder
|
||||
* @see Node#getWorld()
|
||||
*/
|
||||
@NonNull Builder setWorld(@Nullable String world);
|
||||
|
||||
/**
|
||||
* Sets the server value for the node.
|
||||
*
|
||||
* @param server the world value
|
||||
* @return the builder
|
||||
* @see Node#getServer()
|
||||
*/
|
||||
@NonNull Builder setServer(@Nullable String server);
|
||||
|
||||
/**
|
||||
* Appends an extra context onto the node.
|
||||
*
|
||||
* @param key the context key
|
||||
* @param value the context value
|
||||
* @return the builder
|
||||
* @see ContextSet
|
||||
* @see Node#getContexts()
|
||||
*/
|
||||
@NonNull Builder withExtraContext(@NonNull String key, @NonNull String value);
|
||||
|
||||
/**
|
||||
* Appends extra contexts onto the node.
|
||||
*
|
||||
* @param map a map of contexts
|
||||
* @return the builder
|
||||
* @see ContextSet
|
||||
* @see Node#getContexts()
|
||||
*/
|
||||
@NonNull Builder withExtraContext(@NonNull Map<String, String> map);
|
||||
|
||||
/**
|
||||
* Appends extra contexts onto the node.
|
||||
*
|
||||
* @param context a set of contexts
|
||||
* @return the builder
|
||||
* @see ContextSet
|
||||
* @see Node#getContexts()
|
||||
*/
|
||||
@NonNull Builder withExtraContext(@NonNull Set<Map.Entry<String, String>> context);
|
||||
|
||||
/**
|
||||
* Appends an extra context onto the node.
|
||||
*
|
||||
* @param entry the context
|
||||
* @return the builder
|
||||
* @see ContextSet
|
||||
* @see Node#getContexts()
|
||||
*/
|
||||
@NonNull Builder withExtraContext(Map.@NonNull Entry<String, String> entry);
|
||||
|
||||
/**
|
||||
* Appends extra contexts onto the node.
|
||||
*
|
||||
* @param contextSet a context set
|
||||
* @return the builder
|
||||
* @see ContextSet
|
||||
* @see Node#getContexts()
|
||||
*/
|
||||
@NonNull Builder withExtraContext(@NonNull ContextSet contextSet);
|
||||
|
||||
/**
|
||||
* Sets the extra contexts for the node.
|
||||
*
|
||||
* @param contextSet a context set
|
||||
* @return the builder
|
||||
* @see ContextSet
|
||||
* @see Node#getContexts()
|
||||
* @since 4.2
|
||||
*/
|
||||
@NonNull Builder setExtraContext(@NonNull ContextSet contextSet);
|
||||
|
||||
/**
|
||||
* Creates a {@link Node} instance from the builder.
|
||||
*
|
||||
* @return a new node instance
|
||||
*/
|
||||
@NonNull Node build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* A rule for determining if two nodes are equal.
|
||||
*
|
||||
* <p>Generally, individual instances of this interface should fulfil the same
|
||||
* requirements as the {@link Object#equals(Object)} contract.</p>
|
||||
*
|
||||
* <p>Some standard implementations are provided by {@link StandardNodeEquality}.</p>
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface NodeEqualityPredicate {
|
||||
|
||||
/**
|
||||
* Returns if the two nodes are equal.
|
||||
*
|
||||
* <p>This method should avoid making calls to {@link Node#equals(Node, NodeEqualityPredicate)}
|
||||
* with {@code this} as the second argument, directly or otherwise.</p>
|
||||
*
|
||||
* @param o1 the first node
|
||||
* @param o2 the second node
|
||||
* @return true if equal
|
||||
*/
|
||||
boolean areEqual(@NonNull Node o1, @NonNull Node o2);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Assists with constructing {@link Node} instances.
|
||||
*
|
||||
* @since 2.17
|
||||
*/
|
||||
public interface NodeFactory {
|
||||
|
||||
/**
|
||||
* Creates a new node builder from a given base permission string
|
||||
*
|
||||
* @param permission the permission
|
||||
* @return a node builder instance
|
||||
* @throws NullPointerException if the permission is null
|
||||
*/
|
||||
Node.@NonNull Builder newBuilder(@NonNull String permission);
|
||||
|
||||
/**
|
||||
* Creates a node builder instance from an existing node
|
||||
*
|
||||
* @param other the other node
|
||||
* @return a node builder instance
|
||||
* @throws NullPointerException if the other node is null
|
||||
*/
|
||||
Node.@NonNull Builder newBuilderFromExisting(@NonNull Node other);
|
||||
|
||||
|
||||
/**
|
||||
* Creates a node builder from a group
|
||||
*
|
||||
* @param group the group
|
||||
* @return a node builder instance
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @since 3.1
|
||||
*/
|
||||
Node.@NonNull Builder makeGroupNode(@NonNull Group group);
|
||||
|
||||
/**
|
||||
* Creates a node builder from a group
|
||||
*
|
||||
* @param groupName the name of the group
|
||||
* @return a node builder instance
|
||||
* @throws NullPointerException if the groupName is null
|
||||
* @since 4.0
|
||||
*/
|
||||
Node.@NonNull Builder makeGroupNode(@NonNull String groupName);
|
||||
|
||||
/**
|
||||
* Creates a node builder from a key value pair
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @return a node builder instance
|
||||
* @throws NullPointerException if the key or value is null
|
||||
*/
|
||||
Node.@NonNull Builder makeMetaNode(@NonNull String key, @NonNull String value);
|
||||
|
||||
/**
|
||||
* Creates a node builder for the given chat meta type
|
||||
*
|
||||
* @param type the type
|
||||
* @param priority the priority
|
||||
* @param value the value for the prefix/suffix
|
||||
* @return a node builder instance
|
||||
* @throws NullPointerException if the type or value is null
|
||||
* @since 3.2
|
||||
*/
|
||||
Node.@NonNull Builder makeChatMetaNode(@NonNull ChatMetaType type, int priority, @NonNull String value);
|
||||
|
||||
/**
|
||||
* Creates a node builder from a prefix string and priority
|
||||
*
|
||||
* @param priority the priority
|
||||
* @param prefix the prefix string
|
||||
* @return a node builder instance
|
||||
* @throws NullPointerException if the prefix is null
|
||||
*/
|
||||
Node.@NonNull Builder makePrefixNode(int priority, @NonNull String prefix);
|
||||
|
||||
/**
|
||||
* Creates a node builder from a prefix string and priority
|
||||
*
|
||||
* @param priority the priority
|
||||
* @param suffix the suffix string
|
||||
* @return a node builder instance
|
||||
* @throws NullPointerException if the suffix is null
|
||||
*/
|
||||
Node.@NonNull Builder makeSuffixNode(int priority, @NonNull String suffix);
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import me.lucko.luckperms.api.manager.UserManager;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Encapsulates the result of an operation to save uuid data about a player.
|
||||
*
|
||||
* <p>The corresponding method can be found at
|
||||
* {@link UserManager#savePlayerData(UUID, String)}.</p>
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public interface PlayerSaveResult {
|
||||
|
||||
/**
|
||||
* Gets the status returned by the operation
|
||||
*
|
||||
* @return the status
|
||||
*/
|
||||
@NonNull Set<Status> getStatus();
|
||||
|
||||
/**
|
||||
* Gets if the result includes a certain status code.
|
||||
*
|
||||
* @param status the status to check for
|
||||
* @return if the result includes the status
|
||||
*/
|
||||
default boolean includes(@NonNull Status status) {
|
||||
Objects.requireNonNull(status, "status");
|
||||
return getStatus().contains(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the old username involved in the result.
|
||||
*
|
||||
* <p>Returns null when the result doesn't {@link #includes(Status) include} the
|
||||
* {@link Status#USERNAME_UPDATED} status.</p>
|
||||
*
|
||||
* @return the old username
|
||||
* @see Status#USERNAME_UPDATED
|
||||
*/
|
||||
@Nullable String getOldUsername();
|
||||
|
||||
/**
|
||||
* Gets the other uuids involved in the result.
|
||||
*
|
||||
* <p>Returns null when the result doesn't {@link #includes(Status) include} the
|
||||
* {@link Status#OTHER_UUIDS_PRESENT_FOR_USERNAME} status.</p>
|
||||
*
|
||||
* @return the other uuids
|
||||
* @see Status#OTHER_UUIDS_PRESENT_FOR_USERNAME
|
||||
*/
|
||||
@Nullable Set<UUID> getOtherUuids();
|
||||
|
||||
/**
|
||||
* The various states the result can take
|
||||
*/
|
||||
enum Status {
|
||||
|
||||
/**
|
||||
* There was no existing data saved for either the uuid or username
|
||||
*/
|
||||
CLEAN_INSERT,
|
||||
|
||||
/**
|
||||
* There was existing data for the player, no change was needed.
|
||||
*/
|
||||
NO_CHANGE,
|
||||
|
||||
/**
|
||||
* There was already a record for the UUID saved, but it was for a different username.
|
||||
*
|
||||
* <p>This is normal, players are able to change their usernames.</p>
|
||||
*/
|
||||
USERNAME_UPDATED,
|
||||
|
||||
/**
|
||||
* There was already a record for the username saved, but it was under a different uuid.
|
||||
*
|
||||
* <p>This is a bit of a cause for concern. It's possible that "player1" has changed
|
||||
* their username to "player2", and "player3" has changed their username to "player1".
|
||||
* If the original "player1" doesn't join after changing their name, this conflict could
|
||||
* occur.</p>
|
||||
*
|
||||
* <p>However, what's more likely is that the server is not setup to authenticate
|
||||
* correctly. Usually this is a problem with BungeeCord "ip-forwarding", but could be
|
||||
* that the user of the plugin is running a network off a shared database with one
|
||||
* server in online mode and another in offline mode.</p>
|
||||
*/
|
||||
OTHER_UUIDS_PRESENT_FOR_USERNAME,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Encapsulates the result of {@link User}s promotion along a {@link Track}.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public interface PromotionResult extends MutateResult {
|
||||
|
||||
/**
|
||||
* Gets the status of the result.
|
||||
*
|
||||
* @return the status
|
||||
*/
|
||||
@NonNull Status getStatus();
|
||||
|
||||
@Override
|
||||
default boolean wasSuccess() {
|
||||
return getStatus().wasSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the group the user was promoted from, if applicable.
|
||||
*
|
||||
* <p>Will only be present for results with a {@link #getStatus() status} of
|
||||
* {@link Status#SUCCESS}.</p>
|
||||
*
|
||||
* @return the group the user was promoted from.
|
||||
*/
|
||||
@NonNull Optional<String> getGroupFrom();
|
||||
|
||||
/**
|
||||
* Gets the name of the group the user was promoted from, if applicable.
|
||||
*
|
||||
* <p>Will only be present for results with a {@link #getStatus() status} of
|
||||
* {@link Status#SUCCESS} or {@link Status#ADDED_TO_FIRST_GROUP}.</p>
|
||||
*
|
||||
* <p>The value will also be set for results with the {@link Status#MALFORMED_TRACK} status,
|
||||
* with this value marking the group which no longer exists.</p>
|
||||
*
|
||||
* @return the group the user was promoted to.
|
||||
*/
|
||||
@NonNull Optional<String> getGroupTo();
|
||||
|
||||
/**
|
||||
* The result status
|
||||
*/
|
||||
enum Status implements MutateResult {
|
||||
|
||||
/**
|
||||
* Indicates that the user was promoted normally.
|
||||
*/
|
||||
SUCCESS(true),
|
||||
|
||||
/**
|
||||
* Indicates that the user was added to the first group in the track.
|
||||
*
|
||||
* <p>This usually occurs when the user isn't already on any of the groups in the track.</p>
|
||||
*/
|
||||
ADDED_TO_FIRST_GROUP(true),
|
||||
|
||||
/**
|
||||
* Indicates that the next group in the track no longer exists.
|
||||
*/
|
||||
MALFORMED_TRACK(false),
|
||||
|
||||
/**
|
||||
* Indicates that the user is already a member of the group at the end of the track,
|
||||
* and as such cannot be promoted any further.
|
||||
*/
|
||||
END_OF_TRACK(false),
|
||||
|
||||
/**
|
||||
* Indicates that the implementation was unable to determine the users current position on
|
||||
* this track.
|
||||
*
|
||||
* <p>This usually occurs when the user is on more than one group on the track.</p>
|
||||
*/
|
||||
AMBIGUOUS_CALL(false),
|
||||
|
||||
/**
|
||||
* An undefined failure occurred.
|
||||
*/
|
||||
UNDEFINED_FAILURE(false);
|
||||
|
||||
private final boolean success;
|
||||
|
||||
Status(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wasSuccess() {
|
||||
return this.success;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Standard {@link NodeEqualityPredicate}s.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public enum StandardNodeEquality implements NodeEqualityPredicate {
|
||||
|
||||
/**
|
||||
* Represents an exact match.
|
||||
*
|
||||
* <p>All attributes of the nodes must match for them to be considered
|
||||
* equal.</p>
|
||||
*/
|
||||
EXACT,
|
||||
|
||||
/**
|
||||
* All attributes must match, except for
|
||||
* {@link Node#getValue() value}, which is ignored.
|
||||
*/
|
||||
IGNORE_VALUE,
|
||||
|
||||
/**
|
||||
* All attributes must match, except for the
|
||||
* {@link Node#getExpiry() expiry time}, which is ignored.
|
||||
*
|
||||
* <p>Note that with this setting, whether a node is temporary or not is
|
||||
* still considered.</p>
|
||||
*/
|
||||
IGNORE_EXPIRY_TIME,
|
||||
|
||||
/**
|
||||
* All attributes must match, except for
|
||||
* {@link Node#getValue() value} and the
|
||||
* {@link Node#getExpiry() expiry time}, which are ignored.
|
||||
*/
|
||||
IGNORE_EXPIRY_TIME_AND_VALUE,
|
||||
|
||||
/**
|
||||
* All attributes must match, except for
|
||||
* {@link Node#getValue() value} and the if the node is
|
||||
* {@link Node#isTemporary() temporary}, which are ignored.
|
||||
*/
|
||||
IGNORE_VALUE_OR_IF_TEMPORARY;
|
||||
|
||||
@Override
|
||||
public boolean areEqual(@NonNull Node o1, @NonNull Node o2) {
|
||||
return o1.equals(o2, this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import me.lucko.luckperms.api.manager.GroupManager;
|
||||
import me.lucko.luckperms.api.manager.TrackManager;
|
||||
import me.lucko.luckperms.api.manager.UserManager;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* A means of loading and saving permission data to/from the backend.
|
||||
*
|
||||
* @since 2.14
|
||||
*/
|
||||
public interface Storage {
|
||||
|
||||
/**
|
||||
* Get the name of the storage implementation.
|
||||
*
|
||||
* @return the name of the implementation
|
||||
*/
|
||||
@NonNull String getName();
|
||||
|
||||
/**
|
||||
* Gets whether the storage instance is allowing logins on the platform.
|
||||
*
|
||||
* @return true if logins are enabled
|
||||
* @deprecated as this method always returns true.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean isAcceptingLogins();
|
||||
|
||||
/**
|
||||
* Saves an action to storage
|
||||
*
|
||||
* @param entry the log entry to be saved
|
||||
* @return true if the operation completed successfully.
|
||||
* @throws NullPointerException if entry is null
|
||||
* @deprecated in favour of {@link ActionLogger#submit(LogEntry)}.
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<Boolean> logAction(@NonNull LogEntry entry);
|
||||
|
||||
/**
|
||||
* Loads and returns the entire log from storage
|
||||
*
|
||||
* @return a log instance, could be null if loading failed
|
||||
* @deprecated in favour of {@link ActionLogger#getLog()}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<Log> getLog();
|
||||
|
||||
/**
|
||||
* Loads a user's data from the main storage into the plugins local storage.
|
||||
*
|
||||
* @param uuid the uuid of the user to load
|
||||
* @param username the users username, or null if it is not known.
|
||||
* @return if the operation completed successfully
|
||||
* @throws NullPointerException if uuid is null
|
||||
* @deprecated in favour of {@link UserManager#loadUser(UUID, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<Boolean> loadUser(@NonNull UUID uuid, @Nullable String username);
|
||||
|
||||
/**
|
||||
* Loads a user's data from the main storage into the plugins local storage.
|
||||
*
|
||||
* @param uuid the uuid of the user to load
|
||||
* @return if the operation completed successfully
|
||||
* @throws NullPointerException if uuid is null
|
||||
* @deprecated in favour of {@link UserManager#loadUser(UUID)}
|
||||
*/
|
||||
@Deprecated
|
||||
default @NonNull CompletableFuture<Boolean> loadUser(@NonNull UUID uuid) {
|
||||
return loadUser(uuid, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a user object back to storage.
|
||||
*
|
||||
* <p>You should call this after you make any changes to a user.</p>
|
||||
*
|
||||
* @param user the user to save
|
||||
* @return true if the operation completed successfully.
|
||||
* @throws NullPointerException if user is null
|
||||
* @throws IllegalStateException if the user instance was not obtained from LuckPerms.
|
||||
* @deprecated in favour of {@link UserManager#saveUser(User)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<Boolean> saveUser(@NonNull User user);
|
||||
|
||||
/**
|
||||
* Gets a set all "unique" user UUIDs.
|
||||
*
|
||||
* <p>"Unique" meaning the user isn't just a member of the "default" group.</p>
|
||||
*
|
||||
* @return a set of uuids, or null if the operation failed.
|
||||
* @deprecated in favour of {@link UserManager#getUniqueUsers()}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<Set<UUID>> getUniqueUsers();
|
||||
|
||||
/**
|
||||
* Searches for a list of users with a given permission.
|
||||
*
|
||||
* @param permission the permission to search for
|
||||
* @return a list of held permissions, or null if the operation failed
|
||||
* @throws NullPointerException if the permission is null
|
||||
* @since 2.17
|
||||
* @deprecated in favour of {@link UserManager#getWithPermission(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(@NonNull String permission);
|
||||
|
||||
/**
|
||||
* Creates and loads a group into the plugins local storage
|
||||
*
|
||||
* @param name the name of the group
|
||||
* @return true if the operation completed successfully
|
||||
* @throws NullPointerException if name is null
|
||||
* @throws IllegalArgumentException if the name is invalid
|
||||
* @deprecated in favour of {@link GroupManager#createAndLoadGroup(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<Boolean> createAndLoadGroup(@NonNull String name);
|
||||
|
||||
/**
|
||||
* Loads a group into the plugins local storage.
|
||||
*
|
||||
* @param name the name of the group
|
||||
* @return true if the operation completed successfully
|
||||
* @throws NullPointerException if name is null
|
||||
* @throws IllegalArgumentException if the name is invalid
|
||||
* @deprecated in favour of {@link GroupManager#loadGroup(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<Boolean> loadGroup(@NonNull String name);
|
||||
|
||||
/**
|
||||
* Loads all groups from the storage into memory
|
||||
*
|
||||
* @return true if the operation completed successfully.
|
||||
* @deprecated in favour of {@link GroupManager#loadAllGroups()}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<Boolean> loadAllGroups();
|
||||
|
||||
/**
|
||||
* Saves a group back to storage.
|
||||
*
|
||||
* <p>You should call this after you make any changes to a group.</p>
|
||||
*
|
||||
* @param group the group to save
|
||||
* @return true if the operation completed successfully.
|
||||
* @throws NullPointerException if group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @deprecated in favour of {@link GroupManager#saveGroup(Group)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<Boolean> saveGroup(@NonNull Group group);
|
||||
|
||||
/**
|
||||
* Permanently deletes a group from storage.
|
||||
*
|
||||
* @param group the group to delete
|
||||
* @return true if the operation completed successfully.
|
||||
* @throws NullPointerException if group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @deprecated in favour of {@link GroupManager#deleteGroup(Group)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<Boolean> deleteGroup(@NonNull Group group);
|
||||
|
||||
/**
|
||||
* Searches for a list of groups with a given permission.
|
||||
*
|
||||
* @param permission the permission to search for
|
||||
* @return a list of held permissions, or null if the operation failed
|
||||
* @throws NullPointerException if the permission is null
|
||||
* @since 2.17
|
||||
* @deprecated in favour of {@link GroupManager#getWithPermission(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(@NonNull String permission);
|
||||
|
||||
/**
|
||||
* Creates and loads a track into the plugins local storage
|
||||
*
|
||||
* @param name the name of the track
|
||||
* @return true if the operation completed successfully
|
||||
* @throws NullPointerException if name is null
|
||||
* @throws IllegalArgumentException if the name is invalid
|
||||
* @deprecated in favour of {@link TrackManager#createAndLoadTrack(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<Boolean> createAndLoadTrack(@NonNull String name);
|
||||
|
||||
/**
|
||||
* Loads a track into the plugins local storage.
|
||||
*
|
||||
* @param name the name of the track
|
||||
* @return true if the operation completed successfully
|
||||
* @throws NullPointerException if name is null
|
||||
* @throws IllegalArgumentException if the name is invalid
|
||||
* @deprecated in favour of {@link TrackManager#loadTrack(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<Boolean> loadTrack(@NonNull String name);
|
||||
|
||||
/**
|
||||
* Loads all tracks from the storage into memory
|
||||
*
|
||||
* @return true if the operation completed successfully.
|
||||
* @deprecated in favour of {@link TrackManager#loadAllTracks()}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<Boolean> loadAllTracks();
|
||||
|
||||
/**
|
||||
* Saves a track back to storage. You should call this after you make any changes to a track.
|
||||
*
|
||||
* @param track the track to save
|
||||
* @return true if the operation completed successfully.
|
||||
* @throws NullPointerException if track is null
|
||||
* @throws IllegalStateException if the track instance was not obtained from LuckPerms.
|
||||
* @deprecated in favour of {@link TrackManager#saveTrack(Track)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<Boolean> saveTrack(@NonNull Track track);
|
||||
|
||||
/**
|
||||
* Permanently deletes a track from storage
|
||||
*
|
||||
* @param track the track to delete
|
||||
* @return true if the operation completed successfully.
|
||||
* @throws NullPointerException if track is null
|
||||
* @throws IllegalStateException if the track instance was not obtained from LuckPerms.
|
||||
* @deprecated in favour of {@link TrackManager#deleteTrack(Track)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull CompletableFuture<Boolean> deleteTrack(@NonNull Track track);
|
||||
|
||||
/**
|
||||
* Saves UUID caching data to the global cache
|
||||
*
|
||||
* @param username the users username
|
||||
* @param uuid the users mojang unique id
|
||||
* @return true if the operation completed successfully.
|
||||
* @throws NullPointerException if either parameters are null
|
||||
* @throws IllegalArgumentException if the username is invalid
|
||||
* @deprecated in favour of {@link UserManager#savePlayerData(UUID, String)}
|
||||
*/
|
||||
@NonNull CompletableFuture<Boolean> saveUUIDData(@NonNull String username, @NonNull UUID uuid);
|
||||
|
||||
/**
|
||||
* Gets a UUID from a username
|
||||
*
|
||||
* @param username the corresponding username
|
||||
* @return a uuid object, could be null
|
||||
* @throws NullPointerException if either parameters are null
|
||||
* @throws IllegalArgumentException if the username is invalid
|
||||
* @deprecated in favour of {@link UserManager#lookupUuid(String)}
|
||||
*/
|
||||
@NonNull CompletableFuture<UUID> getUUID(@NonNull String username);
|
||||
|
||||
/**
|
||||
* Gets a username from a UUID
|
||||
*
|
||||
* @param uuid the corresponding uuid
|
||||
* @return a name string, could be null
|
||||
* @throws NullPointerException if either parameters are null
|
||||
* @since 2.17
|
||||
* @deprecated in favour of {@link UserManager#lookupUsername(UUID)}
|
||||
*/
|
||||
@NonNull @Deprecated CompletableFuture<String> getName(@NonNull UUID uuid);
|
||||
|
||||
/**
|
||||
* Returns an executor which will run all passed runnables on the
|
||||
* main server thread.
|
||||
*
|
||||
* <p>This method is deprecated as plugins should create and use their own
|
||||
* executor instances.</p>
|
||||
*
|
||||
* @return an executor instance
|
||||
* @deprecated as plugins should create their own executors
|
||||
*/
|
||||
@NonNull @Deprecated Executor getSyncExecutor();
|
||||
|
||||
/**
|
||||
* Returns an executor which will run all passed runnables asynchronously
|
||||
* using the platforms scheduler and thread pools.
|
||||
*
|
||||
* <p>This method is deprecated as plugins should create and use their own
|
||||
* executor instances.</p>
|
||||
*
|
||||
* @return an executor instance
|
||||
* @deprecated as plugins should create their own executors
|
||||
*/
|
||||
@NonNull @Deprecated Executor getAsyncExecutor();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Extension of {@link DataMutateResult} for temporary set operations.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public interface TemporaryDataMutateResult {
|
||||
|
||||
/**
|
||||
* Gets the underlying result.
|
||||
*
|
||||
* @return the result
|
||||
*/
|
||||
@NonNull DataMutateResult getResult();
|
||||
|
||||
/**
|
||||
* Gets the node that resulted from any {@link TemporaryMergeBehaviour}
|
||||
* processing.
|
||||
*
|
||||
* <p>If no processing took place, the same instance will be returned by
|
||||
* this method.</p>
|
||||
*
|
||||
* @return the resultant node
|
||||
*/
|
||||
@NonNull Node getMergedNode();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
/**
|
||||
* Controls how the implementation should behave when new temporary nodes are set
|
||||
* that would otherwise conflict with existing entries.
|
||||
*
|
||||
* <p>The default behaviour of {@link PermissionHolder#setPermission(Node)} is
|
||||
* to return a result of {@link DataMutateResult#ALREADY_HAS} when an equivalent
|
||||
* node is found. This can be replicated using {@link #FAIL_WITH_ALREADY_HAS}.</p>
|
||||
*
|
||||
* <p>However, the {@link PermissionHolder#setPermission(Node, TemporaryMergeBehaviour)}
|
||||
* method allows this behaviour to be customized for temporary permissions.</p>
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public enum TemporaryMergeBehaviour {
|
||||
|
||||
/**
|
||||
* Expiry durations will be added to the existing expiry time of a permission.
|
||||
*/
|
||||
ADD_NEW_DURATION_TO_EXISTING,
|
||||
|
||||
/**
|
||||
* Expiry durations will be replaced if the new duration is longer than the current one.
|
||||
*/
|
||||
REPLACE_EXISTING_IF_DURATION_LONGER,
|
||||
|
||||
/**
|
||||
* The operation will fail if an existing temporary node is present.
|
||||
*/
|
||||
FAIL_WITH_ALREADY_HAS
|
||||
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,111 +25,149 @@
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import me.lucko.luckperms.api.context.ContextSet;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Interface for internal Track instances
|
||||
* An ordered chain of {@link Group}s.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public interface Track {
|
||||
|
||||
/**
|
||||
* Gets the name of this track
|
||||
*
|
||||
* @return the name of this track
|
||||
*/
|
||||
String getName();
|
||||
@NonNull String getName();
|
||||
|
||||
/**
|
||||
* Gets an ordered list of the groups on this track
|
||||
* Index 0 is the first/lowest group in (or start of) the track
|
||||
* Gets a list of the groups on this track
|
||||
*
|
||||
* <p>Index 0 is the first/lowest group in (or start of) the track.</p>
|
||||
*
|
||||
* <p>The returned collection is immutable, and cannot be modified.</p>
|
||||
*
|
||||
* @return an ordered {@link List} of the groups on this track
|
||||
*/
|
||||
List<String> getGroups();
|
||||
@NonNull List<String> getGroups();
|
||||
|
||||
/**
|
||||
* Gets the number of groups on this track
|
||||
*
|
||||
* @return the number of groups on this track
|
||||
*/
|
||||
int getSize();
|
||||
|
||||
/**
|
||||
* Gets the next group on the track, after the one provided
|
||||
*
|
||||
* <p>{@code null} is returned if the group is not on the track.</p>
|
||||
*
|
||||
* @param current the group before the group being requested
|
||||
* @return the group name, or null if the end of the track has been reached
|
||||
* @throws ObjectLacksException if the track does not contain the group given
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
*/
|
||||
String getNext(Group current) throws ObjectLacksException;
|
||||
@Nullable String getNext(@NonNull Group current);
|
||||
|
||||
/**
|
||||
* Gets the previous group on the track, before the one provided
|
||||
*
|
||||
* <p>{@code null} is returned if the group is not on the track.</p>
|
||||
*
|
||||
* @param current the group after the group being requested
|
||||
* @return the group name, or null if the start of the track has been reached
|
||||
* @throws ObjectLacksException if the track does not contain the group given
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
*/
|
||||
String getPrevious(Group current) throws ObjectLacksException;
|
||||
@Nullable String getPrevious(@NonNull Group current);
|
||||
|
||||
/**
|
||||
* Promotes the given user along this track.
|
||||
*
|
||||
* @param user the user to promote
|
||||
* @param contextSet the contexts to promote the user in
|
||||
* @return the result of the action
|
||||
* @since 4.2
|
||||
*/
|
||||
@NonNull PromotionResult promote(@NonNull User user, @NonNull ContextSet contextSet);
|
||||
|
||||
/**
|
||||
* Demotes the given user along this track.
|
||||
*
|
||||
* @param user the user to demote
|
||||
* @param contextSet the contexts to demote the user in
|
||||
* @return the result of the action
|
||||
* @since 4.2
|
||||
*/
|
||||
@NonNull DemotionResult demote(@NonNull User user, @NonNull ContextSet contextSet);
|
||||
|
||||
/**
|
||||
* Appends a group to the end of this track
|
||||
*
|
||||
* @param group the group to append
|
||||
* @throws ObjectAlreadyHasException if the group is already on this track somewhere
|
||||
* @throws NullPointerException if the group is null
|
||||
* @return the result of the operation
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
*/
|
||||
void appendGroup(Group group) throws ObjectAlreadyHasException;
|
||||
@NonNull DataMutateResult appendGroup(@NonNull Group group);
|
||||
|
||||
/**
|
||||
* Inserts a group at a certain position on this track
|
||||
* @param group the group to be inserted
|
||||
*
|
||||
* @param group the group to be inserted
|
||||
* @param position the index position (a value of 0 inserts at the start)
|
||||
* @throws ObjectAlreadyHasException if the group is already on this track somewhere
|
||||
* @return the result of the operation
|
||||
* @throws IndexOutOfBoundsException if the position is less than 0 or greater than the size of the track
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
*/
|
||||
void insertGroup(Group group, int position) throws ObjectAlreadyHasException, IndexOutOfBoundsException;
|
||||
@NonNull DataMutateResult insertGroup(@NonNull Group group, int position) throws IndexOutOfBoundsException;
|
||||
|
||||
/**
|
||||
* Removes a group from this track
|
||||
*
|
||||
* @param group the group to remove
|
||||
* @throws ObjectLacksException if the group is not on this track
|
||||
* @throws NullPointerException if the group is null
|
||||
* @return the result of the operation
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
*/
|
||||
void removeGroup(Group group) throws ObjectLacksException;
|
||||
@NonNull DataMutateResult removeGroup(@NonNull Group group);
|
||||
|
||||
/**
|
||||
* Removes a group from this track
|
||||
*
|
||||
* @param group the group to remove
|
||||
* @throws ObjectLacksException if the group is not on this track
|
||||
* @return the result of the operation
|
||||
* @throws NullPointerException if the group is null
|
||||
*/
|
||||
void removeGroup(String group) throws ObjectLacksException;
|
||||
@NonNull DataMutateResult removeGroup(@NonNull String group);
|
||||
|
||||
/**
|
||||
* Checks if a group features on this track
|
||||
*
|
||||
* @param group the group to check
|
||||
* @return true if the group is on this track
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
*/
|
||||
boolean containsGroup(Group group);
|
||||
boolean containsGroup(@NonNull Group group);
|
||||
|
||||
/**
|
||||
* Checks if a group features on this track
|
||||
*
|
||||
* @param group the group to check
|
||||
* @return true if the group is on this track
|
||||
* @throws NullPointerException if the group is null
|
||||
*/
|
||||
boolean containsGroup(String group);
|
||||
boolean containsGroup(@NonNull String group);
|
||||
|
||||
/**
|
||||
* Clear all of the groups within this track
|
||||
* Clear all of the groups from this track
|
||||
*/
|
||||
void clearGroups();
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,26 +25,75 @@
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Represents a permission value
|
||||
* Represents three different states of a setting.
|
||||
*
|
||||
* <p>Possible values:</p>
|
||||
* <p></p>
|
||||
* <ul>
|
||||
* <li>{@link #TRUE} - a positive setting</li>
|
||||
* <li>{@link #FALSE} - a negative (negated) setting</li>
|
||||
* <li>{@link #UNDEFINED} - a non-existent setting</li>
|
||||
* </ul>
|
||||
*/
|
||||
public enum Tristate {
|
||||
|
||||
/**
|
||||
* A value indicating a positive setting
|
||||
*/
|
||||
TRUE(true),
|
||||
|
||||
/**
|
||||
* A value indicating a negative (negated) setting
|
||||
*/
|
||||
FALSE(false),
|
||||
|
||||
/**
|
||||
* A value indicating a non-existent setting
|
||||
*/
|
||||
UNDEFINED(false);
|
||||
|
||||
/**
|
||||
* Returns a {@link Tristate} from a boolean
|
||||
*
|
||||
* @param val the boolean value
|
||||
* @return {@link #TRUE} or {@link #FALSE}, if the value is <code>true</code> or <code>false</code>, respectively.
|
||||
*/
|
||||
public static @NonNull Tristate fromBoolean(boolean val) {
|
||||
return val ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link Tristate} from a nullable boolean.
|
||||
*
|
||||
* <p>Unlike {@link #fromBoolean(boolean)}, this method returns {@link #UNDEFINED}
|
||||
* if the value is null.</p>
|
||||
*
|
||||
* @param val the boolean value
|
||||
* @return {@link #UNDEFINED}, {@link #TRUE} or {@link #FALSE}, if the value
|
||||
* is <code>null</code>, <code>true</code> or <code>false</code>, respectively.
|
||||
* @since 4.1
|
||||
*/
|
||||
public static @NonNull Tristate fromNullableBoolean(Boolean val) {
|
||||
return val == null ? UNDEFINED : val ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
private final boolean booleanValue;
|
||||
|
||||
Tristate(boolean booleanValue) {
|
||||
this.booleanValue = booleanValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the Tristate as a boolean.
|
||||
*
|
||||
* <p>A value of {@link #UNDEFINED} converts to false.</p>
|
||||
*
|
||||
* @return a boolean representation of the Tristate.
|
||||
*/
|
||||
public boolean asBoolean() {
|
||||
return booleanValue;
|
||||
}
|
||||
|
||||
public static Tristate fromBoolean(boolean b) {
|
||||
return b ? TRUE : FALSE;
|
||||
return this.booleanValue;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,240 +25,84 @@
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import me.lucko.luckperms.api.caching.UserData;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Interface for internal User instances
|
||||
* A player which holds permission data.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public interface User extends PermissionHolder {
|
||||
|
||||
/**
|
||||
* Gets the users unique ID
|
||||
*
|
||||
* @return the users Mojang assigned unique id
|
||||
*/
|
||||
UUID getUuid();
|
||||
@NonNull UUID getUuid();
|
||||
|
||||
/**
|
||||
* @return the Users Username
|
||||
* Gets the users username
|
||||
*
|
||||
* <p>Returns null if no username is known for the user.</p>
|
||||
*
|
||||
* @return the users username
|
||||
*/
|
||||
String getName();
|
||||
@Nullable String getName();
|
||||
|
||||
/**
|
||||
* Gets the users primary group
|
||||
* Gets the users current primary group.
|
||||
*
|
||||
* <p>The result of this method depends on which method is configured for primary group
|
||||
* calculation. It may not be the same as any value set through
|
||||
* {@link #setPrimaryGroup(String)}.</p>
|
||||
*
|
||||
* @return the users primary group
|
||||
*/
|
||||
String getPrimaryGroup();
|
||||
@NonNull String getPrimaryGroup();
|
||||
|
||||
/**
|
||||
* Sets a users primary group
|
||||
* Sets a users primary group.
|
||||
*
|
||||
* <p>This modifies the "stored value" for the users primary group, which may or may not
|
||||
* actually take effect, depending on how the platform is calculating primary groups.</p>
|
||||
*
|
||||
* @param group the new primary group
|
||||
* @throws ObjectAlreadyHasException if the user already has this set as their primary group
|
||||
* @return if the change was applied successfully
|
||||
* @throws IllegalStateException if the user is not a member of that group
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws NullPointerException if the group is null
|
||||
*/
|
||||
void setPrimaryGroup(String group) throws ObjectAlreadyHasException;
|
||||
@NonNull DataMutateResult setPrimaryGroup(@NonNull String group);
|
||||
|
||||
/**
|
||||
* Refresh and re-assign the users permissions
|
||||
* Gets the user's {@link UserData} cache.
|
||||
*
|
||||
* @return the users cached data.
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
@NonNull UserData getCachedData();
|
||||
|
||||
/**
|
||||
* Refresh and re-assign the users permissions.
|
||||
*
|
||||
* @deprecated Calling this method is no longer necessary. Permissions data is now refreshed on
|
||||
* demand, as changes are made. Consider use of {@link #refreshCachedData()}
|
||||
* instead. This method is now implemented as a no-op.
|
||||
*/
|
||||
@Deprecated
|
||||
void refreshPermissions();
|
||||
|
||||
/**
|
||||
* Check to see if the user is a member of a group
|
||||
* @param group The group to check membership of
|
||||
* @return true if the user is a member of the group
|
||||
* @throws NullPointerException if the group is null
|
||||
* Pre-calculates some values in the user's data cache.
|
||||
*
|
||||
* @since 2.17
|
||||
* @deprecated Use of this method is no longer necessary. It is implemented as a no-op.
|
||||
*/
|
||||
boolean isInGroup(Group group);
|
||||
|
||||
/**
|
||||
* Check to see if a user is a member of a group on a specific server
|
||||
* @param group The group to check membership of
|
||||
* @param server The server to check on
|
||||
* @return true if the user is a member of the group
|
||||
* @throws NullPointerException if the group or server is null
|
||||
* @throws IllegalArgumentException if the server is invalid
|
||||
*/
|
||||
boolean isInGroup(Group group, String server);
|
||||
|
||||
/**
|
||||
* Check to see if a user is a member of a group on a specific server and world
|
||||
* @param group The group to check membership of
|
||||
* @param server The server to check on
|
||||
* @param world The world to check on
|
||||
* @return true if the user is a member of the group
|
||||
* @throws NullPointerException if the group, server or world is null
|
||||
* @throws IllegalArgumentException if the server or world is invalid
|
||||
*/
|
||||
boolean isInGroup(Group group, String server, String world);
|
||||
|
||||
/**
|
||||
* Add a user to a group
|
||||
* @param group The group to add the user to
|
||||
* @throws ObjectAlreadyHasException if the user is already a member of the group
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
*/
|
||||
void addGroup(Group group) throws ObjectAlreadyHasException;
|
||||
|
||||
/**
|
||||
* Add a user to a group on a specific server
|
||||
* @param group The group to add the user to
|
||||
* @param server The server to add the group on
|
||||
* @throws ObjectAlreadyHasException if the user is already a member of the group on that server
|
||||
* @throws NullPointerException if the group or server is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the server is invalid
|
||||
*/
|
||||
void addGroup(Group group, String server) throws ObjectAlreadyHasException;
|
||||
|
||||
/**
|
||||
* Add a user to a group on a specific server and world
|
||||
* @param group The group to add the user to
|
||||
* @param server The server to add the group on
|
||||
* @param world The world to add the group on
|
||||
* @throws ObjectAlreadyHasException if the user is already a member of the group on that server
|
||||
* @throws NullPointerException if the group, server or world is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the server or world is invalid
|
||||
*/
|
||||
void addGroup(Group group, String server, String world) throws ObjectAlreadyHasException;
|
||||
|
||||
/**
|
||||
* Add a user to a group temporarily on a specific server
|
||||
* @param group The group to add the user to
|
||||
* @param expireAt when the group should expire
|
||||
* @throws ObjectAlreadyHasException if the user is already a member of the group on that server
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the expiry time is in the past
|
||||
*/
|
||||
void addGroup(Group group, long expireAt) throws ObjectAlreadyHasException;
|
||||
|
||||
/**
|
||||
* Add a user to a group temporarily on a specific server
|
||||
* @param group The group to add the user to
|
||||
* @param server The server to add the group on
|
||||
* @param expireAt when the group should expire
|
||||
* @throws ObjectAlreadyHasException if the user is already a member of the group on that server
|
||||
* @throws NullPointerException if the group or server is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the expiry time is in the past or the server is invalid
|
||||
*/
|
||||
void addGroup(Group group, String server, long expireAt) throws ObjectAlreadyHasException;
|
||||
|
||||
/**
|
||||
* Add a user to a group temporarily on a specific server and world
|
||||
* @param group The group to add the user to
|
||||
* @param server The server to add the group on
|
||||
* @param world The world to add the group on
|
||||
* @param expireAt when the group should expire
|
||||
* @throws ObjectAlreadyHasException if the user is already a member of the group on that server
|
||||
* @throws NullPointerException if the group, server or world is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the expiry time is in the past or the server/world is invalid
|
||||
*/
|
||||
void addGroup(Group group, String server, String world, long expireAt) throws ObjectAlreadyHasException;
|
||||
|
||||
/**
|
||||
* Remove the user from a group
|
||||
* @param group the group to remove the user from
|
||||
* @throws ObjectLacksException if the user isn't a member of the group
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
*/
|
||||
void removeGroup(Group group) throws ObjectLacksException;
|
||||
|
||||
/**
|
||||
* Remove the user from a group
|
||||
* @param group the group to remove the user from
|
||||
* @param temporary if the group being removed is temporary
|
||||
* @throws ObjectLacksException if the user isn't a member of the group
|
||||
* @throws NullPointerException if the group is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
*/
|
||||
void removeGroup(Group group, boolean temporary) throws ObjectLacksException;
|
||||
|
||||
/**
|
||||
* Remove the user from a group on a specific server
|
||||
* @param group The group to remove the user from
|
||||
* @param server The server to remove the group on
|
||||
* @throws ObjectLacksException if the user isn't a member of the group
|
||||
* @throws NullPointerException if the group or server is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the server is invalid
|
||||
*/
|
||||
void removeGroup(Group group, String server) throws ObjectLacksException;
|
||||
|
||||
/**
|
||||
* Remove the user from a group on a specific server and world
|
||||
* @param group The group to remove the user from
|
||||
* @param server The server to remove the group on
|
||||
* @param world The world to remove the group on
|
||||
* @throws ObjectLacksException if the user isn't a member of the group
|
||||
* @throws NullPointerException if the group, server or world is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the server or world is invalid
|
||||
*/
|
||||
void removeGroup(Group group, String server, String world) throws ObjectLacksException;
|
||||
|
||||
/**
|
||||
* Remove the user from a group on a specific server
|
||||
* @param group The group to remove the user from
|
||||
* @param server The server to remove the group on
|
||||
* @param temporary if the group being removed is temporary
|
||||
* @throws ObjectLacksException if the user isn't a member of the group
|
||||
* @throws NullPointerException if the group or server is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the expiry time is in the past or the server is invalid
|
||||
*/
|
||||
void removeGroup(Group group, String server, boolean temporary) throws ObjectLacksException;
|
||||
|
||||
/**
|
||||
* Remove the user from a group on a specific server and world
|
||||
* @param group The group to remove the user from
|
||||
* @param server The server to remove the group on
|
||||
* @param world The world to remove the group on
|
||||
* @param temporary if the group being removed is temporary
|
||||
* @throws ObjectLacksException if the user isn't a member of the group
|
||||
* @throws NullPointerException if the group, server or world is null
|
||||
* @throws IllegalStateException if the group instance was not obtained from LuckPerms.
|
||||
* @throws IllegalArgumentException if the expiry time is in the past or the server/world is invalid
|
||||
*/
|
||||
void removeGroup(Group group, String server, String world, boolean temporary) throws ObjectLacksException;
|
||||
|
||||
/**
|
||||
* Clear all of the users permission nodes
|
||||
*/
|
||||
void clearNodes();
|
||||
|
||||
/**
|
||||
* Get a {@link List} of all of the groups the user is a member of, on all servers
|
||||
* @return a {@link List} of group names
|
||||
*/
|
||||
List<String> getGroupNames();
|
||||
|
||||
/**
|
||||
* Get a {@link List} of the groups the user is a member of on a specific server
|
||||
* @param server the server to check
|
||||
* @param world the world to check
|
||||
* @return a {@link List} of group names
|
||||
* @throws NullPointerException if the server or world is null
|
||||
* @throws IllegalArgumentException if the server or world is invalid
|
||||
*/
|
||||
List<String> getLocalGroups(String server, String world);
|
||||
|
||||
/**
|
||||
* Get a {@link List} of the groups the user is a member of on a specific server
|
||||
* @param server the server to check
|
||||
* @return a {@link List} of group names
|
||||
* @throws NullPointerException if the server is null
|
||||
* @throws IllegalArgumentException if the server is invalid
|
||||
*/
|
||||
List<String> getLocalGroups(String server);
|
||||
@Deprecated
|
||||
void setupDataCache();
|
||||
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,36 +25,43 @@
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A UUID cache for online users, between external Mojang UUIDs, and internal LuckPerms UUIDs.
|
||||
* A UUID cache for online users, between external Mojang UUIDs, and internal
|
||||
* LuckPerms UUIDs.
|
||||
*
|
||||
* <p> This UuidCache is a means of allowing users to have the same internal UUID across a network of offline mode servers
|
||||
* or mixed offline mode and online mode servers. Platforms running in offline mode generate a random UUID for a user when
|
||||
* they first join the server, but this UUID will then not be consistent across the network. LuckPerms will instead check
|
||||
* the datastore cache, to get a UUID for a user that is consistent across an entire network.
|
||||
*
|
||||
* <p> If you want to get a user object from the datastore using the api on a server in offline mode, you will need to use this cache,
|
||||
* OR use Datastore#getUUID, for users that are not online.
|
||||
*
|
||||
* <p> WARNING: THIS IS ONLY EFFECTIVE FOR ONLINE PLAYERS. USE THE DATASTORE METHODS FOR OFFLINE PLAYERS.
|
||||
* @deprecated this feature is now handled internally - and the API returns a
|
||||
* No-op implementation of this class.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Deprecated
|
||||
public interface UuidCache {
|
||||
|
||||
/**
|
||||
* Gets a users internal "LuckPerms" UUID, from the one given by the server.
|
||||
* @param external the UUID assigned by the server, through Player#getUniqueId or ProxiedPlayer#getUniqueId
|
||||
* Gets a users "internal" LuckPerms UUID, from the one given by the server.
|
||||
*
|
||||
* <p>When <code>use-server-uuids</code> is true, this returns the same UUID
|
||||
* instance.</p>
|
||||
*
|
||||
* @param mojangUuid the UUID assigned by the server, through
|
||||
* <code>Player#getUniqueId</code> or
|
||||
* <code>ProxiedPlayer#getUniqueId</code>
|
||||
* @return the corresponding internal UUID
|
||||
*/
|
||||
UUID getUUID(UUID external);
|
||||
@Deprecated
|
||||
@NonNull UUID getUUID(@NonNull UUID mojangUuid);
|
||||
|
||||
/**
|
||||
* Gets a users external, server assigned or Mojang assigned unique id, from the internal one used within LuckPerms.
|
||||
* @param internal the UUID used within LuckPerms, through User#getUuid
|
||||
* Gets a users "external", server assigned unique id, from the internal
|
||||
* one used within LuckPerms.
|
||||
*
|
||||
* @param internalUuid the UUID used within LuckPerms, through
|
||||
* <code>User#getUuid</code>
|
||||
* @return the corresponding external UUID
|
||||
*/
|
||||
UUID getExternalUUID(UUID internal);
|
||||
@Deprecated
|
||||
@NonNull UUID getExternalUUID(@NonNull UUID internalUuid);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,430 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.caching;
|
||||
|
||||
import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.api.PermissionHolder;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* Holds cached permission and meta lookup data for a {@link PermissionHolder}.
|
||||
*
|
||||
* <p>All calls will account for inheritance, as well as any default data
|
||||
* provided by the platform. This calls are heavily cached and are therefore
|
||||
* fast.</p>
|
||||
*
|
||||
* <p>For meta, both methods accepting {@link Contexts} and {@link MetaContexts}
|
||||
* are provided. The only difference is that the latter allows you to define
|
||||
* how the meta stack should be structured internally. Where {@link Contexts}
|
||||
* are passed, the values from the configuration are used.</p>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface CachedData {
|
||||
|
||||
/**
|
||||
* Gets PermissionData from the cache, given a specified context.
|
||||
*
|
||||
* @param contexts the contexts to get the permission data in
|
||||
* @return a permission data instance
|
||||
* @throws NullPointerException if contexts is null
|
||||
*/
|
||||
@NonNull PermissionData getPermissionData(@NonNull Contexts contexts);
|
||||
|
||||
/**
|
||||
* Gets MetaData from the cache, given a specified context.
|
||||
*
|
||||
* @param contexts the contexts to get the permission data in
|
||||
* @return a meta data instance
|
||||
* @throws NullPointerException if contexts is null
|
||||
* @since 3.2
|
||||
*/
|
||||
@NonNull MetaData getMetaData(@NonNull MetaContexts contexts);
|
||||
|
||||
/**
|
||||
* Gets MetaData from the cache, given a specified context.
|
||||
*
|
||||
* @param contexts the contexts to get the permission data in
|
||||
* @return a meta data instance
|
||||
* @throws NullPointerException if contexts is null
|
||||
*/
|
||||
@NonNull MetaData getMetaData(@NonNull Contexts contexts);
|
||||
|
||||
/**
|
||||
* Calculates permission data, bypassing the cache.
|
||||
*
|
||||
* <p>The result of this operation is calculated each time the method is called.
|
||||
* The result is not added to the internal cache.</p>
|
||||
*
|
||||
* <p>It is therefore highly recommended to use {@link #getPermissionData(Contexts)} instead.</p>
|
||||
*
|
||||
* <p>The use cases of this method are more around constructing one-time
|
||||
* instances of {@link PermissionData}, without adding the result to the cache.</p>
|
||||
*
|
||||
* @param contexts the contexts to get permission data in
|
||||
* @return a permission data instance
|
||||
* @throws NullPointerException if contexts is null
|
||||
*/
|
||||
@NonNull PermissionData calculatePermissions(@NonNull Contexts contexts);
|
||||
|
||||
/**
|
||||
* Calculates meta data, bypassing the cache.
|
||||
*
|
||||
* <p>The result of this operation is calculated each time the method is called.
|
||||
* The result is not added to the internal cache.</p>
|
||||
*
|
||||
* <p>It is therefore highly recommended to use {@link #getMetaData(MetaContexts)} instead.</p>
|
||||
*
|
||||
* <p>The use cases of this method are more around constructing one-time
|
||||
* instances of {@link MetaData}, without adding the result to the cache.</p>
|
||||
*
|
||||
* @param contexts the contexts to get meta data in
|
||||
* @return a meta data instance
|
||||
* @throws NullPointerException if contexts is null
|
||||
* @since 3.2
|
||||
*/
|
||||
@NonNull MetaData calculateMeta(@NonNull MetaContexts contexts);
|
||||
|
||||
/**
|
||||
* Calculates meta data, bypassing the cache.
|
||||
*
|
||||
* <p>The result of this operation is calculated each time the method is called.
|
||||
* The result is not added to the internal cache.</p>
|
||||
*
|
||||
* <p>It is therefore highly recommended to use {@link #getMetaData(Contexts)} instead.</p>
|
||||
*
|
||||
* <p>The use cases of this method are more around constructing one-time
|
||||
* instances of {@link MetaData}, without adding the result to the cache.</p>
|
||||
*
|
||||
* @param contexts the contexts to get meta data in
|
||||
* @return a meta data instance
|
||||
* @throws NullPointerException if contexts is null
|
||||
*/
|
||||
@NonNull MetaData calculateMeta(@NonNull Contexts contexts);
|
||||
|
||||
/**
|
||||
* (Re)calculates permission data for a given context.
|
||||
*
|
||||
* <p>This method returns immediately in all cases. The (re)calculation is
|
||||
* performed asynchronously and applied to the cache in the background.</p>
|
||||
*
|
||||
* <p>If there was a previous {@link PermissionData} instance associated with
|
||||
* the given {@link Contexts}, then that instance will continue to be returned by
|
||||
* {@link #getPermissionData(Contexts)} until the recalculation is completed.</p>
|
||||
*
|
||||
* <p>If there was no value calculated and cached prior to the call of this
|
||||
* method, then one will be calculated.</p>
|
||||
*
|
||||
* @param contexts the contexts to recalculate in.
|
||||
* @throws NullPointerException if contexts is null
|
||||
*/
|
||||
void recalculatePermissions(@NonNull Contexts contexts);
|
||||
|
||||
/**
|
||||
* (Re)calculates meta data for a given context.
|
||||
*
|
||||
* <p>This method returns immediately in all cases. The (re)calculation is
|
||||
* performed asynchronously and applied to the cache in the background.</p>
|
||||
*
|
||||
* <p>If there was a previous {@link MetaData} instance associated with
|
||||
* the given {@link MetaContexts}, then that instance will continue to be returned by
|
||||
* {@link #getMetaData(MetaContexts)} until the recalculation is completed.</p>
|
||||
*
|
||||
* <p>If there was no value calculated and cached prior to the call of this
|
||||
* method, then one will be calculated.</p>
|
||||
*
|
||||
* @param contexts the contexts to recalculate in.
|
||||
* @throws NullPointerException if contexts is null
|
||||
* @since 3.2
|
||||
*/
|
||||
void recalculateMeta(@NonNull MetaContexts contexts);
|
||||
|
||||
/**
|
||||
* (Re)calculates meta data for a given context.
|
||||
*
|
||||
* <p>This method returns immediately in all cases. The (re)calculation is
|
||||
* performed asynchronously and applied to the cache in the background.</p>
|
||||
*
|
||||
* <p>If there was a previous {@link MetaData} instance associated with
|
||||
* the given {@link Contexts}, then that instance will continue to be returned by
|
||||
* {@link #getMetaData(Contexts)} until the recalculation is completed.</p>
|
||||
*
|
||||
* <p>If there was no value calculated and cached prior to the call of this
|
||||
* method, then one will be calculated.</p>
|
||||
*
|
||||
* @param contexts the contexts to recalculate in.
|
||||
* @throws NullPointerException if contexts is null
|
||||
*/
|
||||
void recalculateMeta(@NonNull Contexts contexts);
|
||||
|
||||
/**
|
||||
* (Re)loads permission data for a given context.
|
||||
*
|
||||
* <p>Unlike {@link #recalculatePermissions(Contexts)}, this method immediately
|
||||
* invalidates any previous {@link PermissionData} values contained within the cache,
|
||||
* and then schedules a task to reload a new {@link PermissionData} instance to
|
||||
* replace the one which was invalidated.</p>
|
||||
*
|
||||
* <p>The invalidation happens immediately during the execution of this method.
|
||||
* The result of the re-computation encapsulated by the future.</p>
|
||||
*
|
||||
* <p>Subsequent calls to {@link #getPermissionData(Contexts)} will block until
|
||||
* the result of this operation is complete.</p>
|
||||
*
|
||||
* <p>If there was no value calculated and cached prior to the call of this
|
||||
* method, then one will be calculated.</p>
|
||||
*
|
||||
* <p>This method returns a Future so users can optionally choose to wait
|
||||
* until the recalculation has been performed.</p>
|
||||
*
|
||||
* @param contexts the contexts to reload in.
|
||||
* @return a future
|
||||
* @throws NullPointerException if contexts is null
|
||||
* @since 4.0
|
||||
*/
|
||||
@NonNull CompletableFuture<? extends PermissionData> reloadPermissions(@NonNull Contexts contexts);
|
||||
|
||||
/**
|
||||
* (Re)loads meta data for a given context.
|
||||
*
|
||||
* <p>Unlike {@link #recalculateMeta(MetaContexts)}, this method immediately
|
||||
* invalidates any previous {@link MetaData} values contained within the cache,
|
||||
* and then schedules a task to reload a new {@link MetaData} instance to
|
||||
* replace the one which was invalidated.</p>
|
||||
*
|
||||
* <p>The invalidation happens immediately during the execution of this method.
|
||||
* The result of the re-computation encapsulated by the future.</p>
|
||||
*
|
||||
* <p>Subsequent calls to {@link #getMetaData(MetaContexts)} will block until
|
||||
* the result of this operation is complete.</p>
|
||||
*
|
||||
* <p>If there was no value calculated and cached prior to the call of this
|
||||
* method, then one will be calculated.</p>
|
||||
*
|
||||
* <p>This method returns a Future so users can optionally choose to wait
|
||||
* until the recalculation has been performed.</p>
|
||||
*
|
||||
* @param contexts the contexts to reload in.
|
||||
* @return a future
|
||||
* @throws NullPointerException if contexts is null
|
||||
* @since 4.0
|
||||
*/
|
||||
@NonNull CompletableFuture<? extends MetaData> reloadMeta(@NonNull MetaContexts contexts);
|
||||
|
||||
/**
|
||||
* (Re)loads meta data for a given context.
|
||||
*
|
||||
* <p>Unlike {@link #recalculateMeta(Contexts)}, this method immediately
|
||||
* invalidates any previous {@link MetaData} values contained within the cache,
|
||||
* and then schedules a task to reload a new {@link MetaData} instance to
|
||||
* replace the one which was invalidated.</p>
|
||||
*
|
||||
* <p>The invalidation happens immediately during the execution of this method.
|
||||
* The result of the re-computation encapsulated by the future.</p>
|
||||
*
|
||||
* <p>Subsequent calls to {@link #getMetaData(Contexts)} will block until
|
||||
* the result of this operation is complete.</p>
|
||||
*
|
||||
* <p>If there was no value calculated and cached prior to the call of this
|
||||
* method, then one will be calculated.</p>
|
||||
*
|
||||
* <p>This method returns a Future so users can optionally choose to wait
|
||||
* until the recalculation has been performed.</p>
|
||||
*
|
||||
* @param contexts the contexts to reload in.
|
||||
* @return a future
|
||||
* @throws NullPointerException if contexts is null
|
||||
* @since 4.0
|
||||
*/
|
||||
@NonNull CompletableFuture<? extends MetaData> reloadMeta(@NonNull Contexts contexts);
|
||||
|
||||
/**
|
||||
* Recalculates permission data for all known contexts.
|
||||
*
|
||||
* <p>This method returns immediately. The recalculation is performed
|
||||
* asynchronously and applied to the cache in the background.</p>
|
||||
*
|
||||
* <p>The previous {@link PermissionData} instances will continue to be returned
|
||||
* by {@link #getPermissionData(Contexts)} until the recalculation is completed.</p>
|
||||
*/
|
||||
void recalculatePermissions();
|
||||
|
||||
/**
|
||||
* Recalculates meta data for all known contexts.
|
||||
*
|
||||
* <p>This method returns immediately. The recalculation is performed
|
||||
* asynchronously and applied to the cache in the background.</p>
|
||||
*
|
||||
* <p>The previous {@link MetaData} instances will continue to be returned
|
||||
* by {@link #getMetaData(MetaContexts)} and {@link #getMetaData(Contexts)}
|
||||
* until the recalculation is completed.</p>
|
||||
*/
|
||||
void recalculateMeta();
|
||||
|
||||
/**
|
||||
* Reloads permission data for all known contexts.
|
||||
*
|
||||
* <p>Unlike {@link #recalculatePermissions()}, this method immediately
|
||||
* invalidates all previous {@link PermissionData} values contained within the cache,
|
||||
* and then schedules a task to reload a new {@link PermissionData} instances to
|
||||
* replace the ones which were invalidated.</p>
|
||||
*
|
||||
* <p>The invalidation happens immediately during the execution of this method.
|
||||
* The result of the re-computation encapsulated by the future.</p>
|
||||
*
|
||||
* <p>Subsequent calls to {@link #getPermissionData(Contexts)} will block until
|
||||
* the result of this operation is complete.</p>
|
||||
*
|
||||
* <p>This method returns a Future so users can optionally choose to wait
|
||||
* until the recalculation has been performed.</p>
|
||||
*
|
||||
* @return a future
|
||||
* @since 4.0
|
||||
*/
|
||||
@NonNull CompletableFuture<Void> reloadPermissions();
|
||||
|
||||
/**
|
||||
* Reloads meta data for all known contexts.
|
||||
*
|
||||
* <p>Unlike {@link #recalculateMeta()}, this method immediately
|
||||
* invalidates all previous {@link MetaData} values contained within the cache,
|
||||
* and then schedules a task to reload a new {@link MetaData} instances to
|
||||
* replace the ones which were invalidated.</p>
|
||||
*
|
||||
* <p>The invalidation happens immediately during the execution of this method.
|
||||
* The result of the re-computation encapsulated by the future.</p>
|
||||
*
|
||||
* <p>Subsequent calls to {@link #getMetaData(MetaContexts)} and
|
||||
* {@link #getMetaData(Contexts)} will block until the result of this operation
|
||||
* is complete.</p>
|
||||
*
|
||||
* <p>This method returns a Future so users can optionally choose to wait
|
||||
* until the recalculation has been performed.</p>
|
||||
*
|
||||
* @return a future
|
||||
* @since 4.0
|
||||
*/
|
||||
@NonNull CompletableFuture<Void> reloadMeta();
|
||||
|
||||
/**
|
||||
* Pre-calculates and caches {@link PermissionData} and {@link MetaData}
|
||||
* instances for the given contexts.
|
||||
*
|
||||
* <p>If the cache already contains a value for the given context,
|
||||
* no action is taken.</p>
|
||||
*
|
||||
* <p>This method blocks until the calculation is completed.</p>
|
||||
*
|
||||
* @param contexts a set of contexts
|
||||
* @throws NullPointerException if contexts is null
|
||||
*/
|
||||
default void preCalculate(@NonNull Set<Contexts> contexts) {
|
||||
contexts.forEach(this::preCalculate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-calculates and caches {@link PermissionData} and {@link MetaData}
|
||||
* instances for a given context.
|
||||
*
|
||||
* <p>If the cache already contains a value for the given context,
|
||||
* no action is taken.</p>
|
||||
*
|
||||
* <p>This method blocks until the calculation is completed.</p>
|
||||
*
|
||||
* @param contexts the contexts to pre-calculate for
|
||||
* @throws NullPointerException if contexts is null
|
||||
*/
|
||||
default void preCalculate(@NonNull Contexts contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
|
||||
// pre-calculate just by requesting the data from this cache.
|
||||
// if the data isn't already loaded, it will be calculated.
|
||||
getPermissionData(contexts);
|
||||
getMetaData(contexts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates any cached {@link PermissionData} instances mapped to the given
|
||||
* {@link Contexts}.
|
||||
*
|
||||
* @param contexts the contexts to invalidate for
|
||||
* @since 4.0
|
||||
*/
|
||||
void invalidatePermissions(@NonNull Contexts contexts);
|
||||
|
||||
/**
|
||||
* Invalidates any cached {@link MetaData} instances mapped to the given
|
||||
* {@link MetaContexts}.
|
||||
*
|
||||
* @param contexts the contexts to invalidate for
|
||||
* @since 4.0
|
||||
*/
|
||||
void invalidateMeta(@NonNull MetaContexts contexts);
|
||||
|
||||
/**
|
||||
* Invalidates any cached {@link MetaData} instances mapped to the given
|
||||
* {@link Contexts}.
|
||||
*
|
||||
* @param contexts the contexts to invalidate for
|
||||
* @since 4.0
|
||||
*/
|
||||
void invalidateMeta(@NonNull Contexts contexts);
|
||||
|
||||
/**
|
||||
* Invalidates all cached {@link PermissionData} instances.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
void invalidatePermissions();
|
||||
|
||||
/**
|
||||
* Invalidates all cached {@link MetaData} instances.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
void invalidateMeta();
|
||||
|
||||
/**
|
||||
* Invalidates all cached {@link PermissionData} and {@link MetaData}
|
||||
* instances.
|
||||
*
|
||||
* @since 4.5
|
||||
*/
|
||||
void invalidate();
|
||||
|
||||
/**
|
||||
* Invalidates all of the underlying Permission calculators.
|
||||
*
|
||||
* <p>Can be called to allow for an update in defaults.</p>
|
||||
*/
|
||||
void invalidatePermissionCalculators();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.caching;
|
||||
|
||||
import me.lucko.luckperms.api.Contexts;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Holds cached lookup data in a specific set of contexts.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface CachedDataContainer {
|
||||
|
||||
/**
|
||||
* Gets the contexts this container is holding data for.
|
||||
*
|
||||
* @return the contexts this container is caching
|
||||
*/
|
||||
@NonNull Contexts getContexts();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.caching;
|
||||
|
||||
import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.api.Group;
|
||||
|
||||
/**
|
||||
* Holds cached permission and meta lookup data for a {@link Group}.
|
||||
*
|
||||
* <p>All calls will account for inheritance, as well as any default data provided
|
||||
* by the platform. This calls are heavily cached and are therefore fast.</p>
|
||||
*
|
||||
* <p>For meta, both methods accepting {@link Contexts} and {@link MetaContexts} are provided. The only difference is that
|
||||
* the latter allows you to define how the meta stack should be structured internally. Where {@link Contexts} are passed, the
|
||||
* values from the configuration are used.</p>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface GroupData extends CachedData {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.caching;
|
||||
|
||||
import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Encapsulates the options and settings for a meta lookup.
|
||||
*
|
||||
* <p>Consists of a standard {@link Contexts} element, plus options to define how
|
||||
* the meta stack should be constructed.</p>
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public final class MetaContexts {
|
||||
|
||||
/**
|
||||
* Creates a new meta contexts instance
|
||||
*
|
||||
* @param contexts the standard contexts for the query
|
||||
* @param prefixStackDefinition the prefix stack definition to be used
|
||||
* @param suffixStackDefinition the suffix stack definition to be used
|
||||
* @return the new instance
|
||||
*/
|
||||
public static MetaContexts of(@NonNull Contexts contexts, @NonNull MetaStackDefinition prefixStackDefinition, @NonNull MetaStackDefinition suffixStackDefinition) {
|
||||
return new MetaContexts(contexts, prefixStackDefinition, suffixStackDefinition);
|
||||
}
|
||||
|
||||
private final Contexts contexts;
|
||||
private final MetaStackDefinition prefixStackDefinition;
|
||||
private final MetaStackDefinition suffixStackDefinition;
|
||||
|
||||
// cache hashcode - this class is immutable, and is used as an index in the permission cache.
|
||||
private final int hashCode;
|
||||
|
||||
/**
|
||||
* Creates a new meta contexts instance
|
||||
*
|
||||
* @param contexts the standard contexts for the query
|
||||
* @param prefixStackDefinition the prefix stack definition to be used
|
||||
* @param suffixStackDefinition the suffix stack definition to be used
|
||||
*/
|
||||
public MetaContexts(@NonNull Contexts contexts, @NonNull MetaStackDefinition prefixStackDefinition, @NonNull MetaStackDefinition suffixStackDefinition) {
|
||||
this.contexts = Objects.requireNonNull(contexts, "contexts");
|
||||
this.prefixStackDefinition = Objects.requireNonNull(prefixStackDefinition, "prefixStackDefinition");
|
||||
this.suffixStackDefinition = Objects.requireNonNull(suffixStackDefinition, "suffixStackDefinition");
|
||||
this.hashCode = calculateHashCode();
|
||||
}
|
||||
|
||||
public @NonNull Contexts getContexts() {
|
||||
return this.contexts;
|
||||
}
|
||||
|
||||
public @NonNull MetaStackDefinition getPrefixStackDefinition() {
|
||||
return this.prefixStackDefinition;
|
||||
}
|
||||
|
||||
public @NonNull MetaStackDefinition getSuffixStackDefinition() {
|
||||
return this.suffixStackDefinition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String toString() {
|
||||
return "MetaContexts(" +
|
||||
"contexts=" + this.getContexts() + ", " +
|
||||
"prefixStackDefinition=" + this.getPrefixStackDefinition() + ", " +
|
||||
"suffixStackDefinition=" + this.getSuffixStackDefinition() +
|
||||
")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof MetaContexts)) return false;
|
||||
final MetaContexts that = (MetaContexts) o;
|
||||
return this.contexts.equals(that.contexts) &&
|
||||
this.prefixStackDefinition.equals(that.prefixStackDefinition) &&
|
||||
this.suffixStackDefinition.equals(that.suffixStackDefinition);
|
||||
}
|
||||
|
||||
private int calculateHashCode() {
|
||||
return Objects.hash(this.contexts, this.prefixStackDefinition, this.suffixStackDefinition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.hashCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.caching;
|
||||
|
||||
import com.google.common.collect.ListMultimap;
|
||||
|
||||
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
|
||||
/**
|
||||
* Holds cached meta lookup data for a specific set of contexts.
|
||||
*
|
||||
* @since 2.13
|
||||
*/
|
||||
public interface MetaData extends CachedDataContainer {
|
||||
|
||||
/**
|
||||
* Gets the contexts this container is holding data for.
|
||||
*
|
||||
* @return the contexts this container is caching
|
||||
*/
|
||||
@NonNull MetaContexts getMetaContexts();
|
||||
|
||||
/**
|
||||
* Gets an immutable copy of the meta this user has.
|
||||
*
|
||||
* <p>A list multimap is used because when inherited values are included, each key can be
|
||||
* mapped to multiple values.</p>
|
||||
*
|
||||
* <p>The first value to be accumulated (and used to represent the key in {@link #getMeta()} is at index 0
|
||||
* in the list. Any additional values are stored in order of accumulation.</p>
|
||||
*
|
||||
* @return an immutable multimap of meta
|
||||
* @since 3.3
|
||||
*/
|
||||
@NonNull ListMultimap<String, String> getMetaMultimap();
|
||||
|
||||
/**
|
||||
* Gets an immutable copy of the meta this user has.
|
||||
*
|
||||
* <p>This map is formed by taking the entries in {@link #getMetaMultimap()}, and mapping each key
|
||||
* to the value at index 0 in the corresponding list.</p>
|
||||
*
|
||||
* @return an immutable map of meta
|
||||
*/
|
||||
@NonNull Map<String, String> getMeta();
|
||||
|
||||
/**
|
||||
* Gets an immutable sorted map of all of the prefixes the user has, whereby the first value is the highest priority
|
||||
* prefix.
|
||||
*
|
||||
* @return a sorted map of prefixes
|
||||
*/
|
||||
@NonNull SortedMap<Integer, String> getPrefixes();
|
||||
|
||||
/**
|
||||
* Gets an immutable sorted map of all of the suffixes the user has, whereby the first value is the highest priority
|
||||
* suffix.
|
||||
*
|
||||
* @return a sorted map of suffixes
|
||||
*/
|
||||
@NonNull SortedMap<Integer, String> getSuffixes();
|
||||
|
||||
/**
|
||||
* Gets the user's highest priority prefix, or null if the user has no prefixes
|
||||
*
|
||||
* @return a prefix string, or null
|
||||
*/
|
||||
@Nullable String getPrefix();
|
||||
|
||||
/**
|
||||
* Gets the user's highest priority suffix, or null if the user has no suffixes
|
||||
*
|
||||
* @return a suffix string, or null
|
||||
*/
|
||||
@Nullable String getSuffix();
|
||||
|
||||
/**
|
||||
* Gets the definition used for the prefix stack
|
||||
*
|
||||
* @return the definition used for the prefix stack
|
||||
* @since 3.2
|
||||
*/
|
||||
@NonNull MetaStackDefinition getPrefixStackDefinition();
|
||||
|
||||
/**
|
||||
* Gets the definition used for the suffix stack
|
||||
*
|
||||
* @return the definition used for the suffix stack
|
||||
* @since 3.2
|
||||
*/
|
||||
@NonNull MetaStackDefinition getSuffixStackDefinition();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.caching;
|
||||
|
||||
import me.lucko.luckperms.api.Tristate;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Holds cached permission lookup data for a specific set of contexts.
|
||||
*
|
||||
* @since 2.13
|
||||
*/
|
||||
public interface PermissionData extends CachedDataContainer {
|
||||
|
||||
/**
|
||||
* Gets a permission check result for the given permission node.
|
||||
*
|
||||
* @param permission the permission node
|
||||
* @return a tristate result
|
||||
* @throws NullPointerException if permission is null
|
||||
*/
|
||||
@NonNull Tristate getPermissionValue(@NonNull String permission);
|
||||
|
||||
/**
|
||||
* Invalidates the underlying permission calculator cache.
|
||||
*
|
||||
* <p>Can be called to allow for an update in defaults.</p>
|
||||
*/
|
||||
void invalidateCache();
|
||||
|
||||
/**
|
||||
* Gets an immutable copy of the permission map backing the permission calculator
|
||||
*
|
||||
* @return an immutable set of permissions
|
||||
*/
|
||||
@NonNull Map<String, Boolean> getImmutableBacking();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.caching;
|
||||
|
||||
import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.api.User;
|
||||
|
||||
/**
|
||||
* Holds cached permission and meta lookup data for a {@link User}.
|
||||
*
|
||||
* <p>All calls will account for inheritance, as well as any default data provided by
|
||||
* the platform. This calls are heavily cached and are therefore fast.</p>
|
||||
*
|
||||
* <p>For meta, both methods accepting {@link Contexts} and {@link MetaContexts} are provided. The only difference is that
|
||||
* the latter allows you to define how the meta stack should be structured internally. Where {@link Contexts} are passed, the
|
||||
* values from the configuration are used.</p>
|
||||
*
|
||||
* @since 2.13
|
||||
*/
|
||||
public interface UserData extends CachedData {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.context;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
abstract class AbstractContextSet implements ContextSet {
|
||||
|
||||
protected abstract SetMultimap<String, String> backing();
|
||||
|
||||
protected abstract void copyTo(SetMultimap<String, String> other);
|
||||
|
||||
@Override
|
||||
public boolean containsKey(@NonNull String key) {
|
||||
return backing().containsKey(sanitizeKey(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Set<String> getValues(@NonNull String key) {
|
||||
Collection<String> values = backing().asMap().get(sanitizeKey(key));
|
||||
return values != null ? ImmutableSet.copyOf(values) : ImmutableSet.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(@NonNull String key, @NonNull String value) {
|
||||
return backing().containsEntry(sanitizeKey(key), sanitizeValue(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return backing().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return backing().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return backing().hashCode();
|
||||
}
|
||||
|
||||
static String sanitizeKey(String key) {
|
||||
Objects.requireNonNull(key, "key is null");
|
||||
if (stringIsEmpty(key)) {
|
||||
throw new IllegalArgumentException("key is (effectively) empty");
|
||||
}
|
||||
return key.toLowerCase();
|
||||
}
|
||||
|
||||
static String sanitizeValue(String value) {
|
||||
Objects.requireNonNull(value, "value is null");
|
||||
if (stringIsEmpty(value)) {
|
||||
throw new IllegalArgumentException("value is (effectively) empty");
|
||||
}
|
||||
return value.toLowerCase();
|
||||
}
|
||||
|
||||
private static boolean stringIsEmpty(String s) {
|
||||
if (s.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
for (char c : s.toCharArray()) {
|
||||
if (c != ' ') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.context;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Calculates whether contexts are applicable to a {@link T subject}.
|
||||
*
|
||||
* @param <T> the subject type. Is ALWAYS the player class of the platform.
|
||||
* @since 2.13
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ContextCalculator<T> {
|
||||
|
||||
/**
|
||||
* Gives the subject all of the applicable contexts they meet
|
||||
*
|
||||
* @param subject the subject to add contexts to
|
||||
* @param accumulator a map of contexts to add to
|
||||
* @return the map
|
||||
* @since 2.13
|
||||
*/
|
||||
@NonNull MutableContextSet giveApplicableContext(@NonNull T subject, @NonNull MutableContextSet accumulator);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.context;
|
||||
|
||||
import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.api.User;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Manages {@link ContextCalculator}s, and calculates applicable contexts for a
|
||||
* given type.
|
||||
*
|
||||
* This interface accepts {@link Object} types as a parameter to avoid having to depend
|
||||
* on specific server implementations. In all cases, the "player" or "subject" type for
|
||||
* the platform must be used.
|
||||
*
|
||||
* Specifically:
|
||||
*
|
||||
* <p></p>
|
||||
* <ul>
|
||||
* <li>{@code org.bukkit.entity.Player}</li>
|
||||
* <li>{@code net.md_5.bungee.api.connection.ProxiedPlayer}</li>
|
||||
* <li>{@code org.spongepowered.api.service.permission.Subject}</li>
|
||||
* <li>{@code cn.nukkit.Player}</li>
|
||||
* <li>{@code com.velocitypowered.api.proxy.Player}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface ContextManager {
|
||||
|
||||
/**
|
||||
* Queries the ContextManager for current context values for the subject.
|
||||
*
|
||||
* @param subject the subject
|
||||
* @return the applicable context for the subject
|
||||
*/
|
||||
@NonNull ImmutableContextSet getApplicableContext(@NonNull Object subject);
|
||||
|
||||
/**
|
||||
* Queries the ContextManager for current context values for the subject.
|
||||
*
|
||||
* @param subject the subject
|
||||
* @return the applicable context for the subject
|
||||
*/
|
||||
@NonNull Contexts getApplicableContexts(@NonNull Object subject);
|
||||
|
||||
/**
|
||||
* Queries the ContextManager for current context values for the given User.
|
||||
*
|
||||
* <p>This will only return a value if the player corresponding to the
|
||||
* {@link User} is online.</p>
|
||||
*
|
||||
* <p>If you need to be a {@link Contexts} instance regardless, you should
|
||||
* initially try this method, and then fallback on {@link #getStaticContext()}.</p>
|
||||
*
|
||||
* @param user the user
|
||||
* @return the applicable context for the subject
|
||||
*/
|
||||
@NonNull Optional<ImmutableContextSet> lookupApplicableContext(@NonNull User user);
|
||||
|
||||
/**
|
||||
* Queries the ContextManager for current context values for the given User.
|
||||
*
|
||||
* <p>This will only return a value if the player corresponding to the
|
||||
* {@link User} is online.</p>
|
||||
*
|
||||
* <p>If you need to be a {@link Contexts} instance regardless, you should
|
||||
* initially try this method, and then fallback on {@link #getStaticContexts()}.</p>
|
||||
*
|
||||
* @param user the user
|
||||
* @return the applicable context for the subject
|
||||
*/
|
||||
@NonNull Optional<Contexts> lookupApplicableContexts(@NonNull User user);
|
||||
|
||||
/**
|
||||
* Gets the contexts from the static calculators in this manager.
|
||||
*
|
||||
* <p>Static calculators provide the same context for all subjects, and are
|
||||
* marked as such when registered.</p>
|
||||
*
|
||||
* @return the current active static contexts
|
||||
*/
|
||||
@NonNull ImmutableContextSet getStaticContext();
|
||||
|
||||
/**
|
||||
* Gets the contexts from the static calculators in this manager.
|
||||
*
|
||||
* <p>Static calculators provide the same context for all subjects, and are
|
||||
* marked as such when registered.</p>
|
||||
*
|
||||
* @return the current active static contexts
|
||||
*/
|
||||
@NonNull Contexts getStaticContexts();
|
||||
|
||||
/**
|
||||
* Forms a {@link Contexts} instance from an {@link ImmutableContextSet}.
|
||||
*
|
||||
* <p>This method relies on the plugins configuration to form the
|
||||
* {@link Contexts} instance.</p>
|
||||
*
|
||||
* @param subject the reference subject
|
||||
* @param contextSet the context set
|
||||
* @return a contexts instance
|
||||
*/
|
||||
@NonNull Contexts formContexts(@NonNull Object subject, @NonNull ImmutableContextSet contextSet);
|
||||
|
||||
/**
|
||||
* Forms a {@link Contexts} instance from an {@link ImmutableContextSet}.
|
||||
*
|
||||
* <p>This method relies on the plugins configuration to form the
|
||||
* {@link Contexts} instance.</p>
|
||||
*
|
||||
* @param contextSet the context set
|
||||
* @return a contexts instance
|
||||
*/
|
||||
@NonNull Contexts formContexts(@NonNull ImmutableContextSet contextSet);
|
||||
|
||||
/**
|
||||
* Registers a context calculator with the manager.
|
||||
*
|
||||
* @param calculator the calculator
|
||||
*/
|
||||
void registerCalculator(@NonNull ContextCalculator<?> calculator);
|
||||
|
||||
/**
|
||||
* Unregisters a context calculator with the manager.
|
||||
*
|
||||
* @param calculator the calculator
|
||||
* @since 4.4
|
||||
*/
|
||||
void unregisterCalculator(@NonNull ContextCalculator<?> calculator);
|
||||
|
||||
/**
|
||||
* Invalidates the lookup cache for a given subject
|
||||
*
|
||||
* @param subject the subject
|
||||
*/
|
||||
void invalidateCache(@NonNull Object subject);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.context;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A set of contexts.
|
||||
*
|
||||
* <p>Context in the most basic sense simply means the circumstances where
|
||||
* something will apply.</p>
|
||||
*
|
||||
* <p>A single "context" consists of a key and a value, both strings. The key
|
||||
* represents the type of context, and the value represents the setting of the
|
||||
* context key.</p>
|
||||
*
|
||||
* <p>Contexts can be combined with each other to form so called
|
||||
* "context sets" - simply a collection of context pairs.</p>
|
||||
*
|
||||
* <p>Context keys and values are case-insensitive, and will be converted to
|
||||
* {@link String#toLowerCase() lowercase} by all implementations.</p>
|
||||
*
|
||||
* <p>Context keys and values may not be null or empty. A key/value will be
|
||||
* deemed empty if it's length is zero, or if it consists of only space
|
||||
* characters.</p>
|
||||
*
|
||||
* <p>Two default ContextSet implementations are provided.
|
||||
* {@link MutableContextSet} allows the addition and removal of context keys
|
||||
* after construction, and {@link ImmutableContextSet} does not.</p>
|
||||
*
|
||||
* @since 2.13
|
||||
*/
|
||||
public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
||||
|
||||
/**
|
||||
* Creates an {@link ImmutableContextSet} from a context pair.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @return a new ImmutableContextSet containing one context pair
|
||||
* @throws NullPointerException if key or value is null
|
||||
*/
|
||||
static @NonNull ImmutableContextSet singleton(@NonNull String key, @NonNull String value) {
|
||||
return ImmutableContextSet.singleton(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@link ImmutableContextSet} from two context pairs.
|
||||
*
|
||||
* @param key1 the first key
|
||||
* @param value1 the first value
|
||||
* @param key2 the second key
|
||||
* @param value2 the second value
|
||||
* @return a new ImmutableContextSet containing the two pairs
|
||||
* @throws NullPointerException if any of the keys or values are null
|
||||
* @since 3.1
|
||||
*/
|
||||
static @NonNull ImmutableContextSet of(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2) {
|
||||
return ImmutableContextSet.of(key1, value1, key2, value2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@link ImmutableContextSet} from an existing {@link Iterable} of {@link Map.Entry}s.
|
||||
*
|
||||
* @param iterable the iterable to copy from
|
||||
* @return a new ImmutableContextSet representing the pairs in the iterable
|
||||
* @throws NullPointerException if the iterable is null
|
||||
*/
|
||||
static @NonNull ImmutableContextSet fromEntries(@NonNull Iterable<? extends Map.Entry<String, String>> iterable) {
|
||||
return ImmutableContextSet.fromEntries(iterable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@link ImmutableContextSet} from an existing {@link Map}.
|
||||
*
|
||||
* @param map the map to copy from
|
||||
* @return a new ImmutableContextSet representing the pairs from the map
|
||||
* @throws NullPointerException if the map is null
|
||||
*/
|
||||
static @NonNull ImmutableContextSet fromMap(@NonNull Map<String, String> map) {
|
||||
return ImmutableContextSet.fromMap(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@link ImmutableContextSet} from an existing {@link Multimap}.
|
||||
*
|
||||
* @param multimap the multimap to copy from
|
||||
* @return a new ImmutableContextSet representing the pairs in the multimap
|
||||
* @throws NullPointerException if the multimap is null
|
||||
* @since 2.16
|
||||
*/
|
||||
static @NonNull ImmutableContextSet fromMultimap(@NonNull Multimap<String, String> multimap) {
|
||||
return ImmutableContextSet.fromMultimap(multimap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an new {@link ImmutableContextSet} from an existing {@link Set}.
|
||||
*
|
||||
* <p>Only really useful for converting between mutable and immutable types.</p>
|
||||
*
|
||||
* @param contextSet the context set to copy from
|
||||
* @return a new ImmutableContextSet with the same content and the one provided
|
||||
* @throws NullPointerException if contextSet is null
|
||||
*/
|
||||
static @NonNull ImmutableContextSet fromSet(@NonNull ContextSet contextSet) {
|
||||
return ImmutableContextSet.fromSet(contextSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an empty {@link ImmutableContextSet}.
|
||||
*
|
||||
* @return an empty ImmutableContextSet
|
||||
*/
|
||||
static @NonNull ImmutableContextSet empty() {
|
||||
return ImmutableContextSet.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if this {@link ContextSet} is immutable.
|
||||
*
|
||||
* <p>The state of immutable instances will never change.</p>
|
||||
*
|
||||
* @return true if the set is immutable
|
||||
*/
|
||||
boolean isImmutable();
|
||||
|
||||
/**
|
||||
* Returns an immutable representation of this {@link ContextSet}.
|
||||
*
|
||||
* <p>If the set is already immutable, the same object will be returned.
|
||||
* If the set is mutable, an immutable copy will be made.</p>
|
||||
*
|
||||
* @return an immutable representation of this set
|
||||
*/
|
||||
@NonNull ImmutableContextSet makeImmutable();
|
||||
|
||||
/**
|
||||
* Creates a mutable copy of this {@link ContextSet}.
|
||||
*
|
||||
* <p>A new copy is returned regardless of the
|
||||
* {@link #isImmutable() mutability} of this set.</p>
|
||||
*
|
||||
* @return a mutable ContextSet
|
||||
* @since 2.16
|
||||
*/
|
||||
@NonNull MutableContextSet mutableCopy();
|
||||
|
||||
/**
|
||||
* Returns a {@link Set} of {@link Map.Entry}s representing the current
|
||||
* state of this {@link ContextSet}.
|
||||
*
|
||||
* <p>The returned set is immutable, and is a copy of the current set.
|
||||
* (will not update live)</p>
|
||||
*
|
||||
* @return an immutable set
|
||||
*/
|
||||
@NonNull Set<Map.Entry<String, String>> toSet();
|
||||
|
||||
/**
|
||||
* Returns a {@link Map} <b>loosely</b> representing the current state of
|
||||
* this {@link ContextSet}.
|
||||
*
|
||||
* <p>The returned map is immutable, and is a copy of the current set.
|
||||
* (will not update live)</p>
|
||||
*
|
||||
* <p>As a single context key can be mapped to multiple values, this method
|
||||
* may not be a true representation of the set.</p>
|
||||
*
|
||||
* <p>If you need a representation of the set in a Java collection instance,
|
||||
* use {@link #toSet()} or {@link #toMultimap()} followed by
|
||||
* {@link Multimap#asMap()}.</p>
|
||||
*
|
||||
* @return an immutable map
|
||||
* @deprecated because the resultant map may not contain all data in the ContextSet
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull Map<String, String> toMap();
|
||||
|
||||
/**
|
||||
* Returns a {@link Multimap} representing the current state of this
|
||||
* {@link ContextSet}.
|
||||
*
|
||||
* <p>The returned multimap is immutable, and is a copy of the current set.
|
||||
* (will not update live)</p>
|
||||
*
|
||||
* @return a multimap
|
||||
* @since 2.16
|
||||
*/
|
||||
@NonNull Multimap<String, String> toMultimap();
|
||||
|
||||
/**
|
||||
* Returns an {@link Iterator} over each of the context pairs in this set.
|
||||
*
|
||||
* <p>The returned iterator represents the state of the set at the time of creation. It is not
|
||||
* updated as the set changes.</p>
|
||||
*
|
||||
* <p>The iterator does not support {@link Iterator#remove()} calls.</p>
|
||||
*
|
||||
* @return an iterator
|
||||
*/
|
||||
@Override
|
||||
@NonNull Iterator<Map.Entry<String, String>> iterator();
|
||||
|
||||
/**
|
||||
* Returns if the {@link ContextSet} contains at least one value for the
|
||||
* given key.
|
||||
*
|
||||
* @param key the key to check for
|
||||
* @return true if the set contains a value for the key
|
||||
* @throws NullPointerException if the key is null
|
||||
*/
|
||||
boolean containsKey(@NonNull String key);
|
||||
|
||||
/**
|
||||
* Returns a {@link Set} of the values mapped to the given key.
|
||||
*
|
||||
* <p>The returned set is immutable, and only represents the current state
|
||||
* of the {@link ContextSet}. (will not update live)</p>
|
||||
*
|
||||
* @param key the key to get values for
|
||||
* @return a set of values
|
||||
* @throws NullPointerException if the key is null
|
||||
*/
|
||||
@NonNull Set<String> getValues(@NonNull String key);
|
||||
|
||||
/**
|
||||
* Returns any value from this {@link ContextSet} matching the key, if present.
|
||||
*
|
||||
* <p>Note that context keys can be mapped to multiple values.
|
||||
* Use {@link #getValues(String)} to retrieve all associated values.</p>
|
||||
*
|
||||
* @param key the key to find values for
|
||||
* @return an optional containing any match
|
||||
* @since 3.1
|
||||
*/
|
||||
default @NonNull Optional<String> getAnyValue(@NonNull String key) {
|
||||
return getValues(key).stream().findAny();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the {@link ContextSet} contains a given context pairing.
|
||||
*
|
||||
* @param key the key to look for
|
||||
* @param value the value to look for
|
||||
* @return true if the set contains the context pair
|
||||
* @throws NullPointerException if the key or value is null
|
||||
*/
|
||||
boolean has(@NonNull String key, @NonNull String value);
|
||||
|
||||
/**
|
||||
* Returns if the {@link ContextSet} contains a given context pairing.
|
||||
*
|
||||
* @param entry the entry to look for
|
||||
* @return true if the set contains the context pair
|
||||
* @throws NullPointerException if the key or value is null
|
||||
*/
|
||||
default boolean has(Map.@NonNull Entry<String, String> entry) {
|
||||
Objects.requireNonNull(entry, "entry");
|
||||
return has(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if this {@link ContextSet} is fully "satisfied" by another set.
|
||||
*
|
||||
* <p>For a context set to "satisfy" another, it must itself contain all of
|
||||
* the context pairings in the other set.</p>
|
||||
*
|
||||
* <p>Mathematically, this method returns true if this set is a <b>subset</b> of the other.</p>
|
||||
*
|
||||
* @param other the other set to check
|
||||
* @return true if all entries in this set are also in the other set
|
||||
* @since 3.1
|
||||
*/
|
||||
default boolean isSatisfiedBy(@NonNull ContextSet other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Objects.requireNonNull(other, "other");
|
||||
if (this.isEmpty()) {
|
||||
// this is empty, so is therefore always satisfied.
|
||||
return true;
|
||||
} else if (other.isEmpty()) {
|
||||
// this set isn't empty, but the other one is
|
||||
return false;
|
||||
} else if (this.size() > other.size()) {
|
||||
// this set has more unique entries than the other set, so there's no way this can be satisfied.
|
||||
return false;
|
||||
} else {
|
||||
// neither are empty, we need to compare the individual entries
|
||||
for (Map.Entry<String, String> context : toSet()) {
|
||||
if (!other.has(context)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the {@link ContextSet} is empty.
|
||||
*
|
||||
* @return true if the set is empty
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
/**
|
||||
* Gets the number of context pairs in the {@link ContextSet}.
|
||||
*
|
||||
* @return the size of the set
|
||||
*/
|
||||
int size();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,376 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.context;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.Spliterator;
|
||||
|
||||
/**
|
||||
* An immutable implementation of {@link ContextSet}.
|
||||
*
|
||||
* @since 2.16
|
||||
*/
|
||||
public final class ImmutableContextSet extends AbstractContextSet implements ContextSet {
|
||||
private static final ImmutableContextSet EMPTY = new ImmutableContextSet(ImmutableSetMultimap.of());
|
||||
|
||||
/**
|
||||
* Creates an {@link ImmutableContextSet.Builder}.
|
||||
*
|
||||
* @return a new ImmutableContextSet builder
|
||||
* @since 4.1
|
||||
*/
|
||||
public static @NonNull Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@link ImmutableContextSet} from a context pair.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @return a new ImmutableContextSet containing one context pair
|
||||
* @throws NullPointerException if key or value is null
|
||||
*/
|
||||
public static @NonNull ImmutableContextSet singleton(@NonNull String key, @NonNull String value) {
|
||||
return new ImmutableContextSet(ImmutableSetMultimap.of(sanitizeKey(key), sanitizeValue(value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@link ImmutableContextSet} from two context pairs.
|
||||
*
|
||||
* @param key1 the first key
|
||||
* @param value1 the first value
|
||||
* @param key2 the second key
|
||||
* @param value2 the second value
|
||||
* @return a new ImmutableContextSet containing the two pairs
|
||||
* @throws NullPointerException if any of the keys or values are null
|
||||
* @since 3.1
|
||||
*/
|
||||
public static @NonNull ImmutableContextSet of(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2) {
|
||||
return new ImmutableContextSet(ImmutableSetMultimap.of(
|
||||
sanitizeKey(key1),
|
||||
sanitizeValue(value1),
|
||||
sanitizeKey(key2),
|
||||
sanitizeValue(value2)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@link ImmutableContextSet} from an existing {@link Iterable} of {@link Map.Entry}s.
|
||||
*
|
||||
* @param iterable the iterable to copy from
|
||||
* @return a new ImmutableContextSet representing the pairs in the iterable
|
||||
* @throws NullPointerException if the iterable is null
|
||||
*/
|
||||
public static @NonNull ImmutableContextSet fromEntries(@NonNull Iterable<? extends Map.Entry<String, String>> iterable) {
|
||||
Objects.requireNonNull(iterable, "iterable");
|
||||
ImmutableContextSet.Builder builder = builder();
|
||||
for (Map.Entry<String, String> entry : iterable) {
|
||||
builder.add(entry);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@link ImmutableContextSet} from an existing {@link Map}.
|
||||
*
|
||||
* @param map the map to copy from
|
||||
* @return a new ImmutableContextSet representing the pairs from the map
|
||||
* @throws NullPointerException if the map is null
|
||||
*/
|
||||
public static @NonNull ImmutableContextSet fromMap(@NonNull Map<String, String> map) {
|
||||
return fromEntries(Objects.requireNonNull(map, "map").entrySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@link ImmutableContextSet} from an existing {@link Multimap}.
|
||||
*
|
||||
* @param multimap the multimap to copy from
|
||||
* @return a new ImmutableContextSet representing the pairs in the multimap
|
||||
* @throws NullPointerException if the multimap is null
|
||||
* @since 2.16
|
||||
*/
|
||||
public static @NonNull ImmutableContextSet fromMultimap(@NonNull Multimap<String, String> multimap) {
|
||||
return fromEntries(Objects.requireNonNull(multimap, "multimap").entries());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an new {@link ImmutableContextSet} from an existing {@link Set}.
|
||||
*
|
||||
* <p>Only really useful for converting between mutable and immutable types.</p>
|
||||
*
|
||||
* @param contextSet the context set to copy from
|
||||
* @return a new ImmutableContextSet with the same content and the one provided
|
||||
* @throws NullPointerException if contextSet is null
|
||||
*/
|
||||
public static @NonNull ImmutableContextSet fromSet(@NonNull ContextSet contextSet) {
|
||||
return Objects.requireNonNull(contextSet, "contextSet").makeImmutable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an empty {@link ImmutableContextSet}.
|
||||
*
|
||||
* @return an empty ImmutableContextSet
|
||||
*/
|
||||
public static @NonNull ImmutableContextSet empty() {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
private final ImmutableSetMultimap<String, String> map;
|
||||
private final int hashCode;
|
||||
|
||||
ImmutableContextSet(ImmutableSetMultimap<String, String> contexts) {
|
||||
this.map = contexts;
|
||||
this.hashCode = this.map.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SetMultimap<String, String> backing() {
|
||||
return this.map;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void copyTo(SetMultimap<String, String> other) {
|
||||
other.putAll(this.map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isImmutable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override // This set is already immutable!
|
||||
public @NonNull ImmutableContextSet makeImmutable() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull MutableContextSet mutableCopy() {
|
||||
return MutableContextSet.fromSet(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Set<Map.Entry<String, String>> toSet() {
|
||||
return this.map.entries();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public @NonNull Map<String, String> toMap() {
|
||||
ImmutableMap.Builder<String, String> m = ImmutableMap.builder();
|
||||
for (Map.Entry<String, String> e : this.map.entries()) {
|
||||
m.put(e.getKey(), e.getValue());
|
||||
}
|
||||
return m.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Multimap<String, String> toMultimap() {
|
||||
return this.map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Iterator<Map.Entry<String, String>> iterator() {
|
||||
return this.map.entries().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spliterator<Map.Entry<String, String>> spliterator() {
|
||||
return this.map.entries().spliterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof ContextSet)) return false;
|
||||
final ContextSet that = (ContextSet) o;
|
||||
|
||||
// fast(er) path for ImmutableContextSet comparisons
|
||||
if (that instanceof ImmutableContextSet) {
|
||||
ImmutableContextSet immutableThat = (ImmutableContextSet) that;
|
||||
if (this.hashCode != immutableThat.hashCode) return false;
|
||||
}
|
||||
|
||||
final Multimap<String, String> thatBacking;
|
||||
if (that instanceof AbstractContextSet) {
|
||||
thatBacking = ((AbstractContextSet) that).backing();
|
||||
} else {
|
||||
thatBacking = that.toMultimap();
|
||||
}
|
||||
|
||||
return backing().equals(thatBacking);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ImmutableContextSet(contexts=" + this.map + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for {@link ImmutableContextSet}.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public static final class Builder {
|
||||
private ImmutableSetMultimap.Builder<String, String> builder;
|
||||
|
||||
private Builder() {
|
||||
|
||||
}
|
||||
|
||||
private synchronized ImmutableSetMultimap.Builder<String, String> builder() {
|
||||
if (this.builder == null) {
|
||||
this.builder = ImmutableSetMultimap.builder();
|
||||
}
|
||||
return this.builder;
|
||||
}
|
||||
|
||||
private void put(String key, String value) {
|
||||
builder().put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a context to the set.
|
||||
*
|
||||
* @param key the key to add
|
||||
* @param value the value to add
|
||||
* @return the builder
|
||||
* @throws NullPointerException if the key or value is null
|
||||
* @see MutableContextSet#add(String, String)
|
||||
*/
|
||||
public @NonNull Builder add(@NonNull String key, @NonNull String value) {
|
||||
put(sanitizeKey(key), sanitizeValue(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a context to the set.
|
||||
*
|
||||
* @param entry the entry to add
|
||||
* @return the builder
|
||||
* @throws NullPointerException if the entry is null
|
||||
* @see MutableContextSet#add(Map.Entry)
|
||||
*/
|
||||
public @NonNull Builder add(Map.@NonNull Entry<String, String> entry) {
|
||||
Objects.requireNonNull(entry, "entry");
|
||||
add(entry.getKey(), entry.getValue());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the contexts contained in the given {@link Iterable} to the set.
|
||||
*
|
||||
* @param iterable an iterable of key value context pairs
|
||||
* @return the builder
|
||||
* @throws NullPointerException if iterable is null
|
||||
* @see MutableContextSet#addAll(Iterable)
|
||||
*/
|
||||
public @NonNull Builder addAll(@NonNull Iterable<? extends Map.Entry<String, String>> iterable) {
|
||||
for (Map.Entry<String, String> e : Objects.requireNonNull(iterable, "iterable")) {
|
||||
add(e);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the contexts contained in the given {@link Map} to the set.
|
||||
*
|
||||
* @param map the map to add from
|
||||
* @return the builder
|
||||
* @throws NullPointerException if the map is null
|
||||
* @see MutableContextSet#addAll(Map)
|
||||
*/
|
||||
public @NonNull Builder addAll(@NonNull Map<String, String> map) {
|
||||
addAll(Objects.requireNonNull(map, "map").entrySet());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the contexts contained in the given {@link Multimap} to the set.
|
||||
*
|
||||
* @param multimap the multimap to add from
|
||||
* @return the builder
|
||||
* @throws NullPointerException if the map is null
|
||||
* @since 3.4
|
||||
* @see MutableContextSet#addAll(Multimap)
|
||||
*/
|
||||
public @NonNull Builder addAll(@NonNull Multimap<String, String> multimap) {
|
||||
addAll(Objects.requireNonNull(multimap, "multimap").entries());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds of of the contexts in another {@link ContextSet} to the set.
|
||||
*
|
||||
* @param contextSet the set to add from
|
||||
* @return the builder
|
||||
* @throws NullPointerException if the contextSet is null
|
||||
* @see MutableContextSet#addAll(ContextSet)
|
||||
*/
|
||||
public @NonNull Builder addAll(@NonNull ContextSet contextSet) {
|
||||
Objects.requireNonNull(contextSet, "contextSet");
|
||||
if (contextSet instanceof AbstractContextSet) {
|
||||
AbstractContextSet other = ((AbstractContextSet) contextSet);
|
||||
if (!other.isEmpty()) {
|
||||
builder().putAll(other.backing());
|
||||
}
|
||||
} else {
|
||||
addAll(contextSet.toMultimap());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link ImmutableContextSet} from the values previously
|
||||
* added to the builder.
|
||||
*
|
||||
* @return an {@link ImmutableContextSet} from the builder
|
||||
*/
|
||||
public @NonNull ImmutableContextSet build() {
|
||||
if (this.builder == null) {
|
||||
return empty();
|
||||
} else {
|
||||
return new ImmutableContextSet(this.builder.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,368 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.context;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.Spliterator;
|
||||
|
||||
/**
|
||||
* A mutable implementation of {@link ContextSet}.
|
||||
*
|
||||
* @since 2.16
|
||||
*/
|
||||
public final class MutableContextSet extends AbstractContextSet implements ContextSet {
|
||||
|
||||
/**
|
||||
* Creates a {@link MutableContextSet} from a context pair.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @return a new MutableContextSet containing one context pair
|
||||
* @throws NullPointerException if key or value is null
|
||||
*/
|
||||
public static @NonNull MutableContextSet singleton(@NonNull String key, @NonNull String value) {
|
||||
Objects.requireNonNull(key, "key");
|
||||
Objects.requireNonNull(value, "value");
|
||||
MutableContextSet set = MutableContextSet.create();
|
||||
set.add(key, value);
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link MutableContextSet} from two context pairs.
|
||||
*
|
||||
* @param key1 the first key
|
||||
* @param value1 the first value
|
||||
* @param key2 the second key
|
||||
* @param value2 the second value
|
||||
* @return a new MutableContextSet containing the two pairs
|
||||
* @throws NullPointerException if any of the keys or values are null
|
||||
* @since 3.1
|
||||
*/
|
||||
public static @NonNull MutableContextSet of(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2) {
|
||||
Objects.requireNonNull(key1, "key1");
|
||||
Objects.requireNonNull(value1, "value1");
|
||||
Objects.requireNonNull(key2, "key2");
|
||||
Objects.requireNonNull(value2, "value2");
|
||||
MutableContextSet set = create();
|
||||
set.add(key1, value1);
|
||||
set.add(key2, value2);
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link MutableContextSet} from an existing {@link Iterable} of {@link Map.Entry}s.
|
||||
*
|
||||
* @param iterable the iterable to copy from
|
||||
* @return a new MutableContextSet representing the pairs in the iterable
|
||||
* @throws NullPointerException if the iterable is null
|
||||
*/
|
||||
public static @NonNull MutableContextSet fromEntries(@NonNull Iterable<? extends Map.Entry<String, String>> iterable) {
|
||||
Objects.requireNonNull(iterable, "iterable");
|
||||
MutableContextSet set = create();
|
||||
set.addAll(iterable);
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link MutableContextSet} from an existing {@link Map}.
|
||||
*
|
||||
* @param map the map to copy from
|
||||
* @return a new MutableContextSet representing the pairs from the map
|
||||
* @throws NullPointerException if the map is null
|
||||
*/
|
||||
public static @NonNull MutableContextSet fromMap(@NonNull Map<String, String> map) {
|
||||
Objects.requireNonNull(map, "map");
|
||||
MutableContextSet set = create();
|
||||
set.addAll(map);
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link MutableContextSet} from an existing {@link Multimap}.
|
||||
*
|
||||
* @param multimap the multimap to copy from
|
||||
* @return a new MutableContextSet representing the pairs in the multimap
|
||||
* @throws NullPointerException if the multimap is null
|
||||
* @since 2.16
|
||||
*/
|
||||
public static @NonNull MutableContextSet fromMultimap(@NonNull Multimap<String, String> multimap) {
|
||||
Objects.requireNonNull(multimap, "multimap");
|
||||
MutableContextSet set = create();
|
||||
set.addAll(multimap);
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link MutableContextSet} from an existing {@link Set}.
|
||||
*
|
||||
* <p>Only really useful for converting between mutable and immutable types.</p>
|
||||
*
|
||||
* @param contextSet the context set to copy from
|
||||
* @return a new MutableContextSet with the same content and the one provided
|
||||
* @throws NullPointerException if contextSet is null
|
||||
*/
|
||||
public static @NonNull MutableContextSet fromSet(@NonNull ContextSet contextSet) {
|
||||
Objects.requireNonNull(contextSet, "contextSet");
|
||||
|
||||
if (contextSet instanceof ImmutableContextSet) {
|
||||
SetMultimap<String, String> map = ((ImmutableContextSet) contextSet).backing();
|
||||
return new MutableContextSet(map);
|
||||
} else if (contextSet instanceof MutableContextSet) {
|
||||
return contextSet.mutableCopy();
|
||||
} else {
|
||||
MutableContextSet set = create();
|
||||
set.addAll(contextSet);
|
||||
return set;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new empty MutableContextSet.
|
||||
*
|
||||
* @return a new MutableContextSet
|
||||
*/
|
||||
public static @NonNull MutableContextSet create() {
|
||||
return new MutableContextSet();
|
||||
}
|
||||
|
||||
private final SetMultimap<String, String> map;
|
||||
|
||||
public MutableContextSet() {
|
||||
this.map = Multimaps.synchronizedSetMultimap(HashMultimap.create());
|
||||
}
|
||||
|
||||
private MutableContextSet(SetMultimap<String, String> other) {
|
||||
this.map = Multimaps.synchronizedSetMultimap(HashMultimap.create(other));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SetMultimap<String, String> backing() {
|
||||
return this.map;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void copyTo(SetMultimap<String, String> other) {
|
||||
synchronized (this.map) {
|
||||
other.putAll(this.map);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isImmutable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull ImmutableContextSet makeImmutable() {
|
||||
// if the map is empty, don't create a new instance
|
||||
if (this.map.isEmpty()) {
|
||||
return ImmutableContextSet.empty();
|
||||
}
|
||||
synchronized (this.map) {
|
||||
return new ImmutableContextSet(ImmutableSetMultimap.copyOf(this.map));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull MutableContextSet mutableCopy() {
|
||||
synchronized (this.map) {
|
||||
return new MutableContextSet(this.map);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Set<Map.Entry<String, String>> toSet() {
|
||||
synchronized (this.map) {
|
||||
// map.entries() returns immutable Map.Entry instances, so we can just call copyOf
|
||||
return ImmutableSet.copyOf(this.map.entries());
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public @NonNull Map<String, String> toMap() {
|
||||
ImmutableMap.Builder<String, String> m = ImmutableMap.builder();
|
||||
synchronized (this.map) {
|
||||
for (Map.Entry<String, String> e : this.map.entries()) {
|
||||
m.put(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
return m.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Multimap<String, String> toMultimap() {
|
||||
synchronized (this.map) {
|
||||
return ImmutableSetMultimap.copyOf(this.map);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Iterator<Map.Entry<String, String>> iterator() {
|
||||
return toSet().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spliterator<Map.Entry<String, String>> spliterator() {
|
||||
return toSet().spliterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a context to this set.
|
||||
*
|
||||
* @param key the key to add
|
||||
* @param value the value to add
|
||||
* @throws NullPointerException if the key or value is null
|
||||
*/
|
||||
public void add(@NonNull String key, @NonNull String value) {
|
||||
this.map.put(sanitizeKey(key), sanitizeValue(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a context to this set.
|
||||
*
|
||||
* @param entry the entry to add
|
||||
* @throws NullPointerException if the entry is null
|
||||
*/
|
||||
public void add(Map.@NonNull Entry<String, String> entry) {
|
||||
Objects.requireNonNull(entry, "entry");
|
||||
add(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the contexts contained in the given {@link Iterable} to this set.
|
||||
*
|
||||
* @param iterable an iterable of key value context pairs
|
||||
* @throws NullPointerException if iterable is null
|
||||
*/
|
||||
public void addAll(@NonNull Iterable<? extends Map.Entry<String, String>> iterable) {
|
||||
for (Map.Entry<String, String> e : Objects.requireNonNull(iterable, "iterable")) {
|
||||
add(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the contexts contained in the given {@link Map} to this set.
|
||||
*
|
||||
* @param map the map to add from
|
||||
* @throws NullPointerException if the map is null
|
||||
*/
|
||||
public void addAll(@NonNull Map<String, String> map) {
|
||||
addAll(Objects.requireNonNull(map, "map").entrySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the contexts contained in the given {@link Multimap} to this set.
|
||||
*
|
||||
* @param multimap the multimap to add from
|
||||
* @throws NullPointerException if the map is null
|
||||
* @since 3.4
|
||||
*/
|
||||
public void addAll(@NonNull Multimap<String, String> multimap) {
|
||||
addAll(Objects.requireNonNull(multimap, "multimap").entries());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds of of the contexts in another {@link ContextSet} to this set.
|
||||
*
|
||||
* @param contextSet the set to add from
|
||||
* @throws NullPointerException if the contextSet is null
|
||||
*/
|
||||
public void addAll(@NonNull ContextSet contextSet) {
|
||||
Objects.requireNonNull(contextSet, "contextSet");
|
||||
if (contextSet instanceof AbstractContextSet) {
|
||||
AbstractContextSet other = ((AbstractContextSet) contextSet);
|
||||
synchronized (this.map) {
|
||||
other.copyTo(this.map);
|
||||
}
|
||||
} else {
|
||||
addAll(contextSet.toMultimap());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a context from this set.
|
||||
*
|
||||
* @param key the key to remove
|
||||
* @param value the value to remove
|
||||
* @throws NullPointerException if the key or value is null
|
||||
*/
|
||||
public void remove(@NonNull String key, @NonNull String value) {
|
||||
this.map.remove(sanitizeKey(key), sanitizeValue(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all contexts from this set with the given key.
|
||||
*
|
||||
* @param key the key to remove
|
||||
* @throws NullPointerException if the key is null
|
||||
*/
|
||||
public void removeAll(@NonNull String key) {
|
||||
this.map.removeAll(sanitizeKey(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all contexts from the set.
|
||||
*/
|
||||
public void clear() {
|
||||
this.map.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof ContextSet)) return false;
|
||||
final ContextSet that = (ContextSet) o;
|
||||
|
||||
final Multimap<String, String> thatBacking;
|
||||
if (that instanceof AbstractContextSet) {
|
||||
thatBacking = ((AbstractContextSet) that).backing();
|
||||
} else {
|
||||
thatBacking = that.toMultimap();
|
||||
}
|
||||
|
||||
return backing().equals(thatBacking);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MutableContextSet(contexts=" + this.map + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.context;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Extension of {@link ContextCalculator} which provides the same context
|
||||
* regardless of the subject.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface StaticContextCalculator extends ContextCalculator<Object> {
|
||||
|
||||
/**
|
||||
* Adds this calculators context to the given accumulator.
|
||||
*
|
||||
* @param accumulator a map of contexts to add to
|
||||
* @return the map
|
||||
*/
|
||||
@NonNull MutableContextSet giveApplicableContext(@NonNull MutableContextSet accumulator);
|
||||
|
||||
/**
|
||||
* Gives the subject all of the applicable contexts they meet
|
||||
*
|
||||
* @param subject the subject to add contexts to
|
||||
* @param accumulator a map of contexts to add to
|
||||
* @return the map
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
default @NonNull MutableContextSet giveApplicableContext(@Nullable Object subject, @NonNull MutableContextSet accumulator) {
|
||||
return giveApplicableContext(accumulator);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* Represents an event that can be cancelled
|
||||
*/
|
||||
public interface Cancellable {
|
||||
|
||||
/**
|
||||
* Gets an {@link AtomicBoolean} holding the cancellation state of the event
|
||||
*
|
||||
* @return the cancellation
|
||||
*/
|
||||
@NonNull @Param(-1) AtomicBoolean getCancellationState();
|
||||
|
||||
/**
|
||||
* Returns true if the event is currently cancelled.
|
||||
*
|
||||
* @return if the event is cancelled
|
||||
* @since 4.1
|
||||
*/
|
||||
default boolean isCancelled() {
|
||||
return getCancellationState().get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the event is not currently cancelled.
|
||||
*
|
||||
* @return if the event is not cancelled
|
||||
* @since 4.1
|
||||
*/
|
||||
default boolean isNotCancelled() {
|
||||
return !isCancelled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cancellation state of the event.
|
||||
*
|
||||
* @param cancelled the new state
|
||||
* @return the previous state
|
||||
* @since 4.1
|
||||
*/
|
||||
default boolean setCancelled(boolean cancelled) {
|
||||
return getCancellationState().getAndSet(cancelled);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* The LuckPerms event bus.
|
||||
*
|
||||
* <p>Used to subscribe (or "listen") to LuckPerms events.</p>
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public interface EventBus {
|
||||
|
||||
/**
|
||||
* Registers a new subscription to the given event.
|
||||
*
|
||||
* <p>The returned {@link EventHandler} instance encapsulates the subscription state. It has
|
||||
* methods which can be used to terminate the subscription, or view stats about the nature of
|
||||
* the subscription.</p>
|
||||
*
|
||||
* @param eventClass the event class
|
||||
* @param handler the event handler
|
||||
* @param <T> the event class
|
||||
* @return an event handler instance representing this subscription
|
||||
*/
|
||||
@NonNull <T extends LuckPermsEvent> EventHandler<T> subscribe(@NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler);
|
||||
|
||||
/**
|
||||
* Registers a new subscription to the given event.
|
||||
*
|
||||
* <p>The returned {@link EventHandler} instance encapsulates the subscription state. It has
|
||||
* methods which can be used to terminate the subscription, or view stats about the nature of
|
||||
* the subscription.</p>
|
||||
*
|
||||
* <p>Unlike {@link #subscribe(Class, Consumer)}, this method accepts an additional parameter
|
||||
* for {@code plugin}. This object must be a "plugin" instance on the platform, and is used to
|
||||
* automatically {@link EventHandler#unregister() unregister} the subscription when the
|
||||
* corresponding plugin is disabled.</p>
|
||||
*
|
||||
* @param <T> the event class
|
||||
* @param plugin a plugin instance to bind the subscription to.
|
||||
* @param eventClass the event class
|
||||
* @param handler the event handler
|
||||
* @return an event handler instance representing this subscription
|
||||
*/
|
||||
@NonNull <T extends LuckPermsEvent> EventHandler<T> subscribe(Object plugin, @NonNull Class<T> eventClass, @NonNull Consumer<? super T> handler);
|
||||
|
||||
/**
|
||||
* Gets a set of all registered handlers for a given event.
|
||||
*
|
||||
* @param eventClass the event to find handlers for
|
||||
* @param <T> the event class
|
||||
* @return an immutable set of event handlers
|
||||
*/
|
||||
@NonNull <T extends LuckPermsEvent> Set<EventHandler<T>> getHandlers(@NonNull Class<T> eventClass);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Represents a subscription to a {@link LuckPermsEvent}.
|
||||
*
|
||||
* @param <T> the event class
|
||||
*/
|
||||
public interface EventHandler<T extends LuckPermsEvent> extends AutoCloseable {
|
||||
|
||||
/**
|
||||
* Gets the class this handler is listening to
|
||||
*
|
||||
* @return the event class
|
||||
*/
|
||||
@NonNull Class<T> getEventClass();
|
||||
|
||||
/**
|
||||
* Returns true if this handler is active
|
||||
*
|
||||
* @return true if this handler is still active
|
||||
*/
|
||||
boolean isActive();
|
||||
|
||||
/**
|
||||
* Unregisters this handler from the event bus
|
||||
*
|
||||
* @return true if the handler wasn't already unregistered
|
||||
*/
|
||||
boolean unregister();
|
||||
|
||||
/**
|
||||
* Gets the event consumer responsible for handling the event
|
||||
*
|
||||
* @return the event consumer
|
||||
*/
|
||||
@NonNull Consumer<? super T> getConsumer();
|
||||
|
||||
/**
|
||||
* Gets the number of times this handler has been called
|
||||
*
|
||||
* @return the number of times this handler has been called
|
||||
*/
|
||||
int getCallCount();
|
||||
|
||||
@Override
|
||||
default void close() {
|
||||
unregister();
|
||||
}
|
||||
}
|
||||
+19
-26
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,38 +27,28 @@ package me.lucko.luckperms.api.event;
|
||||
|
||||
import me.lucko.luckperms.api.LuckPermsApi;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Abstract LuckPerms Event class.
|
||||
* A superinterface for all LuckPerms events.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public abstract class LPEvent {
|
||||
public interface LuckPermsEvent {
|
||||
|
||||
/**
|
||||
* A link to the API instance provided for convenience.
|
||||
* Get the API instance this event was dispatched from
|
||||
*
|
||||
* @return the api instance
|
||||
*/
|
||||
private LuckPermsApi api = null;
|
||||
@NonNull LuckPermsApi getApi();
|
||||
|
||||
/**
|
||||
* A friendly name of the event
|
||||
* Gets the type of the event.
|
||||
*
|
||||
* @return the type of the event
|
||||
* @since 4.4
|
||||
*/
|
||||
private final String eventName;
|
||||
|
||||
protected LPEvent(String eventName) {
|
||||
this.eventName = eventName;
|
||||
}
|
||||
|
||||
public String getEventName() {
|
||||
return eventName;
|
||||
}
|
||||
|
||||
public LuckPermsApi getApi() {
|
||||
return api;
|
||||
}
|
||||
|
||||
public void setApi(LuckPermsApi api) {
|
||||
if (this.api != null) {
|
||||
throw new IllegalStateException("API can only be set once.");
|
||||
}
|
||||
this.api = api;
|
||||
}
|
||||
@NonNull Class<? extends LuckPermsEvent> getEventType();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Represents the position of a parameter within an event.
|
||||
*
|
||||
* <p>This is an implementation detail and should not be relied upon.</p>
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Param {
|
||||
|
||||
/**
|
||||
* Gets the index of the parameter.
|
||||
*
|
||||
* @return the index
|
||||
*/
|
||||
int value();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event;
|
||||
|
||||
import me.lucko.luckperms.api.event.source.Source;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Represents an event with a {@link Source}.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface Sourced {
|
||||
|
||||
/**
|
||||
* Gets the events source.
|
||||
*
|
||||
* <p>Never returns null. In situations where the source is unknown, a
|
||||
* {@link Source} with type {@link Source.Type#UNKNOWN} is returned.</p>
|
||||
*
|
||||
* @return the source
|
||||
*/
|
||||
@NonNull @Param(-1) Source getSource();
|
||||
|
||||
}
|
||||
+21
-12
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,20 +23,26 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.commands;
|
||||
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
|
||||
import java.util.UUID;
|
||||
package me.lucko.luckperms.api.event.cause;
|
||||
|
||||
/**
|
||||
* Wrapper interface to represent a CommandSender/CommandSource within the luckperms-common command implementations.
|
||||
* The cause of a group/track creation
|
||||
*/
|
||||
public interface Sender {
|
||||
public enum CreationCause {
|
||||
|
||||
String getName();
|
||||
UUID getUuid();
|
||||
void sendMessage(String s);
|
||||
boolean hasPermission(Permission permission);
|
||||
/**
|
||||
* The creation was caused by a command
|
||||
*/
|
||||
COMMAND,
|
||||
|
||||
/**
|
||||
* The creation was caused by an API call
|
||||
*/
|
||||
API,
|
||||
|
||||
/**
|
||||
* The creation was caused by a LuckPerms internal
|
||||
*/
|
||||
INTERNAL
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.cause;
|
||||
|
||||
/**
|
||||
* The cause of a group/track deletion
|
||||
*/
|
||||
public enum DeletionCause {
|
||||
|
||||
/**
|
||||
* The deletion was caused by a command
|
||||
*/
|
||||
COMMAND,
|
||||
|
||||
/**
|
||||
* The deletion was caused by an API call
|
||||
*/
|
||||
API,
|
||||
|
||||
/**
|
||||
* The deletion was caused by a LuckPerms internal
|
||||
*/
|
||||
INTERNAL
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.events;
|
||||
|
||||
import me.lucko.luckperms.api.PermissionHolder;
|
||||
import me.lucko.luckperms.api.event.AbstractPermissionRemoveEvent;
|
||||
|
||||
/**
|
||||
* Called whenever a user or group is removed from / stops inheriting another group
|
||||
*/
|
||||
public class GroupRemoveEvent extends AbstractPermissionRemoveEvent {
|
||||
|
||||
/**
|
||||
* The name of group being removed from the target.
|
||||
* Be aware that this group may have already been deleted, and and instance may therefore not exist internally.
|
||||
*/
|
||||
private final String group;
|
||||
|
||||
public GroupRemoveEvent(PermissionHolder target, String group, String server, String world, boolean temporary) {
|
||||
super("Group Remove Event", target, server, world, temporary);
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.events;
|
||||
|
||||
import me.lucko.luckperms.api.PermissionHolder;
|
||||
import me.lucko.luckperms.api.event.TargetedEvent;
|
||||
|
||||
/**
|
||||
* Called when a permission expires for an object.
|
||||
* @deprecated in favour of {@link PermissionNodeExpireEvent}
|
||||
*/
|
||||
@Deprecated
|
||||
public class PermissionExpireEvent extends TargetedEvent<PermissionHolder> {
|
||||
|
||||
private final String node;
|
||||
|
||||
public PermissionExpireEvent(PermissionHolder target, String node) {
|
||||
super("Permission Expire Event", target);
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
public String getNode() {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.events;
|
||||
|
||||
import me.lucko.luckperms.api.PermissionHolder;
|
||||
import me.lucko.luckperms.api.event.AbstractPermissionRemoveEvent;
|
||||
|
||||
/**
|
||||
* Called whenever a user or group has a permission unset.
|
||||
* @deprecated in favour of {@link PermissionNodeUnsetEvent}
|
||||
*/
|
||||
@Deprecated
|
||||
public class PermissionUnsetEvent extends AbstractPermissionRemoveEvent {
|
||||
|
||||
private final String node;
|
||||
|
||||
public PermissionUnsetEvent(PermissionHolder target, String node, String server, String world, boolean temporary) {
|
||||
super("Permission Unset Event", target, server, world, temporary);
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
public String getNode() {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.group;
|
||||
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.caching.GroupData;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Called when a groups {@link GroupData} is loaded.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface GroupCacheLoadEvent extends LuckPermsEvent {
|
||||
|
||||
/**
|
||||
* Gets the group whose data was loaded
|
||||
*
|
||||
* @return the group
|
||||
*/
|
||||
@NonNull @Param(0) Group getGroup();
|
||||
|
||||
/**
|
||||
* Gets the data that was loaded
|
||||
*
|
||||
* @return the loaded data
|
||||
*/
|
||||
@NonNull @Param(1) GroupData getLoadedData();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.group;
|
||||
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Called when a group is created
|
||||
*/
|
||||
public interface GroupCreateEvent extends LuckPermsEvent {
|
||||
|
||||
/**
|
||||
* Gets the new group
|
||||
*
|
||||
* @return the new group
|
||||
*/
|
||||
@NonNull @Param(0) Group getGroup();
|
||||
|
||||
/**
|
||||
* Gets the cause of the creation
|
||||
*
|
||||
* @return the cause of the creation
|
||||
*/
|
||||
@NonNull @Param(1) CreationCause getCause();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.group;
|
||||
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.caching.GroupData;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Called when a groups cached data is refreshed
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface GroupDataRecalculateEvent extends LuckPermsEvent {
|
||||
|
||||
/**
|
||||
* Gets the group whose data was recalculated
|
||||
*
|
||||
* @return the group
|
||||
*/
|
||||
@NonNull @Param(0) Group getGroup();
|
||||
|
||||
/**
|
||||
* Gets the data that was recalculated
|
||||
*
|
||||
* @return the data
|
||||
*/
|
||||
@NonNull @Param(1) GroupData getData();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.group;
|
||||
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Called when a group is deleted
|
||||
*/
|
||||
public interface GroupDeleteEvent extends LuckPermsEvent {
|
||||
|
||||
/**
|
||||
* Gets the name of the deleted group
|
||||
*
|
||||
* @return the name of the deleted group
|
||||
*/
|
||||
@NonNull @Param(0) String getGroupName();
|
||||
|
||||
/**
|
||||
* Gets an immutable copy of the groups existing data
|
||||
*
|
||||
* @return a copy of the groups existing data
|
||||
*/
|
||||
@NonNull @Param(1) Set<Node> getExistingData();
|
||||
|
||||
/**
|
||||
* Gets the cause of the deletion
|
||||
*
|
||||
* @return the cause of the deletion
|
||||
*/
|
||||
@NonNull @Param(2) DeletionCause getCause();
|
||||
|
||||
}
|
||||
+10
-15
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,23 +23,15 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event;
|
||||
package me.lucko.luckperms.api.event.group;
|
||||
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
|
||||
/**
|
||||
* Represents an event acting upon a user.
|
||||
* Called when all groups have been loaded in from storage.
|
||||
*
|
||||
* <p>Usually only called on startup and in sync tasks.</p>
|
||||
*/
|
||||
public class UserEvent extends LPEvent {
|
||||
public interface GroupLoadAllEvent extends LuckPermsEvent {
|
||||
|
||||
private final User user;
|
||||
|
||||
protected UserEvent(String eventName, User user) {
|
||||
super(eventName);
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
}
|
||||
+17
-16
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,28 +23,26 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.events;
|
||||
package me.lucko.luckperms.api.event.group;
|
||||
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.PermissionHolder;
|
||||
import me.lucko.luckperms.api.event.AbstractPermissionAddEvent;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Called whenever a user or group is added to / starts to inherit another group
|
||||
* Called when a group is loaded into memory from the storage.
|
||||
*
|
||||
* Note that this event is not the same as {@link GroupCreateEvent}
|
||||
*/
|
||||
public class GroupAddEvent extends AbstractPermissionAddEvent {
|
||||
public interface GroupLoadEvent extends LuckPermsEvent {
|
||||
|
||||
/**
|
||||
* The group being added to the target
|
||||
* Gets the group that was loaded
|
||||
*
|
||||
* @return the group that was loaded
|
||||
*/
|
||||
private final Group group;
|
||||
@NonNull @Param(0) Group getGroup();
|
||||
|
||||
public GroupAddEvent(PermissionHolder target, Group group, String server, String world, long expiry) {
|
||||
super("Group Add Event", target, server, world, expiry);
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public Group getGroup() {
|
||||
return group;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.log;
|
||||
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.Cancellable;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Called when a log entry is about to be sent to notifiable players on the platform
|
||||
*/
|
||||
public interface LogBroadcastEvent extends LuckPermsEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the log entry to be broadcasted
|
||||
*
|
||||
* @return the log entry to be broadcasted
|
||||
*/
|
||||
@NonNull @Param(0) LogEntry getEntry();
|
||||
|
||||
/**
|
||||
* Gets where the log entry originated from.
|
||||
*
|
||||
* @return the origin of the log
|
||||
* @since 3.3
|
||||
*/
|
||||
@NonNull @Param(1) Origin getOrigin();
|
||||
|
||||
/**
|
||||
* Represents where a log entry is from
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
enum Origin {
|
||||
|
||||
/**
|
||||
* Marks a log entry which originated from the current server instance
|
||||
*/
|
||||
LOCAL,
|
||||
|
||||
/**
|
||||
* Marks a log entry which originated from an API call on the current server instance
|
||||
*/
|
||||
LOCAL_API,
|
||||
|
||||
/**
|
||||
* Marks a log entry which was sent to this server via the messaging service
|
||||
*/
|
||||
REMOTE
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.log;
|
||||
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.Cancellable;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Called when a log is about to be published to the network via the MessagingService
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
public interface LogNetworkPublishEvent extends LuckPermsEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the ID of the log entry being published
|
||||
*
|
||||
* @return the id of the log entry being published
|
||||
*/
|
||||
@NonNull @Param(0) UUID getLogId();
|
||||
|
||||
/**
|
||||
* Gets the log entry to be published
|
||||
*
|
||||
* @return the log entry to be published
|
||||
*/
|
||||
@NonNull @Param(1) LogEntry getEntry();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.log;
|
||||
|
||||
import me.lucko.luckperms.api.Entity;
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.Cancellable;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Called when a log entry is about to be sent to specific notifiable object on
|
||||
* the platform.
|
||||
*
|
||||
* <p>This event is not called for players without the notify permission,
|
||||
* but is called for objects which are ignoring log notifications (called with
|
||||
* the cancelled flag set to true).</p>
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface LogNotifyEvent extends LuckPermsEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the log entry to be sent
|
||||
*
|
||||
* @return the log entry to be sent
|
||||
*/
|
||||
@NonNull @Param(0) LogEntry getEntry();
|
||||
|
||||
/**
|
||||
* Gets where the log entry originated from.
|
||||
*
|
||||
* @return the origin of the log
|
||||
*/
|
||||
@NonNull @Param(1) Origin getOrigin();
|
||||
|
||||
/**
|
||||
* Gets the object to be notified.
|
||||
*
|
||||
* @return the object to notify
|
||||
*/
|
||||
@NonNull @Param(2) Entity getNotifiable();
|
||||
|
||||
/**
|
||||
* Represents where a log entry is from
|
||||
*/
|
||||
enum Origin {
|
||||
|
||||
/**
|
||||
* Marks a log entry which originated from the current server instance
|
||||
*/
|
||||
LOCAL,
|
||||
|
||||
/**
|
||||
* Marks a log entry which originated from an API call on the current server instance
|
||||
*/
|
||||
LOCAL_API,
|
||||
|
||||
/**
|
||||
* Marks a log entry which was sent to this server via the messaging service
|
||||
*/
|
||||
REMOTE
|
||||
}
|
||||
|
||||
}
|
||||
+16
-18
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,30 +23,25 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.events;
|
||||
package me.lucko.luckperms.api.event.log;
|
||||
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.CancellableEvent;
|
||||
import me.lucko.luckperms.api.event.Cancellable;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Called before a LogEntry is broadcasted to players only with the notify permission.
|
||||
* The log entry will still be recorded in the datastore, regardless of the cancellation state of this event.
|
||||
* Cancelling this event only stops the broadcast.
|
||||
* Called when a log is about to be published to the storage file/table
|
||||
*/
|
||||
public class LogNotifyEvent extends CancellableEvent {
|
||||
public interface LogPublishEvent extends LuckPermsEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* The log entry to be broadcasted
|
||||
* Gets the log entry to be published
|
||||
*
|
||||
* @return the log entry to be published
|
||||
*/
|
||||
private final LogEntry entry;
|
||||
|
||||
public LogNotifyEvent(LogEntry entry) {
|
||||
super("Log Notify Event");
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
public LogEntry getEntry() {
|
||||
return entry;
|
||||
}
|
||||
@NonNull @Param(0) LogEntry getEntry();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.log;
|
||||
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Called when a log entry is received via the MessagingService
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
public interface LogReceiveEvent extends LuckPermsEvent {
|
||||
|
||||
/**
|
||||
* Gets the ID of the log entry being received
|
||||
*
|
||||
* @return the id of the log entry being received
|
||||
*/
|
||||
@NonNull @Param(0) UUID getLogId();
|
||||
|
||||
/**
|
||||
* Gets the log entry being received
|
||||
*
|
||||
* @return the log entry being received
|
||||
*/
|
||||
@NonNull @Param(1) LogEntry getEntry();
|
||||
|
||||
}
|
||||
+16
-14
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,24 +23,23 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event;
|
||||
package me.lucko.luckperms.api.event.node;
|
||||
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.PermissionHolder;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* @since 2.6
|
||||
* Called when a node is added to a holder
|
||||
*/
|
||||
public class AbstractPermissionEvent extends TargetedEvent<PermissionHolder> {
|
||||
public interface NodeAddEvent extends NodeMutateEvent {
|
||||
|
||||
private final Node node;
|
||||
/**
|
||||
* Gets the node that was added
|
||||
*
|
||||
* @return the node that was added
|
||||
*/
|
||||
@NonNull @Param(3) Node getNode();
|
||||
|
||||
protected AbstractPermissionEvent(String eventName, PermissionHolder target, Node node) {
|
||||
super(eventName, target);
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
public Node getNode() {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
+8
-5
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,11 +23,11 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.exceptions;
|
||||
package me.lucko.luckperms.api.event.node;
|
||||
|
||||
/**
|
||||
* Thrown when a permission holding object already has a permission, is already a member of a group, or when a track
|
||||
* already contains a group.
|
||||
* Called when a holder has their nodes cleared
|
||||
*/
|
||||
public class ObjectAlreadyHasException extends MembershipException {
|
||||
public interface NodeClearEvent extends NodeMutateEvent {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.node;
|
||||
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.PermissionHolder;
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Called when a node is added to/removed from a user/group
|
||||
*/
|
||||
public interface NodeMutateEvent extends LuckPermsEvent {
|
||||
|
||||
/**
|
||||
* Gets the target of the event
|
||||
*
|
||||
* @return the event target
|
||||
*/
|
||||
@NonNull @Param(0) PermissionHolder getTarget();
|
||||
|
||||
/**
|
||||
* Gets an immutable copy of the holders data before the change
|
||||
*
|
||||
* @return the data before the change
|
||||
*/
|
||||
@NonNull @Param(1) Set<Node> getDataBefore();
|
||||
|
||||
/**
|
||||
* Gets an immutable copy of the holders data after the change
|
||||
*
|
||||
* @return the data after the change
|
||||
*/
|
||||
@NonNull @Param(2) Set<Node> getDataAfter();
|
||||
|
||||
/**
|
||||
* Gets whether the target of this event is a {@link me.lucko.luckperms.api.User}
|
||||
*
|
||||
* <p>This is equivalent to checking if getTarget() instanceof User</p>
|
||||
*
|
||||
* @return if the event is targeting a user
|
||||
*/
|
||||
default boolean isUser() {
|
||||
return getTarget() instanceof User;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether the target of this event is a {@link me.lucko.luckperms.api.Group}
|
||||
*
|
||||
* <p>This is equivalent to checking if getTarget() instanceof Group</p>
|
||||
*
|
||||
* @return if the event is targeting a group
|
||||
*/
|
||||
default boolean isGroup() {
|
||||
return getTarget() instanceof Group;
|
||||
}
|
||||
|
||||
}
|
||||
+18
-10
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,18 +23,23 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.events;
|
||||
package me.lucko.luckperms.api.event.node;
|
||||
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.PermissionHolder;
|
||||
import me.lucko.luckperms.api.event.AbstractPermissionEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Called when a temporary permission node expires
|
||||
* @since 2.6
|
||||
* Called when a node is removed from a holder
|
||||
*/
|
||||
public class PermissionNodeExpireEvent extends AbstractPermissionEvent {
|
||||
public PermissionNodeExpireEvent(PermissionHolder target, Node node) {
|
||||
super("Permission Node Expire Event", target, node);
|
||||
}
|
||||
public interface NodeRemoveEvent extends NodeMutateEvent {
|
||||
|
||||
/**
|
||||
* Gets the node that was removed
|
||||
*
|
||||
* @return the node that was removed
|
||||
*/
|
||||
@NonNull @Param(3) Node getNode();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.player;
|
||||
|
||||
import me.lucko.luckperms.api.PlayerSaveResult;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
import me.lucko.luckperms.api.manager.UserManager;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Called when player data is saved to the storage.
|
||||
*
|
||||
* <p>Data can be saved using {@link UserManager#savePlayerData(UUID, String)}.</p>
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public interface PlayerDataSaveEvent extends LuckPermsEvent {
|
||||
|
||||
/**
|
||||
* Gets the unique ID that was saved.
|
||||
*
|
||||
* @return the uuid
|
||||
*/
|
||||
@NonNull @Param(0) UUID getUuid();
|
||||
|
||||
/**
|
||||
* Gets the username that was saved.
|
||||
*
|
||||
* @return the username
|
||||
*/
|
||||
@NonNull @Param(1) String getUsername();
|
||||
|
||||
/**
|
||||
* Gets the result of the operation.
|
||||
*
|
||||
* @return the result
|
||||
*/
|
||||
@NonNull @Param(2) PlayerSaveResult getResult();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.player;
|
||||
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Called when LuckPerms has finished processing a Player's initial connection.
|
||||
*
|
||||
* <p>This event will always execute during the platforms async connection
|
||||
* event. The LuckPerms platform listener processing the connection will block
|
||||
* while this event is posted.</p>
|
||||
*
|
||||
* <p>This, among other things, allows you to wait until permission data is
|
||||
* loaded for a User during the BungeeCord 'LoginEvent', as event priorities are
|
||||
* ignored by the current implementation.</p>
|
||||
*
|
||||
* <p>The implementation will make an attempt to ensure this event is called
|
||||
* for all connections, even if the operation to load User data was not
|
||||
* successful. Note that LuckPerms will usually cancel the platform connection
|
||||
* event if data could not be loaded.</p>
|
||||
*
|
||||
* @since 4.4
|
||||
*/
|
||||
public interface PlayerLoginProcessEvent extends LuckPermsEvent {
|
||||
|
||||
/**
|
||||
* Gets the UUID of the connection which was processed
|
||||
*
|
||||
* @return the uuid of the connection which was processed
|
||||
*/
|
||||
@NonNull @Param(0) UUID getUuid();
|
||||
|
||||
/**
|
||||
* Gets the username of the connection which was processed
|
||||
*
|
||||
* @return the username of the connection which was processed
|
||||
*/
|
||||
@NonNull @Param(1) String getUsername();
|
||||
|
||||
/**
|
||||
* Gets if the login was processed successfully.
|
||||
*
|
||||
* @return true if the login was successful
|
||||
*/
|
||||
default boolean wasSuccessful() {
|
||||
return getUser() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the resultant User instance which was loaded.
|
||||
*
|
||||
* <p>Returns {@code null} if the login was not processed
|
||||
* {@link #wasSuccessful() successfully.}</p>
|
||||
*
|
||||
* @return the user instance
|
||||
*/
|
||||
@Nullable @Param(2) User getUser();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.source;
|
||||
|
||||
import me.lucko.luckperms.api.Entity;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Represents an {@link Entity} which was the {@link Source} of something.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface EntitySource extends Source {
|
||||
|
||||
/**
|
||||
* Gets the entity.
|
||||
*
|
||||
* @return the entity
|
||||
*/
|
||||
@NonNull Entity getEntity();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.source;
|
||||
|
||||
import me.lucko.luckperms.api.Entity;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Represents the source of an event.
|
||||
*
|
||||
* <p>Could also be described as the "thing" that caused an event to occur.</p>
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface Source {
|
||||
|
||||
/**
|
||||
* Gets the source type
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
@NonNull Type getType();
|
||||
|
||||
/**
|
||||
* Represents a type of source
|
||||
*/
|
||||
enum Type {
|
||||
|
||||
/**
|
||||
* Represents an {@link Entity} source
|
||||
*
|
||||
* @see EntitySource
|
||||
*/
|
||||
ENTITY,
|
||||
|
||||
/**
|
||||
* Represents an unknown source
|
||||
*/
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
}
|
||||
+9
-9
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,16 +23,13 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.data;
|
||||
package me.lucko.luckperms.api.event.sync;
|
||||
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link DatastoreConfiguration}. This is now used by multiple datastores, not just MySQL.
|
||||
* Called when the configuration is reloaded
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MySQLConfiguration {
|
||||
public interface ConfigReloadEvent extends LuckPermsEvent {
|
||||
|
||||
String getAddress();
|
||||
String getDatabase();
|
||||
String getUsername();
|
||||
String getPassword();
|
||||
}
|
||||
+8
-9
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,17 +23,13 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.events;
|
||||
package me.lucko.luckperms.api.event.sync;
|
||||
|
||||
import me.lucko.luckperms.api.event.LPEvent;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
|
||||
/**
|
||||
* Called after the sync task has ran.
|
||||
* Called when an sync task has been completed
|
||||
*/
|
||||
public class PostSyncEvent extends LPEvent {
|
||||
|
||||
public PostSyncEvent() {
|
||||
super("Post Sync Event");
|
||||
}
|
||||
public interface PostSyncEvent extends LuckPermsEvent {
|
||||
|
||||
}
|
||||
+20
-20
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,29 +23,26 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.constants;
|
||||
package me.lucko.luckperms.api.event.sync;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import me.lucko.luckperms.api.event.Cancellable;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@UtilityClass
|
||||
public class Constants {
|
||||
/**
|
||||
* Called before a received network sync task runs
|
||||
*/
|
||||
public interface PreNetworkSyncEvent extends LuckPermsEvent, Cancellable {
|
||||
|
||||
@Getter
|
||||
private static final UUID consoleUUID = UUID.fromString("00000000-0000-0000-0000-000000000000");
|
||||
|
||||
@Getter
|
||||
private static final String consoleName = "Console";
|
||||
|
||||
@Getter
|
||||
private static final UUID importerUUID = UUID.fromString("11111111-1111-1111-1111-111111111111");
|
||||
|
||||
@Getter
|
||||
private static final String importerName = "Import";
|
||||
|
||||
@Getter
|
||||
private static final String logFormat = "&8(&e%s&8) [&a%s&8] (&b%s&8) &7--> &f%s";
|
||||
/**
|
||||
* Gets the ID of the sync request
|
||||
*
|
||||
* @return the id of the sync request
|
||||
*/
|
||||
@NonNull @Param(0) UUID getSyncId();
|
||||
|
||||
}
|
||||
+10
-11
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,18 +23,14 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api;
|
||||
package me.lucko.luckperms.api.event.sync;
|
||||
|
||||
import me.lucko.luckperms.api.event.Cancellable;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
|
||||
/**
|
||||
* A wrapper interface for platform logger instances.
|
||||
*
|
||||
* <p> Bukkit/Bungee both use java.util.logging, and Sponge uses org.slf4j. This class wraps those classes so the commons
|
||||
* module can access a logger.
|
||||
* Called before a sync task runs
|
||||
*/
|
||||
public interface Logger {
|
||||
|
||||
void info(String s);
|
||||
void warn(String s);
|
||||
void severe(String s);
|
||||
public interface PreSyncEvent extends LuckPermsEvent, Cancellable {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.track;
|
||||
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Called when a track is created
|
||||
*/
|
||||
public interface TrackCreateEvent extends LuckPermsEvent {
|
||||
|
||||
/**
|
||||
* Gets the new track
|
||||
*
|
||||
* @return the new track
|
||||
*/
|
||||
@NonNull @Param(0) Track getTrack();
|
||||
|
||||
/**
|
||||
* Gets the cause of the creation
|
||||
*
|
||||
* @return the cause of the creation
|
||||
*/
|
||||
@NonNull @Param(1) CreationCause getCause();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.track;
|
||||
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Called when a track is deleted
|
||||
*/
|
||||
public interface TrackDeleteEvent extends LuckPermsEvent {
|
||||
|
||||
/**
|
||||
* Gets the name of the deleted track
|
||||
*
|
||||
* @return the name of the deleted track
|
||||
*/
|
||||
@NonNull @Param(0) String getTrackName();
|
||||
|
||||
/**
|
||||
* Gets an immutable copy of the tracks existing data
|
||||
*
|
||||
* @return a copy of the tracks existing data
|
||||
*/
|
||||
@NonNull @Param(1) List<String> getExistingData();
|
||||
|
||||
/**
|
||||
* Gets the cause of the deletion
|
||||
*
|
||||
* @return the cause of the deletion
|
||||
*/
|
||||
@NonNull @Param(2) DeletionCause getCause();
|
||||
|
||||
}
|
||||
+11
-15
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,22 +23,15 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event;
|
||||
package me.lucko.luckperms.api.event.track;
|
||||
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
|
||||
/**
|
||||
* Represents an event acting upon a target
|
||||
* @param <T> the target type
|
||||
* Called when all tracks have been loaded in from storage.
|
||||
*
|
||||
* <p>Usually only called on startup and in sync tasks.</p>
|
||||
*/
|
||||
public class TargetedEvent<T> extends LPEvent {
|
||||
public interface TrackLoadAllEvent extends LuckPermsEvent {
|
||||
|
||||
private final T target;
|
||||
|
||||
protected TargetedEvent(String eventName, T target) {
|
||||
super(eventName);
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public T getTarget() {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.track;
|
||||
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Called when a track is loaded into memory from the storage.
|
||||
*
|
||||
* Note that this event is not the same as {@link TrackCreateEvent}
|
||||
*/
|
||||
public interface TrackLoadEvent extends LuckPermsEvent {
|
||||
|
||||
/**
|
||||
* Gets the track that was loaded
|
||||
*
|
||||
* @return the track that was loaded
|
||||
*/
|
||||
@NonNull @Param(0) Track getTrack();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.track.mutate;
|
||||
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Called when a group is added to a track
|
||||
*/
|
||||
public interface TrackAddGroupEvent extends TrackMutateEvent {
|
||||
|
||||
/**
|
||||
* Gets the group that was added
|
||||
*
|
||||
* @return the group that was added
|
||||
*/
|
||||
@NonNull @Param(3) String getGroup();
|
||||
|
||||
}
|
||||
+8
-5
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,11 +23,11 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.exceptions;
|
||||
package me.lucko.luckperms.api.event.track.mutate;
|
||||
|
||||
/**
|
||||
* Thrown when a permission holding object doesn't / already has a permission or isn't / is already is a member of a group
|
||||
* @since 2.7
|
||||
* Called when a track is cleared
|
||||
*/
|
||||
public abstract class MembershipException extends Exception {
|
||||
public interface TrackClearEvent extends TrackMutateEvent {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.track.mutate;
|
||||
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Called when a track is changed
|
||||
*/
|
||||
public interface TrackMutateEvent extends LuckPermsEvent {
|
||||
|
||||
/**
|
||||
* Gets the track that was mutated
|
||||
*
|
||||
* @return the track that was mutated
|
||||
*/
|
||||
@NonNull @Param(0) Track getTrack();
|
||||
|
||||
/**
|
||||
* Gets an immutable copy of the tracks data before the change
|
||||
*
|
||||
* @return the data before the change
|
||||
*/
|
||||
@NonNull @Param(1) List<String> getDataBefore();
|
||||
|
||||
/**
|
||||
* Gets an immutable copy of the tracks data after the change
|
||||
*
|
||||
* @return the data after the change
|
||||
*/
|
||||
@NonNull @Param(2) List<String> getDataAfter();
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.track.mutate;
|
||||
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Called when a group is removed from a track
|
||||
*/
|
||||
public interface TrackRemoveGroupEvent extends TrackMutateEvent {
|
||||
|
||||
/**
|
||||
* Gets the group that was removed
|
||||
*
|
||||
* @return the group that was removed
|
||||
*/
|
||||
@NonNull @Param(3) String getGroup();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.user;
|
||||
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.caching.UserData;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Called when a users {@link UserData} is loaded.
|
||||
*/
|
||||
public interface UserCacheLoadEvent extends LuckPermsEvent {
|
||||
|
||||
/**
|
||||
* Gets the user whose data was loaded
|
||||
*
|
||||
* @return the user
|
||||
*/
|
||||
@NonNull @Param(0) User getUser();
|
||||
|
||||
/**
|
||||
* Gets the data that was loaded
|
||||
*
|
||||
* @return the loaded data
|
||||
*/
|
||||
@NonNull @Param(1) UserData getLoadedData();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.api.event.user;
|
||||
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.caching.UserData;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Called when a users cached data is refreshed
|
||||
*/
|
||||
public interface UserDataRecalculateEvent extends LuckPermsEvent {
|
||||
|
||||
/**
|
||||
* Gets the user whose data was recalculated
|
||||
*
|
||||
* @return the user
|
||||
*/
|
||||
@NonNull @Param(0) User getUser();
|
||||
|
||||
/**
|
||||
* Gets the data that was recalculated
|
||||
*
|
||||
* @return the data
|
||||
*/
|
||||
@NonNull @Param(1) UserData getData();
|
||||
|
||||
}
|
||||
Loaded 100 of 895 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user