mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2026-11-25 08:44:21 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5577e3f590 | ||
|
|
ffe6c24b53 | ||
|
|
4e4982a98d | ||
|
|
7f4f9bb917 | ||
|
|
8d8024ba5e | ||
|
|
2e16b15b0e | ||
|
|
1ebed37297 | ||
|
|
ff37ad176b | ||
|
|
d0c5d89e91 | ||
|
|
f49446011a | ||
|
|
d762a0aaa6 | ||
|
|
2dc211a91e | ||
|
|
2c62de9658 | ||
|
|
494ab6787f | ||
|
|
b81e8a40a4 | ||
|
|
2fd2f4fedb | ||
|
|
493e5d08be | ||
|
|
62a834e145 | ||
|
|
241f13c8f1 | ||
|
|
98ea255667 | ||
|
|
420ec2bf1a | ||
|
|
364a494ac6 | ||
|
|
821d1cb8dd | ||
|
|
544ffbad19 | ||
|
|
4fa6cd2577 | ||
|
|
37d1f5efab | ||
|
|
7cd8e8bf5b | ||
|
|
8eed4558f4 | ||
|
|
62ca2d9c79 | ||
|
|
c7a0d7026c | ||
|
|
ce74813ce5 | ||
|
|
d1511e43f2 | ||
|
|
6ef749c76a | ||
|
|
8846932cb6 | ||
|
|
12b861db3f | ||
|
|
0a50df6557 | ||
|
|
3726f6de41 | ||
|
|
d1ca7684d6 | ||
|
|
512b621a7a | ||
|
|
2cf919a17a | ||
|
|
46072eb465 | ||
|
|
ae63a42c2e | ||
|
|
8773ec07ab | ||
|
|
287cc308d6 | ||
|
|
beeb4fa169 | ||
|
|
4ef3d50965 | ||
|
|
dae64fc8c4 | ||
|
|
215031a1f3 | ||
|
|
85d2f0b51f | ||
|
|
d91355e4d6 | ||
|
|
1a690dabd7 | ||
|
|
526448ce40 | ||
|
|
43d04a97f5 | ||
|
|
307614e704 | ||
|
|
f6c0794691 | ||
|
|
83db00aef8 | ||
|
|
22252fa46d | ||
|
|
7b8426977a | ||
|
|
d9912cb93f | ||
|
|
5db999f995 | ||
|
|
b744e35ad8 | ||
|
|
b6769811a2 | ||
|
|
1d9fc568e4 | ||
|
|
3c0d1ba7a1 | ||
|
|
78a74510cf | ||
|
|
d3ae3324fa | ||
|
|
4b97c9419e | ||
|
|
db830a0bef | ||
|
|
797c195424 | ||
|
|
4788290615 | ||
|
|
d0c016f6b7 | ||
|
|
9b1c73ed23 | ||
|
|
048768007d | ||
|
|
ec7a5321a6 | ||
|
|
c396323308 | ||
|
|
6fc2321fad | ||
|
|
a0d04790a5 | ||
|
|
c4154c09da | ||
|
|
8eed3131f2 | ||
|
|
e5c4b710f6 | ||
|
|
2ccffc6e6d | ||
|
|
fc69002c86 | ||
|
|
e3a6db5f97 | ||
|
|
6d8077ffd0 | ||
|
|
784161d66d | ||
|
|
115f793733 | ||
|
|
2cb5e437fd | ||
|
|
8c57c2b46d | ||
|
|
879a88a398 | ||
|
|
7e50c3c777 | ||
|
|
4b1cf51530 | ||
|
|
de24817d9c | ||
|
|
085e7af681 | ||
|
|
1aabd7610e | ||
|
|
ef31db1431 | ||
|
|
757e9d6be6 | ||
|
|
b3a028e3ca | ||
|
|
e222e4e98c | ||
|
|
1213e58240 | ||
|
|
b7ff0824b9 | ||
|
|
7b5917660c | ||
|
|
1544487e92 | ||
|
|
c19ef84116 | ||
|
|
e8c4a55dc3 | ||
|
|
97d6aaed5c | ||
|
|
fe77834cef | ||
|
|
2da6298c53 | ||
|
|
e111270aed | ||
|
|
e07f8c0fbe | ||
|
|
90246afd03 | ||
|
|
9809e591ad | ||
|
|
26973461e7 | ||
|
|
759ec5d499 | ||
|
|
58ab3c325c | ||
|
|
44c8c67803 | ||
|
|
acb56d683a | ||
|
|
5dda522a62 | ||
|
|
79091c726b | ||
|
|
e5be06e07b | ||
|
|
f63992e209 | ||
|
|
9988011308 | ||
|
|
8584a9b72c | ||
|
|
42c8cb1354 | ||
|
|
aaeaf5cfa0 | ||
|
|
45b4e1463f | ||
|
|
be92a67544 | ||
|
|
5e0b8ebdf6 | ||
|
|
9d4ccd33e1 | ||
|
|
f5c42c70e5 | ||
|
|
dcc4656e5e | ||
|
|
ee2de3cff1 | ||
|
|
f96518b8e4 | ||
|
|
dac59966aa | ||
|
|
8115fbaa98 | ||
|
|
8b97439ffc | ||
|
|
fa83986250 | ||
|
|
e1b16465f8 | ||
|
|
57619dacb1 | ||
|
|
64e54d89eb |
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
patreon: luckperms
|
||||||
+2
-2
@@ -19,8 +19,8 @@ LuckPerms loosely follows the [Google Java Style Guide](https://google.github.io
|
|||||||
If you're considering submitting a substantial pull request, please open an issue so we can discuss the change before starting work on the contribution. Most pull requests are happily accepted, but larger changes may have an inpact on the maintainability of the project, and require more consideration.
|
If you're considering submitting a substantial pull request, please open an issue so we can discuss the change before starting work on the contribution. Most pull requests are happily accepted, but larger changes may have an inpact on the maintainability of the project, and require more consideration.
|
||||||
|
|
||||||
#### Project Layout
|
#### Project Layout
|
||||||
The project is split up into 5 seperate modules.
|
The project is split up into a few seperate modules.
|
||||||
|
|
||||||
* **API** - The public, semantically versioned API used by other plugins wishing to integrate with and retrieve data from LuckPerms. This module (for the most part) does not contain any implementation itself, and is provided by the plugin.
|
* **API** - The public, semantically versioned API used by other plugins wishing to integrate with and retrieve data from LuckPerms. This module (for the most part) does not contain any implementation itself, and is provided by the plugin.
|
||||||
* **Common** - The common module contains most of the code which implements the respective LuckPerms plugins. This abstract module reduces duplicated code throughout the project.
|
* **Common** - The common module contains most of the code which implements the respective LuckPerms plugins. This abstract module reduces duplicated code throughout the project.
|
||||||
* **Bukkit, BungeeCord & Sponge** - Each use the common module to implement plugins on the respective server platforms.
|
* **Bukkit, BungeeCord, Sponge, Nukkit & Velocity** - Each use the common module to implement plugins on the respective server platforms.
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
|
||||||
|
Copyright (c) lucko (Luck) <[email protected]>
|
||||||
|
Copyright (c) contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
The MIT License.
|
MIT License
|
||||||
|
|
||||||
Copyright (c) lucko (Luck) <[email protected]>
|
Copyright (c) lucko (Luck) <[email protected]>
|
||||||
Copyright (c) contributors
|
Copyright (c) contributors
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||

|

|
||||||
# LuckPerms [](https://ci.lucko.me/job/LuckPerms/) [](https://javadoc.io/doc/me.lucko.luckperms/luckperms-api) [](https://maven-badges.herokuapp.com/maven-central/me.lucko.luckperms/luckperms-api)
|
# LuckPerms
|
||||||
|
[](https://ci.lucko.me/job/LuckPerms/)
|
||||||
|
[](https://javadoc.io/doc/me.lucko.luckperms/luckperms-api)
|
||||||
|
[](https://search.maven.org/artifact/me.lucko.luckperms/luckperms-api)
|
||||||
|
[](https://discord.gg/luckperms)
|
||||||
|
|
||||||
LuckPerms is an advanced permissions implementation aiming to be a fast, reliable and flexible alternative to existing permission plugins. The project's main goals are centered around high performance and a wide feature set, filling the gaps of functionality and building upon existing features found in other plugins.
|
LuckPerms is an advanced permissions implementation aiming to be a fast, reliable and flexible alternative to existing permission plugins. The project's main goals are centered around high performance and a wide feature set, filling the gaps of functionality and building upon existing features found in other plugins.
|
||||||
|
|
||||||
|
|||||||
+10
-5
@@ -1,12 +1,13 @@
|
|||||||
project.version = '4.3'
|
project.version = '4.4'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'com.google.guava:guava:19.0'
|
compileOnly 'com.google.guava:guava:19.0'
|
||||||
compileOnly 'org.checkerframework:checker-qual:2.5.5'
|
compileOnly 'org.checkerframework:checker-qual:2.5.5'
|
||||||
}
|
}
|
||||||
|
|
||||||
// disabled by default
|
// Only used occasionally for deployment - not needed for normal builds.
|
||||||
if (false && project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')) {
|
/*
|
||||||
|
if (project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')) {
|
||||||
apply plugin: 'signing'
|
apply plugin: 'signing'
|
||||||
|
|
||||||
javadoc {
|
javadoc {
|
||||||
@@ -48,11 +49,15 @@ if (false && project.hasProperty('sonatypeUsername') && project.hasProperty('son
|
|||||||
authentication(userName: sonatypeUsername, password: sonatypePassword)
|
authentication(userName: sonatypeUsername, password: sonatypePassword)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') {
|
||||||
|
authentication(userName: sonatypeUsername, password: sonatypePassword)
|
||||||
|
}
|
||||||
|
|
||||||
pom {
|
pom {
|
||||||
project {
|
project {
|
||||||
name 'LuckPerms API'
|
name 'LuckPerms API'
|
||||||
description 'An advanced permissions plugin for Bukkit/Spigot, BungeeCord, Sponge, Nukkit and Velocity.'
|
description 'An advanced permissions plugin for Bukkit/Spigot, BungeeCord, Sponge, Nukkit and Velocity.'
|
||||||
url 'https://github.com/lucko/LuckPerms'
|
url 'https://luckperms.github.io'
|
||||||
|
|
||||||
licenses {
|
licenses {
|
||||||
license {
|
license {
|
||||||
@@ -73,7 +78,6 @@ if (false && project.hasProperty('sonatypeUsername') && project.hasProperty('son
|
|||||||
connection 'scm:git:https://github.com/lucko/LuckPerms.git'
|
connection 'scm:git:https://github.com/lucko/LuckPerms.git'
|
||||||
developerConnection 'scm:git:[email protected]:lucko/LuckPerms.git'
|
developerConnection 'scm:git:[email protected]:lucko/LuckPerms.git'
|
||||||
url 'https://github.com/lucko/LuckPerms'
|
url 'https://github.com/lucko/LuckPerms'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ciManagement {
|
ciManagement {
|
||||||
@@ -91,3 +95,4 @@ if (false && project.hasProperty('sonatypeUsername') && project.hasProperty('son
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
@@ -25,14 +25,11 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -57,9 +54,9 @@ public class Contexts {
|
|||||||
public static final String WORLD_KEY = "world";
|
public static final String WORLD_KEY = "world";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default {@link LookupSetting}s.
|
* The default {@link LookupSetting}s as a flag.
|
||||||
*/
|
*/
|
||||||
private static final EnumSet<LookupSetting> DEFAULT_SETTINGS = EnumSet.of(
|
private static final byte DEFAULT_SETTINGS_FLAG = LookupSetting.createFlag(
|
||||||
LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER,
|
LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER,
|
||||||
LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD,
|
LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD,
|
||||||
LookupSetting.RESOLVE_INHERITANCE,
|
LookupSetting.RESOLVE_INHERITANCE,
|
||||||
@@ -73,7 +70,7 @@ public class Contexts {
|
|||||||
* <p>Formed of an empty {@link ContextSet} and all inclusion and
|
* <p>Formed of an empty {@link ContextSet} and all inclusion and
|
||||||
* inheritance {@link LookupSetting}s applied.</p>
|
* inheritance {@link LookupSetting}s applied.</p>
|
||||||
*/
|
*/
|
||||||
private static final Contexts GLOBAL = new Contexts(ImmutableContextSet.empty(), ImmutableSet.copyOf(DEFAULT_SETTINGS));
|
private static final Contexts GLOBAL = new Contexts(ImmutableContextSet.empty(), DEFAULT_SETTINGS_FLAG);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link FullySatisfiedContexts} instance.
|
* Gets the {@link FullySatisfiedContexts} instance.
|
||||||
@@ -111,7 +108,7 @@ public class Contexts {
|
|||||||
*/
|
*/
|
||||||
public static @NonNull Contexts of(@NonNull ContextSet contextSet, boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) {
|
public static @NonNull Contexts of(@NonNull ContextSet contextSet, boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) {
|
||||||
Objects.requireNonNull(contextSet, "contextSet");
|
Objects.requireNonNull(contextSet, "contextSet");
|
||||||
EnumSet<LookupSetting> settings = formSettings(
|
byte settingsFlag = LookupSetting.createFlag(
|
||||||
includeNodesSetWithoutServer,
|
includeNodesSetWithoutServer,
|
||||||
includeNodesSetWithoutWorld,
|
includeNodesSetWithoutWorld,
|
||||||
resolveInheritance,
|
resolveInheritance,
|
||||||
@@ -119,18 +116,10 @@ public class Contexts {
|
|||||||
applyParentsWithoutWorld,
|
applyParentsWithoutWorld,
|
||||||
isOp
|
isOp
|
||||||
);
|
);
|
||||||
if (contextSet.isEmpty() && DEFAULT_SETTINGS.equals(settings)) {
|
if (contextSet.isEmpty() && DEFAULT_SETTINGS_FLAG == settingsFlag) {
|
||||||
return GLOBAL;
|
return GLOBAL;
|
||||||
}
|
}
|
||||||
return new Contexts(contextSet.makeImmutable(), ImmutableSet.copyOf(settings));
|
return new Contexts(contextSet.makeImmutable(), settingsFlag);
|
||||||
}
|
|
||||||
|
|
||||||
private static EnumSet<LookupSetting> asEnumSet(Set<LookupSetting> settings) {
|
|
||||||
if (settings instanceof EnumSet<?>) {
|
|
||||||
return ((EnumSet<LookupSetting>) settings);
|
|
||||||
} else {
|
|
||||||
return EnumSet.copyOf(settings);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,12 +133,12 @@ public class Contexts {
|
|||||||
Objects.requireNonNull(contextSet, "contextSet");
|
Objects.requireNonNull(contextSet, "contextSet");
|
||||||
Objects.requireNonNull(settings, "settings");
|
Objects.requireNonNull(settings, "settings");
|
||||||
|
|
||||||
EnumSet<LookupSetting> settingsCopy = asEnumSet(settings);
|
byte settingsFlag = LookupSetting.createFlag(settings);
|
||||||
if (contextSet.isEmpty() && DEFAULT_SETTINGS.equals(settingsCopy)) {
|
if (contextSet.isEmpty() && DEFAULT_SETTINGS_FLAG == settingsFlag) {
|
||||||
return GLOBAL;
|
return GLOBAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Contexts(contextSet.makeImmutable(), ImmutableSet.copyOf(settingsCopy));
|
return new Contexts(contextSet.makeImmutable(), settingsFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,7 +149,7 @@ public class Contexts {
|
|||||||
/**
|
/**
|
||||||
* The settings for this lookup
|
* The settings for this lookup
|
||||||
*/
|
*/
|
||||||
private final ImmutableSet<LookupSetting> settings;
|
private final byte settingsFlag;
|
||||||
|
|
||||||
// cache hashcode - this class is immutable, and is used as an index in the permission cache.
|
// cache hashcode - this class is immutable, and is used as an index in the permission cache.
|
||||||
private final int hashCode;
|
private final int hashCode;
|
||||||
@@ -180,25 +169,25 @@ public class Contexts {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public Contexts(@NonNull ContextSet contextSet, boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) {
|
public Contexts(@NonNull ContextSet contextSet, boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) {
|
||||||
this.contextSet = Objects.requireNonNull(contextSet, "contextSet").makeImmutable();
|
this.contextSet = Objects.requireNonNull(contextSet, "contextSet").makeImmutable();
|
||||||
this.settings = ImmutableSet.copyOf(formSettings(
|
this.settingsFlag = LookupSetting.createFlag(
|
||||||
includeNodesSetWithoutServer,
|
includeNodesSetWithoutServer,
|
||||||
includeNodesSetWithoutWorld,
|
includeNodesSetWithoutWorld,
|
||||||
resolveInheritance,
|
resolveInheritance,
|
||||||
applyParentsWithoutServer,
|
applyParentsWithoutServer,
|
||||||
applyParentsWithoutWorld,
|
applyParentsWithoutWorld,
|
||||||
isOp
|
isOp
|
||||||
));
|
);
|
||||||
this.hashCode = calculateHashCode();
|
this.hashCode = calculateHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Contexts(@NonNull ImmutableContextSet contextSet, @NonNull ImmutableSet<LookupSetting> settings) {
|
protected Contexts(@NonNull ImmutableContextSet contextSet, byte settingsFlag) {
|
||||||
this.contextSet = contextSet;
|
this.contextSet = contextSet;
|
||||||
this.settings = settings;
|
this.settingsFlag = settingsFlag;
|
||||||
this.hashCode = calculateHashCode();
|
this.hashCode = calculateHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link ContextSet} which represent these {@link Contexts}.
|
* Gets the {@link ContextSet set of context pairs} for this {@link Contexts} instance.
|
||||||
*
|
*
|
||||||
* @return an immutable context from this instance
|
* @return an immutable context from this instance
|
||||||
* @since 2.13
|
* @since 2.13
|
||||||
@@ -208,13 +197,51 @@ public class Contexts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the set of {@link LookupSetting}s which represent these {@link Contexts}.
|
* Gets the set of {@link LookupSetting}s for this {@link Contexts} instance.
|
||||||
*
|
*
|
||||||
* @return the settings
|
* @return the settings
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
public @NonNull Set<LookupSetting> getSettings() {
|
public @NonNull Set<LookupSetting> getSettings() {
|
||||||
return this.settings;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -225,7 +252,7 @@ public class Contexts {
|
|||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
public boolean hasSetting(@NonNull LookupSetting setting) {
|
public boolean hasSetting(@NonNull LookupSetting setting) {
|
||||||
return this.settings.contains(setting);
|
return LookupSetting.isSet(this.settingsFlag, setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -302,7 +329,7 @@ public class Contexts {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull String toString() {
|
public @NonNull String toString() {
|
||||||
return "Contexts(contextSet=" + this.contextSet + ", settings=" + this.settings + ")";
|
return "Contexts(contextSet=" + this.contextSet + ", settings=" + LookupSetting.createSetFromFlag(this.settingsFlag) + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -311,14 +338,14 @@ public class Contexts {
|
|||||||
if (o == allowAll()) return false;
|
if (o == allowAll()) return false;
|
||||||
if (!(o instanceof Contexts)) return false;
|
if (!(o instanceof Contexts)) return false;
|
||||||
final Contexts that = (Contexts) o;
|
final Contexts that = (Contexts) o;
|
||||||
return this.contextSet.equals(that.contextSet) && this.settings.equals(that.settings);
|
return this.contextSet.equals(that.contextSet) && this.settingsFlag == that.settingsFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calculateHashCode() {
|
private int calculateHashCode() {
|
||||||
final int PRIME = 59;
|
final int PRIME = 59;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = result * PRIME + this.contextSet.hashCode();
|
result = result * PRIME + this.contextSet.hashCode();
|
||||||
result = result * PRIME + this.settings.hashCode();
|
result = result * PRIME + this.settingsFlag;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,27 +354,4 @@ public class Contexts {
|
|||||||
return this.hashCode;
|
return this.hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static EnumSet<LookupSetting> formSettings(boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) {
|
|
||||||
EnumSet<LookupSetting> settings = EnumSet.noneOf(LookupSetting.class);
|
|
||||||
if (includeNodesSetWithoutServer) {
|
|
||||||
settings.add(LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER);
|
|
||||||
}
|
|
||||||
if (includeNodesSetWithoutWorld) {
|
|
||||||
settings.add(LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD);
|
|
||||||
}
|
|
||||||
if (resolveInheritance) {
|
|
||||||
settings.add(LookupSetting.RESOLVE_INHERITANCE);
|
|
||||||
}
|
|
||||||
if (applyParentsWithoutServer) {
|
|
||||||
settings.add(LookupSetting.APPLY_PARENTS_SET_WITHOUT_SERVER);
|
|
||||||
}
|
|
||||||
if (applyParentsWithoutWorld) {
|
|
||||||
settings.add(LookupSetting.APPLY_PARENTS_SET_WITHOUT_WORLD);
|
|
||||||
}
|
|
||||||
if (isOp) {
|
|
||||||
settings.add(LookupSetting.IS_OP);
|
|
||||||
}
|
|
||||||
return settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.api.caching.CachedData;
|
import me.lucko.luckperms.api.caching.CachedData;
|
||||||
import me.lucko.luckperms.api.caching.MetaContexts;
|
import me.lucko.luckperms.api.caching.MetaContexts;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
@@ -59,7 +57,7 @@ public final class FullySatisfiedContexts extends Contexts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private FullySatisfiedContexts() {
|
private FullySatisfiedContexts() {
|
||||||
super(ImmutableContextSet.empty(), ImmutableSet.copyOf(Contexts.global().getSettings()));
|
super(ImmutableContextSet.empty(), LookupSetting.createFlag(Contexts.global().getSettings()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -80,14 +80,14 @@ public interface HeldPermission<T> {
|
|||||||
*
|
*
|
||||||
* @return the expiry time
|
* @return the expiry time
|
||||||
*/
|
*/
|
||||||
OptionalLong getExpiry();
|
@NonNull OptionalLong getExpiry();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the extra context for the permission.
|
* Gets the extra context for the permission.
|
||||||
*
|
*
|
||||||
* @return the extra context
|
* @return the extra context
|
||||||
*/
|
*/
|
||||||
ContextSet getContexts();
|
@NonNull ContextSet getContexts();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts this permission into a Node
|
* Converts this permission into a Node
|
||||||
|
|||||||
@@ -102,6 +102,35 @@ public interface LogEntry extends Comparable<LogEntry> {
|
|||||||
enum Type {
|
enum Type {
|
||||||
USER('U'), GROUP('G'), TRACK('T');
|
USER('U'), GROUP('G'), TRACK('T');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return valueOf(type.charAt(0));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Unknown type: " + type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
public static @NonNull Type valueOf(char code) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 'U':
|
case 'U':
|
||||||
|
|||||||
@@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The various lookup setting flags for {@link Contexts}.
|
* The various lookup setting flags for {@link Contexts}.
|
||||||
*
|
*
|
||||||
@@ -60,5 +63,62 @@ public enum LookupSetting {
|
|||||||
/**
|
/**
|
||||||
* If global or non-world-specific group memberships should be applied
|
* If global or non-world-specific group memberships should be applied
|
||||||
*/
|
*/
|
||||||
APPLY_PARENTS_SET_WITHOUT_WORLD
|
APPLY_PARENTS_SET_WITHOUT_WORLD;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* bitwise utility methods */
|
||||||
|
|
||||||
|
static boolean isSet(byte b, LookupSetting setting) {
|
||||||
|
return ((b >> setting.ordinal()) & 1) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static byte createFlag(LookupSetting... settings) {
|
||||||
|
byte b = 0;
|
||||||
|
for (LookupSetting setting : settings) {
|
||||||
|
b |= (1 << setting.ordinal());
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static byte createFlag(Set<LookupSetting> settings) {
|
||||||
|
byte b = 0;
|
||||||
|
for (LookupSetting setting : settings) {
|
||||||
|
b |= (1 << setting.ordinal());
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Set<LookupSetting> createSetFromFlag(byte b) {
|
||||||
|
EnumSet<LookupSetting> settings = EnumSet.noneOf(LookupSetting.class);
|
||||||
|
for (LookupSetting setting : LookupSetting.values()) {
|
||||||
|
if (((b >> setting.ordinal()) & 1) == 1) {
|
||||||
|
settings.add(setting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
static byte createFlag(boolean includeNodesSetWithoutServer, boolean includeNodesSetWithoutWorld, boolean resolveInheritance, boolean applyParentsWithoutServer, boolean applyParentsWithoutWorld, boolean isOp) {
|
||||||
|
byte b = 0;
|
||||||
|
if (includeNodesSetWithoutServer) {
|
||||||
|
b |= (1 << LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER.ordinal());
|
||||||
|
}
|
||||||
|
if (includeNodesSetWithoutWorld) {
|
||||||
|
b |= (1 << LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD.ordinal());
|
||||||
|
}
|
||||||
|
if (resolveInheritance) {
|
||||||
|
b |= (1 << LookupSetting.RESOLVE_INHERITANCE.ordinal());
|
||||||
|
}
|
||||||
|
if (applyParentsWithoutServer) {
|
||||||
|
b |= (1 << LookupSetting.APPLY_PARENTS_SET_WITHOUT_SERVER.ordinal());
|
||||||
|
}
|
||||||
|
if (applyParentsWithoutWorld) {
|
||||||
|
b |= (1 << LookupSetting.APPLY_PARENTS_SET_WITHOUT_WORLD.ordinal());
|
||||||
|
}
|
||||||
|
if (isOp) {
|
||||||
|
b |= (1 << LookupSetting.IS_OP.ordinal());
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -26,10 +26,12 @@
|
|||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
import me.lucko.luckperms.LuckPerms;
|
import me.lucko.luckperms.LuckPerms;
|
||||||
|
import me.lucko.luckperms.api.caching.CachedData;
|
||||||
import me.lucko.luckperms.api.context.ContextCalculator;
|
import me.lucko.luckperms.api.context.ContextCalculator;
|
||||||
import me.lucko.luckperms.api.context.ContextManager;
|
import me.lucko.luckperms.api.context.ContextManager;
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.api.event.EventBus;
|
import me.lucko.luckperms.api.event.EventBus;
|
||||||
|
import me.lucko.luckperms.api.manager.CachedDataManager;
|
||||||
import me.lucko.luckperms.api.manager.GroupManager;
|
import me.lucko.luckperms.api.manager.GroupManager;
|
||||||
import me.lucko.luckperms.api.manager.TrackManager;
|
import me.lucko.luckperms.api.manager.TrackManager;
|
||||||
import me.lucko.luckperms.api.manager.UserManager;
|
import me.lucko.luckperms.api.manager.UserManager;
|
||||||
@@ -40,6 +42,7 @@ import me.lucko.luckperms.api.platform.PlatformInfo;
|
|||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -109,6 +112,15 @@ public interface LuckPermsApi {
|
|||||||
*/
|
*/
|
||||||
@NonNull TrackManager getTrackManager();
|
@NonNull TrackManager getTrackManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link CachedDataManager}, responsible for managing
|
||||||
|
* {@link CachedData} instances.
|
||||||
|
*
|
||||||
|
* @return the cached data manager
|
||||||
|
* @since 4.5
|
||||||
|
*/
|
||||||
|
@NonNull CachedDataManager getCachedDataManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedules the execution of an update task, and returns an encapsulation
|
* Schedules the execution of an update task, and returns an encapsulation
|
||||||
* of the task as a {@link CompletableFuture}.
|
* of the task as a {@link CompletableFuture}.
|
||||||
@@ -210,6 +222,14 @@ public interface LuckPermsApi {
|
|||||||
*/
|
*/
|
||||||
@NonNull ContextManager getContextManager();
|
@NonNull ContextManager getContextManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a {@link Collection} of all known permission strings.
|
||||||
|
*
|
||||||
|
* @return a collection of the known permissions
|
||||||
|
* @since 4.4
|
||||||
|
*/
|
||||||
|
@NonNull Collection<String> getKnownPermissions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link NodeFactory}.
|
* Gets the {@link NodeFactory}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -430,17 +430,6 @@ public interface Node {
|
|||||||
@Override
|
@Override
|
||||||
boolean equals(Object obj);
|
boolean equals(Object obj);
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets if this Node is equal to another node as defined by the given
|
|
||||||
* {@link StandardNodeEquality} predicate.
|
|
||||||
*
|
|
||||||
* @param other the other node
|
|
||||||
* @param equalityPredicate the predicate
|
|
||||||
* @return true if this node is considered equal
|
|
||||||
* @since 4.1
|
|
||||||
*/
|
|
||||||
boolean standardEquals(Node other, StandardNodeEquality equalityPredicate);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if this Node is equal to another node as defined by the given
|
* Gets if this Node is equal to another node as defined by the given
|
||||||
* {@link NodeEqualityPredicate}.
|
* {@link NodeEqualityPredicate}.
|
||||||
@@ -450,9 +439,7 @@ public interface Node {
|
|||||||
* @return true if this node is considered equal
|
* @return true if this node is considered equal
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
default boolean equals(Node other, NodeEqualityPredicate equalityPredicate) {
|
boolean equals(Node other, NodeEqualityPredicate equalityPredicate);
|
||||||
return equalityPredicate.areEqual(this, other);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to {@link Node#equals(Object)}, except doesn't take note of the
|
* Similar to {@link Node#equals(Object)}, except doesn't take note of the
|
||||||
|
|||||||
@@ -41,7 +41,10 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
public interface NodeEqualityPredicate {
|
public interface NodeEqualityPredicate {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the two nodes are equal
|
* Returns if the two nodes are equal.
|
||||||
|
*
|
||||||
|
* <p>This method should avoid making calls to {@link Node#equals(Node, NodeEqualityPredicate)}
|
||||||
|
* with {@code this} as the second argument, directly or otherwise.</p>
|
||||||
*
|
*
|
||||||
* @param o1 the first node
|
* @param o1 the first node
|
||||||
* @param o2 the second node
|
* @param o2 the second node
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import me.lucko.luckperms.api.manager.UserManager;
|
|||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -56,10 +57,16 @@ public interface PlayerSaveResult {
|
|||||||
* @param status the status to check for
|
* @param status the status to check for
|
||||||
* @return if the result includes the status
|
* @return if the result includes the status
|
||||||
*/
|
*/
|
||||||
boolean includes(@NonNull Status status);
|
default boolean includes(@NonNull Status status) {
|
||||||
|
Objects.requireNonNull(status, "status");
|
||||||
|
return getStatus().contains(status);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the old username involved in the result
|
* Gets the old username involved in the result.
|
||||||
|
*
|
||||||
|
* <p>Returns null when the result doesn't {@link #includes(Status) include} the
|
||||||
|
* {@link Status#USERNAME_UPDATED} status.</p>
|
||||||
*
|
*
|
||||||
* @return the old username
|
* @return the old username
|
||||||
* @see Status#USERNAME_UPDATED
|
* @see Status#USERNAME_UPDATED
|
||||||
@@ -67,7 +74,10 @@ public interface PlayerSaveResult {
|
|||||||
@Nullable String getOldUsername();
|
@Nullable String getOldUsername();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the other uuids involved in the result
|
* Gets the other uuids involved in the result.
|
||||||
|
*
|
||||||
|
* <p>Returns null when the result doesn't {@link #includes(Status) include} the
|
||||||
|
* {@link Status#OTHER_UUIDS_PRESENT_FOR_USERNAME} status.</p>
|
||||||
*
|
*
|
||||||
* @return the other uuids
|
* @return the other uuids
|
||||||
* @see Status#OTHER_UUIDS_PRESENT_FOR_USERNAME
|
* @see Status#OTHER_UUIDS_PRESENT_FOR_USERNAME
|
||||||
|
|||||||
@@ -73,6 +73,6 @@ public enum StandardNodeEquality implements NodeEqualityPredicate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean areEqual(@NonNull Node o1, @NonNull Node o2) {
|
public boolean areEqual(@NonNull Node o1, @NonNull Node o2) {
|
||||||
return o1.standardEquals(o2, this);
|
return o1.equals(o2, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -412,6 +412,14 @@ public interface CachedData {
|
|||||||
*/
|
*/
|
||||||
void invalidateMeta();
|
void invalidateMeta();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidates all cached {@link PermissionData} and {@link MetaData}
|
||||||
|
* instances.
|
||||||
|
*
|
||||||
|
* @since 4.5
|
||||||
|
*/
|
||||||
|
void invalidate();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidates all of the underlying Permission calculators.
|
* Invalidates all of the underlying Permission calculators.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
package me.lucko.luckperms.api.context;
|
package me.lucko.luckperms.api.context;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
import com.google.common.collect.SetMultimap;
|
import com.google.common.collect.SetMultimap;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
@@ -67,23 +66,6 @@ abstract class AbstractContextSet implements ContextSet {
|
|||||||
return backing().size();
|
return backing().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (o == this) return true;
|
|
||||||
if (!(o instanceof ContextSet)) return false;
|
|
||||||
final ContextSet that = (ContextSet) o;
|
|
||||||
|
|
||||||
final Multimap<String, String> otherContexts;
|
|
||||||
|
|
||||||
if (that instanceof AbstractContextSet) {
|
|
||||||
otherContexts = ((AbstractContextSet) that).backing();
|
|
||||||
} else {
|
|
||||||
otherContexts = that.toMultimap();
|
|
||||||
}
|
|
||||||
|
|
||||||
return backing().equals(otherContexts);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return backing().hashCode();
|
return backing().hashCode();
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ import java.util.Optional;
|
|||||||
* <li>{@code org.bukkit.entity.Player}</li>
|
* <li>{@code org.bukkit.entity.Player}</li>
|
||||||
* <li>{@code net.md_5.bungee.api.connection.ProxiedPlayer}</li>
|
* <li>{@code net.md_5.bungee.api.connection.ProxiedPlayer}</li>
|
||||||
* <li>{@code org.spongepowered.api.service.permission.Subject}</li>
|
* <li>{@code org.spongepowered.api.service.permission.Subject}</li>
|
||||||
|
* <li>{@code cn.nukkit.Player}</li>
|
||||||
|
* <li>{@code com.velocitypowered.api.proxy.Player}</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
@@ -148,13 +150,12 @@ public interface ContextManager {
|
|||||||
void registerCalculator(@NonNull ContextCalculator<?> calculator);
|
void registerCalculator(@NonNull ContextCalculator<?> calculator);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a static context calculator with the manager.
|
* Unregisters a context calculator with the manager.
|
||||||
*
|
|
||||||
* <p>Static calculators provide the same context for all subjects.</p>
|
|
||||||
*
|
*
|
||||||
* @param calculator the calculator
|
* @param calculator the calculator
|
||||||
|
* @since 4.4
|
||||||
*/
|
*/
|
||||||
void registerStaticCalculator(@NonNull StaticContextCalculator calculator);
|
void unregisterCalculator(@NonNull ContextCalculator<?> calculator);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidates the lookup cache for a given subject
|
* Invalidates the lookup cache for a given subject
|
||||||
|
|||||||
@@ -213,6 +213,28 @@ public final class ImmutableContextSet extends AbstractContextSet implements Con
|
|||||||
return this.map.entries().spliterator();
|
return this.map.entries().spliterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (o == this) return true;
|
||||||
|
if (!(o instanceof ContextSet)) return false;
|
||||||
|
final ContextSet that = (ContextSet) o;
|
||||||
|
|
||||||
|
// fast(er) path for ImmutableContextSet comparisons
|
||||||
|
if (that instanceof ImmutableContextSet) {
|
||||||
|
ImmutableContextSet immutableThat = (ImmutableContextSet) that;
|
||||||
|
if (this.hashCode != immutableThat.hashCode) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Multimap<String, String> thatBacking;
|
||||||
|
if (that instanceof AbstractContextSet) {
|
||||||
|
thatBacking = ((AbstractContextSet) that).backing();
|
||||||
|
} else {
|
||||||
|
thatBacking = that.toMultimap();
|
||||||
|
}
|
||||||
|
|
||||||
|
return backing().equals(thatBacking);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return this.hashCode;
|
return this.hashCode;
|
||||||
|
|||||||
@@ -345,6 +345,22 @@ public final class MutableContextSet extends AbstractContextSet implements Conte
|
|||||||
this.map.clear();
|
this.map.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (o == this) return true;
|
||||||
|
if (!(o instanceof ContextSet)) return false;
|
||||||
|
final ContextSet that = (ContextSet) o;
|
||||||
|
|
||||||
|
final Multimap<String, String> thatBacking;
|
||||||
|
if (that instanceof AbstractContextSet) {
|
||||||
|
thatBacking = ((AbstractContextSet) that).backing();
|
||||||
|
} else {
|
||||||
|
thatBacking = that.toMultimap();
|
||||||
|
}
|
||||||
|
|
||||||
|
return backing().equals(thatBacking);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MutableContextSet(contexts=" + this.map + ")";
|
return "MutableContextSet(contexts=" + this.map + ")";
|
||||||
|
|||||||
@@ -43,4 +43,12 @@ public interface LuckPermsEvent {
|
|||||||
*/
|
*/
|
||||||
@NonNull LuckPermsApi getApi();
|
@NonNull LuckPermsApi getApi();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the type of the event.
|
||||||
|
*
|
||||||
|
* @return the type of the event
|
||||||
|
* @since 4.4
|
||||||
|
*/
|
||||||
|
@NonNull Class<? extends LuckPermsEvent> getEventType();
|
||||||
|
|
||||||
}
|
}
|
||||||
+29
-10
@@ -23,29 +23,36 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.api.event.user;
|
package me.lucko.luckperms.api.event.player;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.User;
|
import me.lucko.luckperms.api.User;
|
||||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||||
import me.lucko.luckperms.api.event.Param;
|
import me.lucko.luckperms.api.event.Param;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when LuckPerms has finished processing a certain Player's connection.
|
* Called when LuckPerms has finished processing a Player's initial connection.
|
||||||
*
|
*
|
||||||
* <p>This event will always execute during the platforms async login/auth event.
|
* <p>This event will always execute during the platforms async connection
|
||||||
* All handlers will be called instantly.</p>
|
* event. The LuckPerms platform listener processing the connection will block
|
||||||
|
* while this event is posted.</p>
|
||||||
*
|
*
|
||||||
* <p>This, among other things, allows you to wait until permission data is loaded
|
* <p>This, among other things, allows you to wait until permission data is
|
||||||
* for a User during the BungeeCord 'LoginEvent', as event priorities are ignored
|
* loaded for a User during the BungeeCord 'LoginEvent', as event priorities are
|
||||||
* by the current implementation.</p>
|
* ignored by the current implementation.</p>
|
||||||
*
|
*
|
||||||
* @since 3.4
|
* <p>The implementation will make an attempt to ensure this event is called
|
||||||
|
* for all connections, even if the operation to load User data was not
|
||||||
|
* successful. Note that LuckPerms will usually cancel the platform connection
|
||||||
|
* event if data could not be loaded.</p>
|
||||||
|
*
|
||||||
|
* @since 4.4
|
||||||
*/
|
*/
|
||||||
public interface UserLoginProcessEvent extends LuckPermsEvent {
|
public interface PlayerLoginProcessEvent extends LuckPermsEvent {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the UUID of the connection which was processed
|
* Gets the UUID of the connection which was processed
|
||||||
@@ -61,11 +68,23 @@ public interface UserLoginProcessEvent extends LuckPermsEvent {
|
|||||||
*/
|
*/
|
||||||
@NonNull @Param(1) String getUsername();
|
@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.
|
* Gets the resultant User instance which was loaded.
|
||||||
*
|
*
|
||||||
|
* <p>Returns {@code null} if the login was not processed
|
||||||
|
* {@link #wasSuccessful() successfully.}</p>
|
||||||
|
*
|
||||||
* @return the user instance
|
* @return the user instance
|
||||||
*/
|
*/
|
||||||
@NonNull @Param(2) User getUser();
|
@Nullable @Param(2) User getUser();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[email protected]>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.api.manager;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.Group;
|
||||||
|
import me.lucko.luckperms.api.User;
|
||||||
|
import me.lucko.luckperms.api.caching.CachedData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an object responsible for managing {@link CachedData} instances.
|
||||||
|
*
|
||||||
|
* @since 4.5
|
||||||
|
*/
|
||||||
|
public interface CachedDataManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidate the {@link CachedData} instances for all loaded {@link User}s.
|
||||||
|
*
|
||||||
|
* @see CachedData#invalidate()
|
||||||
|
*/
|
||||||
|
void invalidateAllUserCaches();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidate the {@link CachedData} instances for all loaded {@link Group}s.
|
||||||
|
*
|
||||||
|
* @see CachedData#invalidate()
|
||||||
|
*/
|
||||||
|
void invalidateAllGroupCaches();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <[email protected]>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.api.metastacking;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Functional interface which removes duplicate entries from a list.
|
||||||
|
*
|
||||||
|
* <p>Used by LuckPerms to remove duplicate entries from a MetaStack.</p>
|
||||||
|
*
|
||||||
|
* @since 4.4
|
||||||
|
*/
|
||||||
|
public interface DuplicateRemovalFunction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes duplicates from the given list, according to the behaviour
|
||||||
|
* of the function.
|
||||||
|
*
|
||||||
|
* @param list the entries
|
||||||
|
* @param <T> the type of entries
|
||||||
|
*/
|
||||||
|
<T> void processDuplicates(@NonNull List<T> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link DuplicateRemovalFunction} that does not remove duplicates.
|
||||||
|
*/
|
||||||
|
DuplicateRemovalFunction RETAIN_ALL = new DuplicateRemovalFunction() {
|
||||||
|
@Override
|
||||||
|
public <T> void processDuplicates(@NonNull List<T> list) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "DuplicateRemovalFunction#RETAIN_ALL";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link DuplicateRemovalFunction} that retains only the first occurrence.
|
||||||
|
*/
|
||||||
|
DuplicateRemovalFunction FIRST_ONLY = new DuplicateRemovalFunction() {
|
||||||
|
@SuppressWarnings("Java8CollectionRemoveIf")
|
||||||
|
@Override
|
||||||
|
public <T> void processDuplicates(@NonNull List<T> list) {
|
||||||
|
Set<T> seen = new HashSet<>();
|
||||||
|
for (ListIterator<T> it = list.listIterator(); it.hasNext(); ) {
|
||||||
|
T next = it.next();
|
||||||
|
if (!seen.add(next)) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "DuplicateRemovalFunction#FIRST_ONLY";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link DuplicateRemovalFunction} that retains only the last occurrence.
|
||||||
|
*/
|
||||||
|
DuplicateRemovalFunction LAST_ONLY = new DuplicateRemovalFunction() {
|
||||||
|
@Override
|
||||||
|
public <T> void processDuplicates(@NonNull List<T> list) {
|
||||||
|
Set<T> seen = new HashSet<>();
|
||||||
|
for (ListIterator<T> it = list.listIterator(list.size()); it.hasPrevious(); ) {
|
||||||
|
T next = it.previous();
|
||||||
|
if (!seen.add(next)) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "DuplicateRemovalFunction#LAST_ONLY";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
@@ -49,6 +49,15 @@ public interface MetaStackDefinition {
|
|||||||
*/
|
*/
|
||||||
@NonNull List<MetaStackElement> getElements();
|
@NonNull List<MetaStackElement> getElements();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the duplicate removal function, applied to the entries before
|
||||||
|
* formatting takes place.
|
||||||
|
*
|
||||||
|
* @return the duplicate removal function
|
||||||
|
* @since 4.4
|
||||||
|
*/
|
||||||
|
@NonNull DuplicateRemovalFunction getDuplicateRemovalFunction();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the spacer string added before any stack elements
|
* Gets the spacer string added before any stack elements
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -64,6 +64,22 @@ public interface MetaStackFactory {
|
|||||||
* @param endSpacer the spacer to be included at the end of the stacks output
|
* @param endSpacer the spacer to be included at the end of the stacks output
|
||||||
* @return the new stack definition instance
|
* @return the new stack definition instance
|
||||||
*/
|
*/
|
||||||
@NonNull MetaStackDefinition createDefinition(@NonNull List<MetaStackElement> elements, @NonNull String startSpacer, @NonNull String middleSpacer, @NonNull String endSpacer);
|
default @NonNull MetaStackDefinition createDefinition(@NonNull List<MetaStackElement> elements, @NonNull String startSpacer, @NonNull String middleSpacer, @NonNull String endSpacer) {
|
||||||
|
return createDefinition(elements, DuplicateRemovalFunction.RETAIN_ALL, startSpacer, middleSpacer, endSpacer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link MetaStackDefinition} with the given properties.
|
||||||
|
*
|
||||||
|
* @param elements the elements to be included in the stack.
|
||||||
|
* @param duplicateRemovalFunction the duplicate removal function
|
||||||
|
* @param startSpacer the spacer to be included at the start of the stacks output
|
||||||
|
* @param middleSpacer the spacer to be included between stack elements
|
||||||
|
* @param endSpacer the spacer to be included at the end of the stacks output
|
||||||
|
* @return the new stack definition instance
|
||||||
|
* @since 4.4
|
||||||
|
*/
|
||||||
|
@NonNull MetaStackDefinition createDefinition(@NonNull List<MetaStackElement> elements, @NonNull DuplicateRemovalFunction duplicateRemovalFunction, @NonNull String startSpacer, @NonNull String middleSpacer, @NonNull String endSpacer);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+31
-20
@@ -1,9 +1,22 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
maven { url 'https://plugins.gradle.org/m2' }
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath 'gradle.plugin.net.minecrell:licenser:0.4.1'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultTasks 'licenseFormat', 'build'
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'maven'
|
apply plugin: 'maven'
|
||||||
|
apply plugin: 'net.minecrell.licenser'
|
||||||
|
|
||||||
group = 'me.lucko.luckperms'
|
group = 'me.lucko.luckperms'
|
||||||
version = '4.3-SNAPSHOT'
|
version = '4.4-SNAPSHOT'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 1.8
|
||||||
@@ -18,35 +31,33 @@ subprojects {
|
|||||||
|
|
||||||
def determinePatchVersion = {
|
def determinePatchVersion = {
|
||||||
// get the name of the last tag
|
// get the name of the last tag
|
||||||
def lastTag = new ByteArrayOutputStream()
|
def tagInfo = new ByteArrayOutputStream()
|
||||||
exec {
|
exec {
|
||||||
commandLine 'git', 'describe', '--tags', '--abbrev=0', '@^'
|
commandLine 'git', 'describe', '--tags'
|
||||||
standardOutput = lastTag
|
standardOutput = tagInfo
|
||||||
}
|
}
|
||||||
|
tagInfo = tagInfo.toString()
|
||||||
|
|
||||||
// get a list of the commits since the last tag
|
if (!tagInfo.contains('-')) {
|
||||||
def commitsSinceLastTag = new ByteArrayOutputStream()
|
return 0
|
||||||
exec {
|
|
||||||
commandLine 'git', 'log', '--oneline', lastTag.toString().trim() + '..@'
|
|
||||||
standardOutput = commitsSinceLastTag
|
|
||||||
}
|
}
|
||||||
|
return tagInfo.split("-")[1]
|
||||||
// calculate what the patch version should be
|
|
||||||
return Integer.toString(commitsSinceLastTag.toString().split("\n").length)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
project.ext.majorVersion = '4'
|
project.ext.majorVersion = '4'
|
||||||
project.ext.minorVersion = '3'
|
project.ext.minorVersion = '4'
|
||||||
project.ext.patchVersion = determinePatchVersion()
|
project.ext.patchVersion = determinePatchVersion()
|
||||||
project.ext.fullVersion = project.ext.majorVersion + '.' + project.ext.minorVersion + '.' + project.ext.patchVersion
|
project.ext.fullVersion = project.ext.majorVersion + '.' + project.ext.minorVersion + '.' + project.ext.patchVersion
|
||||||
|
|
||||||
repositories {
|
license {
|
||||||
//mavenLocal()
|
header = rootProject.file('HEADER.txt')
|
||||||
mavenCentral()
|
include '**/*.java'
|
||||||
|
newLine = true
|
||||||
|
}
|
||||||
|
|
||||||
maven {
|
repositories {
|
||||||
name 'luck-repo'
|
mavenCentral()
|
||||||
url 'https://repo.lucko.me/'
|
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
|
||||||
}
|
maven { url 'https://repo.lucko.me/' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,13 +2,6 @@ plugins {
|
|||||||
id 'com.github.johnrengelman.shadow' version '2.0.4'
|
id 'com.github.johnrengelman.shadow' version '2.0.4'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
name 'spigot-repo'
|
|
||||||
url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(path: ':bukkit', configuration: 'shadow')
|
compile project(path: ':bukkit', configuration: 'shadow')
|
||||||
compile 'com.google.code.gson:gson:2.7'
|
compile 'com.google.code.gson:gson:2.7'
|
||||||
|
|||||||
+5
-6
@@ -3,17 +3,16 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
|
||||||
name 'spigot-repo'
|
maven { url 'https://libraries.minecraft.net/' }
|
||||||
url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':common')
|
compile project(':common')
|
||||||
|
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot-api:1.14-R0.1-SNAPSHOT'
|
||||||
compileOnly 'me.lucko:commodore:1.0'
|
compileOnly 'net.kyori:text-adapter-bukkit:3.0.2'
|
||||||
|
compileOnly 'me.lucko:commodore:1.3'
|
||||||
compileOnly('net.milkbowl.vault:VaultAPI:1.6') {
|
compileOnly('net.milkbowl.vault:VaultAPI:1.6') {
|
||||||
exclude(module: 'bukkit')
|
exclude(module: 'bukkit')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,16 +26,14 @@
|
|||||||
package me.lucko.luckperms.bukkit;
|
package me.lucko.luckperms.bukkit;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.bukkit.compat.BukkitJsonMessageHandler;
|
|
||||||
import me.lucko.luckperms.bukkit.compat.CraftBukkitUtil;
|
import me.lucko.luckperms.bukkit.compat.CraftBukkitUtil;
|
||||||
import me.lucko.luckperms.bukkit.compat.SpigotJsonMessageHandler;
|
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.sender.SenderFactory;
|
import me.lucko.luckperms.common.sender.SenderFactory;
|
||||||
import me.lucko.luckperms.common.utils.TextUtils;
|
import me.lucko.luckperms.common.util.TextUtils;
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.serializer.ComponentSerializers;
|
import net.kyori.text.adapter.bukkit.TextAdapter;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
@@ -45,13 +43,9 @@ import org.bukkit.entity.Player;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class BukkitSenderFactory extends SenderFactory<CommandSender> {
|
public class BukkitSenderFactory extends SenderFactory<CommandSender> {
|
||||||
private final BukkitJsonMessageHandler bukkitHandler;
|
|
||||||
private final SpigotJsonMessageHandler spigotHandler;
|
|
||||||
|
|
||||||
public BukkitSenderFactory(LuckPermsPlugin plugin) {
|
public BukkitSenderFactory(LuckPermsPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.bukkitHandler = new BukkitJsonMessageHandler();
|
|
||||||
this.spigotHandler = isSpigot() ? new SpigotJsonMessageHandler() : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -59,7 +53,7 @@ public class BukkitSenderFactory extends SenderFactory<CommandSender> {
|
|||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
return sender.getName();
|
return sender.getName();
|
||||||
}
|
}
|
||||||
return CommandManager.CONSOLE_NAME;
|
return Sender.CONSOLE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -67,7 +61,7 @@ public class BukkitSenderFactory extends SenderFactory<CommandSender> {
|
|||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
return ((Player) sender).getUniqueId();
|
return ((Player) sender).getUniqueId();
|
||||||
}
|
}
|
||||||
return CommandManager.CONSOLE_UUID;
|
return Sender.CONSOLE_UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -85,22 +79,11 @@ public class BukkitSenderFactory extends SenderFactory<CommandSender> {
|
|||||||
@Override
|
@Override
|
||||||
protected void sendMessage(CommandSender sender, Component message) {
|
protected void sendMessage(CommandSender sender, Component message) {
|
||||||
if (CraftBukkitUtil.isChatCompatible() && sender instanceof Player) {
|
if (CraftBukkitUtil.isChatCompatible() && sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
TextAdapter.sendComponent(sender, message);
|
||||||
String json = ComponentSerializers.JSON.serialize(message);
|
} else {
|
||||||
|
// Fallback to legacy format
|
||||||
// Try Bukkit.
|
sendMessage(sender, TextUtils.toLegacy(message));
|
||||||
if (this.bukkitHandler.sendJsonMessage(player, json)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try Spigot.
|
|
||||||
if (this.spigotHandler != null && this.spigotHandler.sendJsonMessage(player, json)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to legacy format
|
|
||||||
sendMessage(sender, TextUtils.toLegacy(message));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -116,15 +99,6 @@ public class BukkitSenderFactory extends SenderFactory<CommandSender> {
|
|||||||
return sender.hasPermission(node);
|
return sender.hasPermission(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isSpigot() {
|
|
||||||
try {
|
|
||||||
Class.forName("net.md_5.bungee.chat.ComponentSerializer");
|
|
||||||
return true;
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class SyncMessengerAgent implements Runnable {
|
private static final class SyncMessengerAgent implements Runnable {
|
||||||
private final CommandSender sender;
|
private final CommandSender sender;
|
||||||
private final String message;
|
private final String message;
|
||||||
|
|||||||
@@ -212,11 +212,6 @@ public class LPBukkitBootstrap extends JavaPlugin implements LuckPermsBootstrap
|
|||||||
return getServer().getVersion() + " - " + getServer().getBukkitVersion();
|
return getServer().getVersion() + " - " + getServer().getBukkitVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getServerName() {
|
|
||||||
return getServer().getServerName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Path getDataDirectory() {
|
public Path getDataDirectory() {
|
||||||
return getDataFolder().toPath().toAbsolutePath();
|
return getDataFolder().toPath().toAbsolutePath();
|
||||||
|
|||||||
@@ -28,36 +28,36 @@ package me.lucko.luckperms.bukkit;
|
|||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.LuckPermsApi;
|
import me.lucko.luckperms.api.LuckPermsApi;
|
||||||
import me.lucko.luckperms.api.event.user.UserDataRecalculateEvent;
|
import me.lucko.luckperms.api.event.user.UserDataRecalculateEvent;
|
||||||
import me.lucko.luckperms.bukkit.calculators.BukkitCalculatorFactory;
|
import me.lucko.luckperms.bukkit.calculator.BukkitCalculatorFactory;
|
||||||
import me.lucko.luckperms.bukkit.compat.LuckPermsBrigadier;
|
import me.lucko.luckperms.bukkit.compat.LuckPermsBrigadier;
|
||||||
import me.lucko.luckperms.bukkit.contexts.BukkitContextManager;
|
import me.lucko.luckperms.bukkit.context.BukkitContextManager;
|
||||||
import me.lucko.luckperms.bukkit.contexts.WorldCalculator;
|
import me.lucko.luckperms.bukkit.context.WorldCalculator;
|
||||||
|
import me.lucko.luckperms.bukkit.inject.permissible.LPPermissible;
|
||||||
|
import me.lucko.luckperms.bukkit.inject.permissible.PermissibleInjector;
|
||||||
|
import me.lucko.luckperms.bukkit.inject.permissible.PermissibleMonitoringInjector;
|
||||||
|
import me.lucko.luckperms.bukkit.inject.server.InjectorDefaultsMap;
|
||||||
|
import me.lucko.luckperms.bukkit.inject.server.InjectorPermissionMap;
|
||||||
|
import me.lucko.luckperms.bukkit.inject.server.InjectorSubscriptionMap;
|
||||||
|
import me.lucko.luckperms.bukkit.inject.server.LPDefaultsMap;
|
||||||
|
import me.lucko.luckperms.bukkit.inject.server.LPPermissionMap;
|
||||||
|
import me.lucko.luckperms.bukkit.inject.server.LPSubscriptionMap;
|
||||||
import me.lucko.luckperms.bukkit.listeners.BukkitConnectionListener;
|
import me.lucko.luckperms.bukkit.listeners.BukkitConnectionListener;
|
||||||
import me.lucko.luckperms.bukkit.listeners.BukkitPlatformListener;
|
import me.lucko.luckperms.bukkit.listeners.BukkitPlatformListener;
|
||||||
import me.lucko.luckperms.bukkit.messaging.BukkitMessagingFactory;
|
import me.lucko.luckperms.bukkit.messaging.BukkitMessagingFactory;
|
||||||
import me.lucko.luckperms.bukkit.model.permissible.LPPermissible;
|
|
||||||
import me.lucko.luckperms.bukkit.model.permissible.PermissibleInjector;
|
|
||||||
import me.lucko.luckperms.bukkit.model.permissible.PermissibleMonitoringInjector;
|
|
||||||
import me.lucko.luckperms.bukkit.model.server.InjectorDefaultsMap;
|
|
||||||
import me.lucko.luckperms.bukkit.model.server.InjectorPermissionMap;
|
|
||||||
import me.lucko.luckperms.bukkit.model.server.InjectorSubscriptionMap;
|
|
||||||
import me.lucko.luckperms.bukkit.model.server.LPDefaultsMap;
|
|
||||||
import me.lucko.luckperms.bukkit.model.server.LPPermissionMap;
|
|
||||||
import me.lucko.luckperms.bukkit.model.server.LPSubscriptionMap;
|
|
||||||
import me.lucko.luckperms.bukkit.vault.VaultHookManager;
|
import me.lucko.luckperms.bukkit.vault.VaultHookManager;
|
||||||
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
||||||
import me.lucko.luckperms.common.api.delegates.model.ApiUser;
|
import me.lucko.luckperms.common.api.implementation.ApiUser;
|
||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculator.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||||
import me.lucko.luckperms.common.dependencies.Dependency;
|
import me.lucko.luckperms.common.dependencies.Dependency;
|
||||||
import me.lucko.luckperms.common.event.AbstractEventBus;
|
import me.lucko.luckperms.common.event.AbstractEventBus;
|
||||||
import me.lucko.luckperms.common.managers.group.StandardGroupManager;
|
|
||||||
import me.lucko.luckperms.common.managers.track.StandardTrackManager;
|
|
||||||
import me.lucko.luckperms.common.managers.user.StandardUserManager;
|
|
||||||
import me.lucko.luckperms.common.messaging.MessagingFactory;
|
import me.lucko.luckperms.common.messaging.MessagingFactory;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
|
import me.lucko.luckperms.common.model.manager.group.StandardGroupManager;
|
||||||
|
import me.lucko.luckperms.common.model.manager.track.StandardTrackManager;
|
||||||
|
import me.lucko.luckperms.common.model.manager.user.StandardUserManager;
|
||||||
import me.lucko.luckperms.common.plugin.AbstractLuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.AbstractLuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.plugin.util.AbstractConnectionListener;
|
import me.lucko.luckperms.common.plugin.util.AbstractConnectionListener;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
@@ -73,7 +73,6 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
import org.bukkit.plugin.ServicePriority;
|
import org.bukkit.plugin.ServicePriority;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -123,7 +122,8 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Set<Dependency> getGlobalDependencies() {
|
protected Set<Dependency> getGlobalDependencies() {
|
||||||
EnumSet<Dependency> dependencies = EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP, Dependency.EVENT);
|
Set<Dependency> dependencies = super.getGlobalDependencies();
|
||||||
|
dependencies.add(Dependency.TEXT_ADAPTER_BUKKIT);
|
||||||
if (isBrigadierSupported()) {
|
if (isBrigadierSupported()) {
|
||||||
dependencies.add(Dependency.COMMODORE);
|
dependencies.add(Dependency.COMMODORE);
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,9 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
|||||||
try {
|
try {
|
||||||
LuckPermsBrigadier.register(this, cmd);
|
LuckPermsBrigadier.register(this, cmd);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
if (!(e instanceof RuntimeException && e.getMessage().contains("not supported by the server"))) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,7 +191,7 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
|||||||
new InjectorSubscriptionMap(this),
|
new InjectorSubscriptionMap(this),
|
||||||
new InjectorPermissionMap(this),
|
new InjectorPermissionMap(this),
|
||||||
new InjectorDefaultsMap(this),
|
new InjectorDefaultsMap(this),
|
||||||
new PermissibleMonitoringInjector(this)
|
new PermissibleMonitoringInjector(this, PermissibleMonitoringInjector.Mode.INJECT)
|
||||||
};
|
};
|
||||||
|
|
||||||
for (Runnable injector : injectors) {
|
for (Runnable injector : injectors) {
|
||||||
@@ -216,8 +218,8 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (force || this.bootstrap.getServer().getPluginManager().isPluginEnabled("Vault")) {
|
if (force || this.bootstrap.getServer().getPluginManager().isPluginEnabled("Vault")) {
|
||||||
this.vaultHookManager = new VaultHookManager();
|
this.vaultHookManager = new VaultHookManager(this);
|
||||||
this.vaultHookManager.hook(this);
|
this.vaultHookManager.hook();
|
||||||
getLogger().info("Registered Vault permission & chat hook.");
|
getLogger().info("Registered Vault permission & chat hook.");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -266,7 +268,7 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
|||||||
getApiProvider().getEventBus().subscribe(UserDataRecalculateEvent.class, event -> {
|
getApiProvider().getEventBus().subscribe(UserDataRecalculateEvent.class, event -> {
|
||||||
User user = ApiUser.cast(event.getUser());
|
User user = ApiUser.cast(event.getUser());
|
||||||
Optional<Player> player = getBootstrap().getPlayer(user.getUuid());
|
Optional<Player> player = getBootstrap().getPlayer(user.getUuid());
|
||||||
player.ifPresent(this::refreshAutoOp);
|
player.ifPresent(p -> refreshAutoOp(p, false));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +299,7 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
|||||||
// uninject from players
|
// uninject from players
|
||||||
for (Player player : this.bootstrap.getServer().getOnlinePlayers()) {
|
for (Player player : this.bootstrap.getServer().getOnlinePlayers()) {
|
||||||
try {
|
try {
|
||||||
PermissibleInjector.unInject(player, false);
|
PermissibleInjector.uninject(player, false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -317,23 +319,33 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
|||||||
InjectorSubscriptionMap.uninject();
|
InjectorSubscriptionMap.uninject();
|
||||||
InjectorPermissionMap.uninject();
|
InjectorPermissionMap.uninject();
|
||||||
InjectorDefaultsMap.uninject();
|
InjectorDefaultsMap.uninject();
|
||||||
|
new PermissibleMonitoringInjector(this, PermissibleMonitoringInjector.Mode.UNINJECT).run();
|
||||||
|
|
||||||
// unhook vault
|
// unhook vault
|
||||||
if (this.vaultHookManager != null) {
|
if (this.vaultHookManager != null) {
|
||||||
this.vaultHookManager.unhook(this);
|
this.vaultHookManager.unhook();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshAutoOp(Player player) {
|
public void refreshAutoOp(Player player, boolean callerIsSync) {
|
||||||
if (getConfiguration().get(ConfigKeys.AUTO_OP)) {
|
if (!getConfiguration().get(ConfigKeys.AUTO_OP)) {
|
||||||
User user = getUserManager().getIfLoaded(player.getUniqueId());
|
return;
|
||||||
if (user == null) {
|
}
|
||||||
player.setOp(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
User user = getUserManager().getIfLoaded(player.getUniqueId());
|
||||||
|
boolean value;
|
||||||
|
|
||||||
|
if (user != null) {
|
||||||
Map<String, Boolean> permData = user.getCachedData().getPermissionData(this.contextManager.getApplicableContexts(player)).getImmutableBacking();
|
Map<String, Boolean> permData = user.getCachedData().getPermissionData(this.contextManager.getApplicableContexts(player)).getImmutableBacking();
|
||||||
player.setOp(permData.getOrDefault("luckperms.autoop", false));
|
value = permData.getOrDefault("luckperms.autoop", false);
|
||||||
|
} else {
|
||||||
|
value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callerIsSync) {
|
||||||
|
player.setOp(value);
|
||||||
|
} else {
|
||||||
|
this.bootstrap.getScheduler().executeSync(() -> player.setOp(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-11
@@ -23,24 +23,22 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.calculators;
|
package me.lucko.luckperms.bukkit.calculator;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.LookupSetting;
|
import me.lucko.luckperms.api.LookupSetting;
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
import me.lucko.luckperms.bukkit.processors.ChildProcessor;
|
import me.lucko.luckperms.common.cacheddata.CacheMetadata;
|
||||||
import me.lucko.luckperms.bukkit.processors.DefaultsProcessor;
|
import me.lucko.luckperms.common.calculator.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculator.PermissionCalculator;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
import me.lucko.luckperms.common.calculator.processor.MapProcessor;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
import me.lucko.luckperms.common.calculator.processor.PermissionProcessor;
|
||||||
|
import me.lucko.luckperms.common.calculator.processor.RegexProcessor;
|
||||||
|
import me.lucko.luckperms.common.calculator.processor.WildcardProcessor;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.model.HolderType;
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.processors.MapProcessor;
|
|
||||||
import me.lucko.luckperms.common.processors.PermissionProcessor;
|
|
||||||
import me.lucko.luckperms.common.processors.RegexProcessor;
|
|
||||||
import me.lucko.luckperms.common.processors.WildcardProcessor;
|
|
||||||
|
|
||||||
public class BukkitCalculatorFactory implements CalculatorFactory {
|
public class BukkitCalculatorFactory implements CalculatorFactory {
|
||||||
private final LPBukkitPlugin plugin;
|
private final LPBukkitPlugin plugin;
|
||||||
@@ -50,7 +48,7 @@ public class BukkitCalculatorFactory implements CalculatorFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PermissionCalculator build(Contexts contexts, PermissionCalculatorMetadata metadata) {
|
public PermissionCalculator build(Contexts contexts, CacheMetadata metadata) {
|
||||||
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
||||||
|
|
||||||
processors.add(new MapProcessor());
|
processors.add(new MapProcessor());
|
||||||
+13
-5
@@ -23,12 +23,13 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.processors;
|
package me.lucko.luckperms.bukkit.calculator;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
import me.lucko.luckperms.common.processors.AbstractPermissionProcessor;
|
import me.lucko.luckperms.common.calculator.processor.AbstractPermissionProcessor;
|
||||||
import me.lucko.luckperms.common.processors.PermissionProcessor;
|
import me.lucko.luckperms.common.calculator.processor.PermissionProcessor;
|
||||||
|
import me.lucko.luckperms.common.calculator.result.TristateResult;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -38,6 +39,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
* Permission Processor for Bukkits "child" permission system.
|
* Permission Processor for Bukkits "child" permission system.
|
||||||
*/
|
*/
|
||||||
public class ChildProcessor extends AbstractPermissionProcessor implements PermissionProcessor {
|
public class ChildProcessor extends AbstractPermissionProcessor implements PermissionProcessor {
|
||||||
|
private static final TristateResult.Factory RESULT_FACTORY = new TristateResult.Factory(ChildProcessor.class);
|
||||||
|
|
||||||
private final LPBukkitPlugin plugin;
|
private final LPBukkitPlugin plugin;
|
||||||
private Map<String, Boolean> childPermissions = Collections.emptyMap();
|
private Map<String, Boolean> childPermissions = Collections.emptyMap();
|
||||||
|
|
||||||
@@ -46,8 +49,8 @@ public class ChildProcessor extends AbstractPermissionProcessor implements Permi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Tristate hasPermission(String permission) {
|
public TristateResult hasPermission(String permission) {
|
||||||
return Tristate.fromNullableBoolean(this.childPermissions.get(permission));
|
return RESULT_FACTORY.result(Tristate.fromNullableBoolean(this.childPermissions.get(permission)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -61,4 +64,9 @@ public class ChildProcessor extends AbstractPermissionProcessor implements Permi
|
|||||||
}
|
}
|
||||||
this.childPermissions = builder;
|
this.childPermissions = builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invalidate() {
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+12
-5
@@ -23,11 +23,12 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.processors;
|
package me.lucko.luckperms.bukkit.calculator;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
import me.lucko.luckperms.common.processors.PermissionProcessor;
|
import me.lucko.luckperms.common.calculator.processor.PermissionProcessor;
|
||||||
|
import me.lucko.luckperms.common.calculator.result.TristateResult;
|
||||||
|
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
|
|
||||||
@@ -35,6 +36,9 @@ import org.bukkit.permissions.Permission;
|
|||||||
* Permission Processor for Bukkits "default" permission system.
|
* Permission Processor for Bukkits "default" permission system.
|
||||||
*/
|
*/
|
||||||
public class DefaultsProcessor implements PermissionProcessor {
|
public class DefaultsProcessor implements PermissionProcessor {
|
||||||
|
private static final TristateResult.Factory DEFAULT_PERMISSION_MAP_RESULT_FACTORY = new TristateResult.Factory(DefaultsProcessor.class, "default permission map");
|
||||||
|
private static final TristateResult.Factory PERMISSION_MAP_RESULT_FACTORY = new TristateResult.Factory(DefaultsProcessor.class, "permission map");
|
||||||
|
|
||||||
private final LPBukkitPlugin plugin;
|
private final LPBukkitPlugin plugin;
|
||||||
private final boolean isOp;
|
private final boolean isOp;
|
||||||
|
|
||||||
@@ -44,13 +48,16 @@ public class DefaultsProcessor implements PermissionProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Tristate hasPermission(String permission) {
|
public TristateResult hasPermission(String permission) {
|
||||||
Tristate t = this.plugin.getDefaultPermissionMap().lookupDefaultPermission(permission, this.isOp);
|
Tristate t = this.plugin.getDefaultPermissionMap().lookupDefaultPermission(permission, this.isOp);
|
||||||
if (t != Tristate.UNDEFINED) {
|
if (t != Tristate.UNDEFINED) {
|
||||||
return t;
|
return DEFAULT_PERMISSION_MAP_RESULT_FACTORY.result(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
Permission defPerm = this.plugin.getPermissionMap().get(permission);
|
Permission defPerm = this.plugin.getPermissionMap().get(permission);
|
||||||
return defPerm == null ? Tristate.UNDEFINED : Tristate.fromBoolean(defPerm.getDefault().getValue(this.isOp));
|
if (defPerm == null) {
|
||||||
|
return TristateResult.UNDEFINED;
|
||||||
|
}
|
||||||
|
return PERMISSION_MAP_RESULT_FACTORY.result(Tristate.fromBoolean(defPerm.getDefault().getValue(this.isOp)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of LuckPerms, licensed under the MIT License.
|
|
||||||
*
|
|
||||||
* Copyright (c) lucko (Luck) <[email protected]>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.compat;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
public class BukkitJsonMessageHandler {
|
|
||||||
private static boolean setup = false;
|
|
||||||
private static boolean triedAndFailed = false;
|
|
||||||
|
|
||||||
private static Method GET_HANDLE_METHOD;
|
|
||||||
private static Field PLAYER_CONNECTION_FIELD;
|
|
||||||
private static Method SEND_PACKET_METHOD;
|
|
||||||
private static Constructor<?> PACKET_CHAT_CONSTRUCTOR;
|
|
||||||
private static Method SERIALIZE_METHOD;
|
|
||||||
|
|
||||||
private static void setup(Object player) throws Exception {
|
|
||||||
Class<?> craftPlayerClass = player.getClass();
|
|
||||||
GET_HANDLE_METHOD = craftPlayerClass.getDeclaredMethod("getHandle");
|
|
||||||
|
|
||||||
Object handleObject = GET_HANDLE_METHOD.invoke(player);
|
|
||||||
Class<?> handleClass = handleObject.getClass();
|
|
||||||
|
|
||||||
PLAYER_CONNECTION_FIELD = handleClass.getDeclaredField("playerConnection");
|
|
||||||
|
|
||||||
Object playerConnectionObject = PLAYER_CONNECTION_FIELD.get(handleObject);
|
|
||||||
|
|
||||||
Method[] playerConnectionMethods = playerConnectionObject.getClass().getDeclaredMethods();
|
|
||||||
for (Method m : playerConnectionMethods) {
|
|
||||||
if (m.getName().equals("sendPacket")) {
|
|
||||||
SEND_PACKET_METHOD = m;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Class<?> packetChatClass = CraftBukkitUtil.nmsClass("PacketPlayOutChat");
|
|
||||||
Constructor[] packetConstructors = packetChatClass.getDeclaredConstructors();
|
|
||||||
for (Constructor c : packetConstructors) {
|
|
||||||
Class<?>[] parameters = c.getParameterTypes();
|
|
||||||
if (parameters.length == 1 && parameters[0].getName().endsWith("IChatBaseComponent")) {
|
|
||||||
PACKET_CHAT_CONSTRUCTOR = c;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Class<?> baseComponentClass = CraftBukkitUtil.nmsClass("IChatBaseComponent");
|
|
||||||
Class<?> chatSerializerClass;
|
|
||||||
|
|
||||||
if (baseComponentClass.getClasses().length > 0) {
|
|
||||||
chatSerializerClass = baseComponentClass.getClasses()[0];
|
|
||||||
} else {
|
|
||||||
// 1.7 class is here instead.
|
|
||||||
chatSerializerClass = CraftBukkitUtil.nmsClass("ChatSerializer");
|
|
||||||
}
|
|
||||||
|
|
||||||
SERIALIZE_METHOD = chatSerializerClass.getDeclaredMethod("a", String.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static synchronized boolean trySetup(Object player) {
|
|
||||||
if (setup) return true;
|
|
||||||
if (triedAndFailed) return false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
setup(player);
|
|
||||||
setup = true;
|
|
||||||
return true;
|
|
||||||
} catch (Throwable e) {
|
|
||||||
triedAndFailed = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean sendJsonMessage(Player player, String json) {
|
|
||||||
if (!trySetup(player)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Object connection = PLAYER_CONNECTION_FIELD.get(GET_HANDLE_METHOD.invoke(player));
|
|
||||||
SEND_PACKET_METHOD.invoke(connection, PACKET_CHAT_CONSTRUCTOR.newInstance(SERIALIZE_METHOD.invoke(null, json)));
|
|
||||||
return true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -28,10 +28,12 @@ package me.lucko.luckperms.bukkit.compat;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
public final class CraftBukkitUtil {
|
public final class CraftBukkitUtil {
|
||||||
private static final String SERVER_VERSION = getServerVersion();
|
private CraftBukkitUtil() {}
|
||||||
private static final boolean CHAT_COMPATIBLE = !SERVER_VERSION.startsWith(".v1_7_");
|
|
||||||
|
|
||||||
private static String getServerVersion() {
|
private static final String SERVER_PACKAGE_VERSION = getServerPackageVersion();
|
||||||
|
private static final boolean CHAT_COMPATIBLE = !SERVER_PACKAGE_VERSION.startsWith(".v1_7_");
|
||||||
|
|
||||||
|
private static String getServerPackageVersion() {
|
||||||
Class<?> server = Bukkit.getServer().getClass();
|
Class<?> server = Bukkit.getServer().getClass();
|
||||||
if (!server.getSimpleName().equals("CraftServer")) {
|
if (!server.getSimpleName().equals("CraftServer")) {
|
||||||
return ".";
|
return ".";
|
||||||
@@ -50,7 +52,7 @@ public final class CraftBukkitUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String nms(String className) {
|
public static String nms(String className) {
|
||||||
return "net.minecraft.server" + SERVER_VERSION + className;
|
return "net.minecraft.server" + SERVER_PACKAGE_VERSION + className;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> nmsClass(String className) throws ClassNotFoundException {
|
public static Class<?> nmsClass(String className) throws ClassNotFoundException {
|
||||||
@@ -58,13 +60,10 @@ public final class CraftBukkitUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String obc(String className) {
|
public static String obc(String className) {
|
||||||
return "org.bukkit.craftbukkit" + SERVER_VERSION + className;
|
return "org.bukkit.craftbukkit" + SERVER_PACKAGE_VERSION + className;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> obcClass(String className) throws ClassNotFoundException {
|
public static Class<?> obcClass(String className) throws ClassNotFoundException {
|
||||||
return Class.forName(obc(className));
|
return Class.forName(obc(className));
|
||||||
}
|
}
|
||||||
|
|
||||||
private CraftBukkitUtil() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -40,19 +40,28 @@ import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
|||||||
import me.lucko.commodore.Commodore;
|
import me.lucko.commodore.Commodore;
|
||||||
import me.lucko.commodore.CommodoreProvider;
|
import me.lucko.commodore.CommodoreProvider;
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
public class LuckPermsBrigadier {
|
public class LuckPermsBrigadier {
|
||||||
|
|
||||||
public static void register(LPBukkitPlugin plugin, Command pluginCommand) throws Exception {
|
public static void register(LPBukkitPlugin plugin, Command pluginCommand) throws Exception {
|
||||||
|
// register completions with commodore
|
||||||
Commodore commodore = CommodoreProvider.getCommodore(plugin.getBootstrap());
|
Commodore commodore = CommodoreProvider.getCommodore(plugin.getBootstrap());
|
||||||
try (InputStream is = plugin.getBootstrap().getResourceStream("luckperms-brigadier.json.gz")) {
|
try (InputStream is = plugin.getBootstrap().getResourceStream("luckperms-brigadier.json.gz")) {
|
||||||
if (is == null) {
|
if (is == null) {
|
||||||
@@ -65,6 +74,31 @@ public class LuckPermsBrigadier {
|
|||||||
commodore.register(pluginCommand, command);
|
commodore.register(pluginCommand, command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add event listener to prevent completions from being send to players without permission
|
||||||
|
// to use any LP commands.
|
||||||
|
PluginManager pluginManager = plugin.getBootstrap().getServer().getPluginManager();
|
||||||
|
pluginManager.registerEvents(new PermissionListener(plugin, pluginCommand), plugin.getBootstrap());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class PermissionListener implements Listener {
|
||||||
|
private final LPBukkitPlugin plugin;
|
||||||
|
private final List<String> aliases;
|
||||||
|
|
||||||
|
private PermissionListener(LPBukkitPlugin plugin, Command pluginCommand) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.aliases = Commodore.getAliases(pluginCommand).stream()
|
||||||
|
.flatMap(alias -> Stream.of(alias, "minecraft:" + alias))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onCommandSend(PlayerCommandSendEvent e) {
|
||||||
|
Sender playerAsSender = this.plugin.getSenderFactory().wrap(e.getPlayer());
|
||||||
|
if (!this.plugin.getCommandManager().hasPermissionForAny(playerAsSender)) {
|
||||||
|
e.getCommands().removeAll(this.aliases);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArgumentBuilder deserialize(JsonObject data) {
|
private static ArgumentBuilder deserialize(JsonObject data) {
|
||||||
|
|||||||
+13
-12
@@ -23,19 +23,20 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.contexts;
|
package me.lucko.luckperms.bukkit.context;
|
||||||
|
|
||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
|
||||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.LookupSetting;
|
import me.lucko.luckperms.api.LookupSetting;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
|
import me.lucko.luckperms.common.cache.LoadingMap;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
import me.lucko.luckperms.common.context.ContextManager;
|
||||||
import me.lucko.luckperms.common.contexts.ContextsCache;
|
import me.lucko.luckperms.common.context.ContextsCache;
|
||||||
import me.lucko.luckperms.common.contexts.ContextsSupplier;
|
import me.lucko.luckperms.common.context.ContextsSupplier;
|
||||||
|
import me.lucko.luckperms.common.util.CaffeineFactory;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -45,11 +46,10 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class BukkitContextManager extends ContextManager<Player> {
|
public class BukkitContextManager extends ContextManager<Player> {
|
||||||
|
|
||||||
// cache the creation of ContextsCache instances for online players with no expiry
|
// cache the creation of ContextsCache instances for online players with no expiry
|
||||||
private final LoadingCache<Player, ContextsCache<Player>> onlineSubjectCaches = Caffeine.newBuilder()
|
private final LoadingMap<Player, ContextsCache<Player>> onlineSubjectCaches = LoadingMap.of(key -> new ContextsCache<>(key, this));
|
||||||
.build(key -> new ContextsCache<>(key, this));
|
|
||||||
|
|
||||||
// cache the creation of ContextsCache instances for offline players with a 1m expiry
|
// cache the creation of ContextsCache instances for offline players with a 1m expiry
|
||||||
private final LoadingCache<Player, ContextsCache<Player>> offlineSubjectCaches = Caffeine.newBuilder()
|
private final LoadingCache<Player, ContextsCache<Player>> offlineSubjectCaches = CaffeineFactory.newBuilder()
|
||||||
.expireAfterAccess(1, TimeUnit.MINUTES)
|
.expireAfterAccess(1, TimeUnit.MINUTES)
|
||||||
.build(key -> {
|
.build(key -> {
|
||||||
ContextsCache<Player> cache = this.onlineSubjectCaches.getIfPresent(key);
|
ContextsCache<Player> cache = this.onlineSubjectCaches.getIfPresent(key);
|
||||||
@@ -64,7 +64,7 @@ public class BukkitContextManager extends ContextManager<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerQuit(Player player) {
|
public void onPlayerQuit(Player player) {
|
||||||
this.onlineSubjectCaches.invalidate(player);
|
this.onlineSubjectCaches.remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -99,12 +99,13 @@ public class BukkitContextManager extends ContextManager<Player> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Contexts formContexts(Player subject, ImmutableContextSet contextSet) {
|
public Contexts formContexts(Player subject, ImmutableContextSet contextSet) {
|
||||||
EnumSet<LookupSetting> settings = this.plugin.getConfiguration().get(ConfigKeys.LOOKUP_SETTINGS);
|
Contexts contexts = this.plugin.getConfiguration().get(ConfigKeys.GLOBAL_CONTEXTS);
|
||||||
if (subject.isOp()) {
|
if (subject.isOp()) {
|
||||||
settings = EnumSet.copyOf(settings);
|
EnumSet<LookupSetting> settings = EnumSet.copyOf(contexts.getSettings());
|
||||||
settings.add(LookupSetting.IS_OP);
|
settings.add(LookupSetting.IS_OP);
|
||||||
|
contexts = contexts.setSettings(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Contexts.of(contextSet, settings);
|
return contexts.setContexts(contextSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.contexts;
|
package me.lucko.luckperms.bukkit.context;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.context.ContextCalculator;
|
import me.lucko.luckperms.api.context.ContextCalculator;
|
||||||
+1
-1
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.model.dummy;
|
package me.lucko.luckperms.bukkit.inject.dummy;
|
||||||
|
|
||||||
import org.bukkit.permissions.PermissibleBase;
|
import org.bukkit.permissions.PermissibleBase;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
+1
-1
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.model.dummy;
|
package me.lucko.luckperms.bukkit.inject.dummy;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
+23
-21
@@ -23,17 +23,19 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.model.permissible;
|
package me.lucko.luckperms.bukkit.inject.permissible;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
|
import me.lucko.luckperms.bukkit.calculator.DefaultsProcessor;
|
||||||
|
import me.lucko.luckperms.common.calculator.result.TristateResult;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.contexts.ContextsSupplier;
|
import me.lucko.luckperms.common.context.ContextsSupplier;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.permissions.PermissibleBase;
|
import org.bukkit.permissions.PermissibleBase;
|
||||||
@@ -136,8 +138,17 @@ public class LPPermissible extends PermissibleBase {
|
|||||||
throw new NullPointerException("permission");
|
throw new NullPointerException("permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission, CheckOrigin.PLATFORM_LOOKUP_CHECK);
|
TristateResult result = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission, PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK);
|
||||||
return ts != Tristate.UNDEFINED || Permission.DEFAULT_PERMISSION.getValue(isOp());
|
if (result.result() == Tristate.UNDEFINED) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ignore matches made from looking up in the permission map (replicate bukkit behaviour)
|
||||||
|
if (result.processorClass() == DefaultsProcessor.class && "permission map".equals(result.cause())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -146,16 +157,7 @@ public class LPPermissible extends PermissibleBase {
|
|||||||
throw new NullPointerException("permission");
|
throw new NullPointerException("permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission.getName(), CheckOrigin.PLATFORM_LOOKUP_CHECK);
|
return isPermissionSet(permission.getName());
|
||||||
if (ts != Tristate.UNDEFINED) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUKKIT_DEFAULT_PERMISSIONS)) {
|
|
||||||
return Permission.DEFAULT_PERMISSION.getValue(isOp());
|
|
||||||
} else {
|
|
||||||
return permission.getDefault().getValue(isOp());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -164,7 +166,7 @@ public class LPPermissible extends PermissibleBase {
|
|||||||
throw new NullPointerException("permission");
|
throw new NullPointerException("permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission, CheckOrigin.PLATFORM_PERMISSION_CHECK);
|
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission, PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK).result();
|
||||||
return ts != Tristate.UNDEFINED ? ts.asBoolean() : Permission.DEFAULT_PERMISSION.getValue(isOp());
|
return ts != Tristate.UNDEFINED ? ts.asBoolean() : Permission.DEFAULT_PERMISSION.getValue(isOp());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,15 +176,15 @@ public class LPPermissible extends PermissibleBase {
|
|||||||
throw new NullPointerException("permission");
|
throw new NullPointerException("permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission.getName(), CheckOrigin.PLATFORM_PERMISSION_CHECK);
|
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission.getName(), PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK).result();
|
||||||
if (ts != Tristate.UNDEFINED) {
|
if (ts != Tristate.UNDEFINED) {
|
||||||
return ts.asBoolean();
|
return ts.asBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUKKIT_DEFAULT_PERMISSIONS)) {
|
if (this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUKKIT_DEFAULT_PERMISSIONS)) {
|
||||||
return Permission.DEFAULT_PERMISSION.getValue(isOp());
|
|
||||||
} else {
|
|
||||||
return permission.getDefault().getValue(isOp());
|
return permission.getDefault().getValue(isOp());
|
||||||
|
} else {
|
||||||
|
return Permission.DEFAULT_PERMISSION.getValue(isOp());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+2
-2
@@ -23,12 +23,12 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.model.permissible;
|
package me.lucko.luckperms.bukkit.inject.permissible;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.bukkit.model.dummy.DummyPlugin;
|
import me.lucko.luckperms.bukkit.inject.dummy.DummyPlugin;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
+11
-14
@@ -23,14 +23,15 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.model.permissible;
|
package me.lucko.luckperms.bukkit.inject.permissible;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.bukkit.model.dummy.DummyPermissibleBase;
|
import me.lucko.luckperms.bukkit.inject.dummy.DummyPermissibleBase;
|
||||||
|
import me.lucko.luckperms.common.calculator.result.TristateResult;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
|
||||||
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
|
|
||||||
import org.bukkit.permissions.PermissibleBase;
|
import org.bukkit.permissions.PermissibleBase;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
@@ -47,7 +48,7 @@ import java.util.Set;
|
|||||||
* Method calls are forwarded to the delegate permissible.
|
* Method calls are forwarded to the delegate permissible.
|
||||||
*/
|
*/
|
||||||
public class MonitoredPermissibleBase extends PermissibleBase {
|
public class MonitoredPermissibleBase extends PermissibleBase {
|
||||||
private final LuckPermsPlugin plugin;
|
final LuckPermsPlugin plugin;
|
||||||
private final PermissibleBase delegate;
|
private final PermissibleBase delegate;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
@@ -64,14 +65,10 @@ public class MonitoredPermissibleBase extends PermissibleBase {
|
|||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.initialised = true;
|
this.initialised = true;
|
||||||
|
|
||||||
// since we effectively cancel the execution of this call in the super
|
|
||||||
// constructor we need to call it again.
|
|
||||||
recalculatePermissions();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logCheck(CheckOrigin origin, String permission, boolean result) {
|
private void logCheck(PermissionCheckEvent.Origin origin, String permission, boolean result) {
|
||||||
this.plugin.getVerboseHandler().offerCheckData(origin, this.name, ContextSet.empty(), permission, Tristate.fromBoolean(result));
|
this.plugin.getVerboseHandler().offerPermissionCheckEvent(origin, this.name, ContextSet.empty(), permission, TristateResult.of(Tristate.fromBoolean(result)));
|
||||||
this.plugin.getPermissionRegistry().offer(permission);
|
this.plugin.getPermissionRegistry().offer(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +83,7 @@ public class MonitoredPermissibleBase extends PermissibleBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final boolean result = this.delegate.isPermissionSet(permission);
|
final boolean result = this.delegate.isPermissionSet(permission);
|
||||||
logCheck(CheckOrigin.PLATFORM_LOOKUP_CHECK, permission, result);
|
logCheck(PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK, permission, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +94,7 @@ public class MonitoredPermissibleBase extends PermissibleBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final boolean result = this.delegate.isPermissionSet(permission);
|
final boolean result = this.delegate.isPermissionSet(permission);
|
||||||
logCheck(CheckOrigin.PLATFORM_LOOKUP_CHECK, permission.getName(), result);
|
logCheck(PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK, permission.getName(), result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +105,7 @@ public class MonitoredPermissibleBase extends PermissibleBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final boolean result = this.delegate.hasPermission(permission);
|
final boolean result = this.delegate.hasPermission(permission);
|
||||||
logCheck(CheckOrigin.PLATFORM_PERMISSION_CHECK, permission, result);
|
logCheck(PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK, permission, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +116,7 @@ public class MonitoredPermissibleBase extends PermissibleBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final boolean result = this.delegate.hasPermission(permission);
|
final boolean result = this.delegate.hasPermission(permission);
|
||||||
logCheck(CheckOrigin.PLATFORM_PERMISSION_CHECK, permission.getName(), result);
|
logCheck(PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK, permission.getName(), result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
+4
-5
@@ -23,10 +23,10 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.model.permissible;
|
package me.lucko.luckperms.bukkit.inject.permissible;
|
||||||
|
|
||||||
import me.lucko.luckperms.bukkit.compat.CraftBukkitUtil;
|
import me.lucko.luckperms.bukkit.compat.CraftBukkitUtil;
|
||||||
import me.lucko.luckperms.bukkit.model.dummy.DummyPermissibleBase;
|
import me.lucko.luckperms.bukkit.inject.dummy.DummyPermissibleBase;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.permissions.PermissibleBase;
|
import org.bukkit.permissions.PermissibleBase;
|
||||||
@@ -42,6 +42,7 @@ import java.util.List;
|
|||||||
* checks made by plugins.
|
* checks made by plugins.
|
||||||
*/
|
*/
|
||||||
public final class PermissibleInjector {
|
public final class PermissibleInjector {
|
||||||
|
private PermissibleInjector() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All permission checks made on standard Bukkit objects are effectively proxied to a
|
* All permission checks made on standard Bukkit objects are effectively proxied to a
|
||||||
@@ -120,7 +121,7 @@ public final class PermissibleInjector {
|
|||||||
* @param dummy if the replacement permissible should be a dummy.
|
* @param dummy if the replacement permissible should be a dummy.
|
||||||
* @throws Exception propagates any exceptions which were thrown during uninjection
|
* @throws Exception propagates any exceptions which were thrown during uninjection
|
||||||
*/
|
*/
|
||||||
public static void unInject(Player player, boolean dummy) throws Exception {
|
public static void uninject(Player player, boolean dummy) throws Exception {
|
||||||
|
|
||||||
// gets the players current permissible.
|
// gets the players current permissible.
|
||||||
PermissibleBase permissible = (PermissibleBase) HUMAN_ENTITY_PERMISSIBLE_FIELD.get(player);
|
PermissibleBase permissible = (PermissibleBase) HUMAN_ENTITY_PERMISSIBLE_FIELD.get(player);
|
||||||
@@ -151,6 +152,4 @@ public final class PermissibleInjector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PermissibleInjector() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+38
-12
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.model.permissible;
|
package me.lucko.luckperms.bukkit.inject.permissible;
|
||||||
|
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
import me.lucko.luckperms.bukkit.compat.CraftBukkitUtil;
|
import me.lucko.luckperms.bukkit.compat.CraftBukkitUtil;
|
||||||
@@ -43,8 +43,15 @@ import java.util.Objects;
|
|||||||
public class PermissibleMonitoringInjector implements Runnable {
|
public class PermissibleMonitoringInjector implements Runnable {
|
||||||
private final LPBukkitPlugin plugin;
|
private final LPBukkitPlugin plugin;
|
||||||
|
|
||||||
public PermissibleMonitoringInjector(LPBukkitPlugin plugin) {
|
public enum Mode {
|
||||||
|
INJECT, UNINJECT
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Mode mode;
|
||||||
|
|
||||||
|
public PermissibleMonitoringInjector(LPBukkitPlugin plugin, Mode mode) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -68,14 +75,24 @@ public class PermissibleMonitoringInjector implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private MonitoredPermissibleBase wrap(PermissibleBase permBase, String name) {
|
private PermissibleBase transform(PermissibleBase permBase, String name) {
|
||||||
Objects.requireNonNull(permBase, "permBase");
|
Objects.requireNonNull(permBase, "permBase");
|
||||||
|
|
||||||
|
// don't bother injecting if already setup.
|
||||||
|
if (this.mode == Mode.INJECT && permBase instanceof MonitoredPermissibleBase && ((MonitoredPermissibleBase) permBase).plugin == this.plugin) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// unwrap any previous injection
|
// unwrap any previous injection
|
||||||
if (permBase instanceof MonitoredPermissibleBase) {
|
if (permBase instanceof MonitoredPermissibleBase) {
|
||||||
permBase = ((MonitoredPermissibleBase) permBase).getDelegate();
|
permBase = ((MonitoredPermissibleBase) permBase).getDelegate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the mode is uninject, just return the unwrapped PermissibleBase
|
||||||
|
if (this.mode == Mode.UNINJECT) {
|
||||||
|
return permBase;
|
||||||
|
}
|
||||||
|
|
||||||
// create a monitored instance which delegates to the previous PermissibleBase
|
// create a monitored instance which delegates to the previous PermissibleBase
|
||||||
return new MonitoredPermissibleBase(this.plugin, permBase, name);
|
return new MonitoredPermissibleBase(this.plugin, permBase, name);
|
||||||
}
|
}
|
||||||
@@ -93,10 +110,13 @@ public class PermissibleMonitoringInjector implements Runnable {
|
|||||||
// get the PermissibleBase instance
|
// get the PermissibleBase instance
|
||||||
PermissibleBase permBase = (PermissibleBase) permField.get(consoleSender);
|
PermissibleBase permBase = (PermissibleBase) permField.get(consoleSender);
|
||||||
|
|
||||||
// create a monitored instance which delegates to the previous PermissibleBase
|
// create a new instance which delegates to the previous PermissibleBase
|
||||||
MonitoredPermissibleBase newPermBase = wrap(permBase, "internal/console");
|
PermissibleBase newPermBase = transform(permBase, "internal/console");
|
||||||
|
if (newPermBase == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// inject the monitored instance
|
// inject the new instance
|
||||||
permField.set(consoleSender, newPermBase);
|
permField.set(consoleSender, newPermBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,10 +137,13 @@ public class PermissibleMonitoringInjector implements Runnable {
|
|||||||
permBase = new PermissibleBase(new CommandBlockServerOperator());
|
permBase = new PermissibleBase(new CommandBlockServerOperator());
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a monitored instance which delegates to the previous PermissibleBase
|
// create a new instance which delegates to the previous PermissibleBase
|
||||||
MonitoredPermissibleBase newPermBase = wrap(permBase, "internal/commandblock");
|
PermissibleBase newPermBase = transform(permBase, "internal/commandblock");
|
||||||
|
if (newPermBase == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// inject the monitored instance
|
// inject the new instance
|
||||||
permField.set(null, newPermBase);
|
permField.set(null, newPermBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,10 +163,13 @@ public class PermissibleMonitoringInjector implements Runnable {
|
|||||||
Field permField = entityClass.getDeclaredField("perm");
|
Field permField = entityClass.getDeclaredField("perm");
|
||||||
permField.setAccessible(true);
|
permField.setAccessible(true);
|
||||||
|
|
||||||
// create a monitored instance which delegates to the previous PermissibleBase
|
// create a new instance which delegates to the previous PermissibleBase
|
||||||
MonitoredPermissibleBase newPermBase = wrap(permBase, "internal/entity");
|
PermissibleBase newPermBase = transform(permBase, "internal/entity");
|
||||||
|
if (newPermBase == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// inject the monitored instance
|
// inject the new instance
|
||||||
permField.set(null, newPermBase);
|
permField.set(null, newPermBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
+1
-1
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.model.server;
|
package me.lucko.luckperms.bukkit.inject.server;
|
||||||
|
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
|
|
||||||
+1
-1
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.model.server;
|
package me.lucko.luckperms.bukkit.inject.server;
|
||||||
|
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
|
|
||||||
+1
-1
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.model.server;
|
package me.lucko.luckperms.bukkit.inject.server;
|
||||||
|
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
|
|
||||||
+11
-2
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.model.server;
|
package me.lucko.luckperms.bukkit.inject.server;
|
||||||
|
|
||||||
import com.google.common.collect.ForwardingSet;
|
import com.google.common.collect.ForwardingSet;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@@ -33,7 +33,7 @@ import com.google.common.collect.Maps;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
import me.lucko.luckperms.common.buffers.Cache;
|
import me.lucko.luckperms.common.cache.Cache;
|
||||||
|
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
@@ -95,6 +95,8 @@ public final class LPDefaultsMap implements Map<Boolean, Set<Permission>> {
|
|||||||
|
|
||||||
private void invalidate(boolean op) {
|
private void invalidate(boolean op) {
|
||||||
getCache(op).invalidate();
|
getCache(op).invalidate();
|
||||||
|
this.plugin.getUserManager().invalidateAllPermissionCalculators();
|
||||||
|
this.plugin.getGroupManager().invalidateAllPermissionCalculators();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,6 +178,13 @@ public final class LPDefaultsMap implements Map<Boolean, Set<Permission>> {
|
|||||||
invalidate(this.op);
|
invalidate(this.op);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean remove(@NonNull Object object) {
|
||||||
|
boolean ret = super.remove(object);
|
||||||
|
invalidate(this.op);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+107
-30
@@ -23,14 +23,12 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.model.server;
|
package me.lucko.luckperms.bukkit.inject.server;
|
||||||
|
|
||||||
import com.github.benmanes.caffeine.cache.CacheLoader;
|
|
||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
|
||||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
|
||||||
import com.google.common.collect.ForwardingMap;
|
import com.google.common.collect.ForwardingMap;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.cache.LoadingMap;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.treeview.PermissionRegistry;
|
import me.lucko.luckperms.common.treeview.PermissionRegistry;
|
||||||
|
|
||||||
@@ -39,18 +37,21 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A replacement map for the 'permissions' instance in Bukkit's SimplePluginManager.
|
* A replacement map for the 'permissions' instance in Bukkit's SimplePluginManager.
|
||||||
*
|
*
|
||||||
* This instance allows LuckPerms to intercept calls to
|
* This instance allows LuckPerms to intercept calls to
|
||||||
* {@link PluginManager#addPermission(Permission)} and record permissions in the
|
* {@link PluginManager#addPermission(Permission)} and record permissions in the
|
||||||
* {@link PermissionRegistry}.
|
* {@link PermissionRegistry}. It also lets us monitor changes to child permission
|
||||||
|
* relationships.
|
||||||
*
|
*
|
||||||
* It also allows us to pre-determine child permission relationships.
|
* It also allows us to pre-determine child permission relationships.
|
||||||
*
|
*
|
||||||
@@ -58,15 +59,23 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
*/
|
*/
|
||||||
public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
||||||
|
|
||||||
|
private static final Field PERMISSION_CHILDREN_FIELD;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
PERMISSION_CHILDREN_FIELD = Permission.class.getDeclaredField("children");
|
||||||
|
PERMISSION_CHILDREN_FIELD.setAccessible(true);
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
throw new ExceptionInInitializerError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Uses perm.getName().toLowerCase(java.util.Locale.ENGLISH); to determine the key
|
// Uses perm.getName().toLowerCase(java.util.Locale.ENGLISH); to determine the key
|
||||||
private final Map<String, Permission> delegate = new ConcurrentHashMap<>();
|
private final Map<String, Permission> delegate = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
// cache from permission --> children
|
// cache from permission --> children
|
||||||
private final LoadingCache<String, Map<String, Boolean>> trueChildPermissions = Caffeine.newBuilder()
|
private final Map<String, Map<String, Boolean>> trueChildPermissions = LoadingMap.of(new ChildPermissionResolver(true));
|
||||||
.build(new ChildPermissionResolver(true));
|
private final Map<String, Map<String, Boolean>> falseChildPermissions = LoadingMap.of(new ChildPermissionResolver(false));
|
||||||
|
|
||||||
private final LoadingCache<String, Map<String, Boolean>> falseChildPermissions = Caffeine.newBuilder()
|
|
||||||
.build(new ChildPermissionResolver(false));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plugin instance
|
* The plugin instance
|
||||||
@@ -83,8 +92,10 @@ public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void update() {
|
private void update() {
|
||||||
this.trueChildPermissions.invalidateAll();
|
this.trueChildPermissions.clear();
|
||||||
this.falseChildPermissions.invalidateAll();
|
this.falseChildPermissions.clear();
|
||||||
|
this.plugin.getUserManager().invalidateAllPermissionCalculators();
|
||||||
|
this.plugin.getGroupManager().invalidateAllPermissionCalculators();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -98,7 +109,7 @@ public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
|||||||
Objects.requireNonNull(value, "value");
|
Objects.requireNonNull(value, "value");
|
||||||
|
|
||||||
this.plugin.getPermissionRegistry().insert(key);
|
this.plugin.getPermissionRegistry().insert(key);
|
||||||
Permission ret = super.put(key, value);
|
Permission ret = super.put(key, inject(value));
|
||||||
update();
|
update();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -110,32 +121,21 @@ public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Permission putIfAbsent(String key, Permission value) {
|
|
||||||
Objects.requireNonNull(key, "key");
|
|
||||||
Objects.requireNonNull(value, "value");
|
|
||||||
|
|
||||||
this.plugin.getPermissionRegistry().insert(key);
|
|
||||||
Permission ret = super.putIfAbsent(key, value);
|
|
||||||
update();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// null-safe - the plugin manager uses hashmap
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Permission remove(@Nullable Object object) {
|
public Permission remove(@Nullable Object object) {
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return super.remove(object);
|
return uninject(super.remove(object));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object key, Object value) {
|
public boolean remove(Object key, Object value) {
|
||||||
return key != null && value != null && super.remove(key, value);
|
return key != null && value != null && super.remove(key, uninject(((Permission) value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check for null
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsKey(@Nullable Object key) {
|
public boolean containsKey(@Nullable Object key) {
|
||||||
return key != null && super.containsKey(key);
|
return key != null && super.containsKey(key);
|
||||||
@@ -154,7 +154,7 @@ public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
|||||||
return super.get(key);
|
return super.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ChildPermissionResolver implements CacheLoader<String, Map<String, Boolean>> {
|
private final class ChildPermissionResolver implements Function<String, Map<String, Boolean>> {
|
||||||
private final boolean value;
|
private final boolean value;
|
||||||
|
|
||||||
private ChildPermissionResolver(boolean value) {
|
private ChildPermissionResolver(boolean value) {
|
||||||
@@ -162,7 +162,7 @@ public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Boolean> load(@NonNull String key) {
|
public Map<String, Boolean> apply(@NonNull String key) {
|
||||||
Map<String, Boolean> children = new HashMap<>();
|
Map<String, Boolean> children = new HashMap<>();
|
||||||
resolveChildren(children, Collections.singletonMap(key, this.value), false);
|
resolveChildren(children, Collections.singletonMap(key, this.value), false);
|
||||||
children.remove(key, this.value);
|
children.remove(key, this.value);
|
||||||
@@ -190,4 +190,81 @@ public final class LPPermissionMap extends ForwardingMap<String, Permission> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Permission inject(Permission permission) {
|
||||||
|
if (permission == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
//noinspection unchecked
|
||||||
|
Map<String, Boolean> children = (Map<String, Boolean>) PERMISSION_CHILDREN_FIELD.get(permission);
|
||||||
|
while (children instanceof PermissionNotifyingChildrenMap) {
|
||||||
|
children = ((PermissionNotifyingChildrenMap) children).delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
PermissionNotifyingChildrenMap notifyingChildren = new PermissionNotifyingChildrenMap(children);
|
||||||
|
PERMISSION_CHILDREN_FIELD.set(permission, notifyingChildren);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Permission uninject(Permission permission) {
|
||||||
|
if (permission == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
//noinspection unchecked
|
||||||
|
Map<String, Boolean> children = (Map<String, Boolean>) PERMISSION_CHILDREN_FIELD.get(permission);
|
||||||
|
while (children instanceof PermissionNotifyingChildrenMap) {
|
||||||
|
children = ((PermissionNotifyingChildrenMap) children).delegate;
|
||||||
|
}
|
||||||
|
PERMISSION_CHILDREN_FIELD.set(permission, children);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final class PermissionNotifyingChildrenMap extends ForwardingMap<String, Boolean> {
|
||||||
|
private final Map<String, Boolean> delegate;
|
||||||
|
|
||||||
|
PermissionNotifyingChildrenMap(Map<String, Boolean> delegate) {
|
||||||
|
this.delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Map<String, Boolean> delegate() {
|
||||||
|
return this.delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean put(@NonNull String key, @NonNull Boolean value) {
|
||||||
|
Boolean ret = super.put(key, value);
|
||||||
|
LPPermissionMap.this.update();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putAll(@NonNull Map<? extends String, ? extends Boolean> map) {
|
||||||
|
super.putAll(map);
|
||||||
|
LPPermissionMap.this.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean remove(@NonNull Object object) {
|
||||||
|
Boolean ret = super.remove(object);
|
||||||
|
LPPermissionMap.this.update();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
super.clear();
|
||||||
|
LPPermissionMap.this.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+7
-7
@@ -23,13 +23,13 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bukkit.model.server;
|
package me.lucko.luckperms.bukkit.inject.server;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.permissions.Permissible;
|
import org.bukkit.permissions.Permissible;
|
||||||
@@ -177,8 +177,8 @@ public final class LPSubscriptionMap extends HashMap<String, Map<Permissible, Bo
|
|||||||
// if the key is a player, check their LPPermissible first
|
// if the key is a player, check their LPPermissible first
|
||||||
if (isPlayer) {
|
if (isPlayer) {
|
||||||
Permissible p = (Permissible) key;
|
Permissible p = (Permissible) key;
|
||||||
if (p.isPermissionSet(this.permission)) {
|
if (p.hasPermission(this.permission)) {
|
||||||
return p.hasPermission(this.permission);
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,8 +191,8 @@ public final class LPSubscriptionMap extends HashMap<String, Map<Permissible, Bo
|
|||||||
// then try the permissible, if we haven't already
|
// then try the permissible, if we haven't already
|
||||||
if (!isPlayer && key instanceof Permissible) {
|
if (!isPlayer && key instanceof Permissible) {
|
||||||
Permissible p = (Permissible) key;
|
Permissible p = (Permissible) key;
|
||||||
if (p.isPermissionSet(this.permission)) {
|
if (p.hasPermission(this.permission)) {
|
||||||
return p.hasPermission(this.permission);
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +220,7 @@ public final class LPSubscriptionMap extends HashMap<String, Map<Permissible, Bo
|
|||||||
public @NonNull Set<Permissible> keySet() {
|
public @NonNull Set<Permissible> keySet() {
|
||||||
// gather players (LPPermissibles)
|
// gather players (LPPermissibles)
|
||||||
Set<Permissible> players = LPSubscriptionMap.this.plugin.getBootstrap().getServer().getOnlinePlayers().stream()
|
Set<Permissible> players = LPSubscriptionMap.this.plugin.getBootstrap().getServer().getOnlinePlayers().stream()
|
||||||
.filter(player -> player.isPermissionSet(this.permission))
|
.filter(player -> player.hasPermission(this.permission) || player.isPermissionSet(this.permission))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
// then combine the players with the backing map
|
// then combine the players with the backing map
|
||||||
+34
-5
@@ -26,8 +26,8 @@
|
|||||||
package me.lucko.luckperms.bukkit.listeners;
|
package me.lucko.luckperms.bukkit.listeners;
|
||||||
|
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
import me.lucko.luckperms.bukkit.model.permissible.LPPermissible;
|
import me.lucko.luckperms.bukkit.inject.permissible.LPPermissible;
|
||||||
import me.lucko.luckperms.bukkit.model.permissible.PermissibleInjector;
|
import me.lucko.luckperms.bukkit.inject.permissible.PermissibleInjector;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.locale.message.Message;
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
@@ -50,12 +50,32 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class BukkitConnectionListener extends AbstractConnectionListener implements Listener {
|
public class BukkitConnectionListener extends AbstractConnectionListener implements Listener {
|
||||||
private final LPBukkitPlugin plugin;
|
private final LPBukkitPlugin plugin;
|
||||||
|
|
||||||
|
private final boolean detectedCraftBukkitOfflineMode;
|
||||||
|
|
||||||
private final Set<UUID> deniedAsyncLogin = Collections.synchronizedSet(new HashSet<>());
|
private final Set<UUID> deniedAsyncLogin = Collections.synchronizedSet(new HashSet<>());
|
||||||
private final Set<UUID> deniedLogin = Collections.synchronizedSet(new HashSet<>());
|
private final Set<UUID> deniedLogin = Collections.synchronizedSet(new HashSet<>());
|
||||||
|
|
||||||
public BukkitConnectionListener(LPBukkitPlugin plugin) {
|
public BukkitConnectionListener(LPBukkitPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
// check for craftbukkit + offline mode combination
|
||||||
|
String version = plugin.getBootstrap().getServer().getVersion();
|
||||||
|
boolean onlineMode = plugin.getBootstrap().getServer().getOnlineMode();
|
||||||
|
|
||||||
|
if (!onlineMode && version.startsWith("git-Bukkit-")) {
|
||||||
|
printCraftBukkitOfflineModeError();
|
||||||
|
this.detectedCraftBukkitOfflineMode = true;
|
||||||
|
} else {
|
||||||
|
this.detectedCraftBukkitOfflineMode = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void printCraftBukkitOfflineModeError() {
|
||||||
|
this.plugin.getLogger().warn("It appears that your server is running CraftBukkit and configured in offline (cracked) mode.");
|
||||||
|
this.plugin.getLogger().warn("Due to a CraftBukkit limitation, LuckPerms cannot function correctly in this setup.");
|
||||||
|
this.plugin.getLogger().warn("To resolve this, please either a) upgrade from CraftBukkit to Spigot or Paper, or b) enable online-mode.");
|
||||||
|
this.plugin.getLogger().warn("For more info, please see: https://github.com/lucko/LuckPerms/wiki/Installation#craftbukkit-and-offline-mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
@@ -86,8 +106,8 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
|
|||||||
- setting up cached data. */
|
- setting up cached data. */
|
||||||
try {
|
try {
|
||||||
User user = loadUser(e.getUniqueId(), e.getName());
|
User user = loadUser(e.getUniqueId(), e.getName());
|
||||||
this.plugin.getEventFactory().handleUserLoginProcess(e.getUniqueId(), e.getName(), user);
|
|
||||||
recordConnection(e.getUniqueId());
|
recordConnection(e.getUniqueId());
|
||||||
|
this.plugin.getEventFactory().handlePlayerLoginProcess(e.getUniqueId(), e.getName(), user);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + e.getUniqueId() + " - " + e.getName());
|
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + e.getUniqueId() + " - " + e.getName());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@@ -95,6 +115,7 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
|
|||||||
// deny the connection
|
// deny the connection
|
||||||
this.deniedAsyncLogin.add(e.getUniqueId());
|
this.deniedAsyncLogin.add(e.getUniqueId());
|
||||||
e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, Message.LOADING_DATABASE_ERROR.asString(this.plugin.getLocaleManager()));
|
e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, Message.LOADING_DATABASE_ERROR.asString(this.plugin.getLocaleManager()));
|
||||||
|
this.plugin.getEventFactory().handlePlayerLoginProcess(e.getUniqueId(), e.getName(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,9 +154,17 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
|
|||||||
this.deniedLogin.add(player.getUniqueId());
|
this.deniedLogin.add(player.getUniqueId());
|
||||||
|
|
||||||
if (!getUniqueConnections().contains(player.getUniqueId())) {
|
if (!getUniqueConnections().contains(player.getUniqueId())) {
|
||||||
|
|
||||||
this.plugin.getLogger().warn("User " + player.getUniqueId() + " - " + player.getName() +
|
this.plugin.getLogger().warn("User " + player.getUniqueId() + " - " + player.getName() +
|
||||||
" doesn't have data pre-loaded, they have never been processed during pre-login in this session." +
|
" doesn't have data pre-loaded, they have never been processed during pre-login in this session." +
|
||||||
" - denying login.");
|
" - denying login.");
|
||||||
|
|
||||||
|
if (this.detectedCraftBukkitOfflineMode) {
|
||||||
|
printCraftBukkitOfflineModeError();
|
||||||
|
e.disallow(PlayerLoginEvent.Result.KICK_OTHER, Message.LOADING_STATE_ERROR_CB_OFFLINE_MODE.asString(this.plugin.getLocaleManager()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.plugin.getLogger().warn("User " + player.getUniqueId() + " - " + player.getName() +
|
this.plugin.getLogger().warn("User " + player.getUniqueId() + " - " + player.getName() +
|
||||||
" doesn't currently have data pre-loaded, but they have been processed before in this session." +
|
" doesn't currently have data pre-loaded, but they have been processed before in this session." +
|
||||||
@@ -164,7 +193,7 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.plugin.refreshAutoOp(player);
|
this.plugin.refreshAutoOp(player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
@@ -193,7 +222,7 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
|
|||||||
this.plugin.getBootstrap().getServer().getScheduler().runTaskLaterAsynchronously(this.plugin.getBootstrap(), () -> {
|
this.plugin.getBootstrap().getServer().getScheduler().runTaskLaterAsynchronously(this.plugin.getBootstrap(), () -> {
|
||||||
// Remove the custom permissible
|
// Remove the custom permissible
|
||||||
try {
|
try {
|
||||||
PermissibleInjector.unInject(player, true);
|
PermissibleInjector.uninject(player, true);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -75,8 +75,8 @@ public class BukkitPlatformListener implements Listener {
|
|||||||
s = s.substring(1);
|
s = s.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.startsWith("minecraft:")) {
|
if (s.contains(":")) {
|
||||||
s = s.substring("minecraft:".length());
|
s = s.substring(s.indexOf(':') + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.equals("op") || s.startsWith("op ") || s.equals("deop") || s.startsWith("deop ")) {
|
if (s.equals("op") || s.startsWith("op ") || s.equals("deop") || s.startsWith("deop ")) {
|
||||||
@@ -95,7 +95,7 @@ public class BukkitPlatformListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onWorldChange(PlayerChangedWorldEvent e) {
|
public void onWorldChange(PlayerChangedWorldEvent e) {
|
||||||
this.plugin.getContextManager().invalidateCache(e.getPlayer());
|
this.plugin.getContextManager().invalidateCache(e.getPlayer());
|
||||||
this.plugin.refreshAutoOp(e.getPlayer());
|
this.plugin.refreshAutoOp(e.getPlayer(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+4
-5
@@ -69,6 +69,10 @@ public class PluginMessageMessenger implements Messenger, PluginMessageListener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage) {
|
public void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage) {
|
||||||
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
|
out.writeUTF(outgoingMessage.asEncodedString());
|
||||||
|
byte[] data = out.toByteArray();
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -78,11 +82,6 @@ public class PluginMessageMessenger implements Messenger, PluginMessageListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
|
||||||
out.writeUTF(outgoingMessage.asEncodedString());
|
|
||||||
|
|
||||||
byte[] data = out.toByteArray();
|
|
||||||
|
|
||||||
p.sendPluginMessage(PluginMessageMessenger.this.plugin.getBootstrap(), CHANNEL, data);
|
p.sendPluginMessage(PluginMessageMessenger.this.plugin.getBootstrap(), CHANNEL, data);
|
||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,14 +25,15 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.bukkit.migration;
|
package me.lucko.luckperms.bukkit.migration;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.utils.ProgressLogger;
|
import me.lucko.luckperms.common.util.ProgressLogger;
|
||||||
import me.lucko.luckperms.common.utils.Uuids;
|
import me.lucko.luckperms.common.util.Uuids;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public final class BukkitUuids {
|
public final class BukkitUuids {
|
||||||
|
private BukkitUuids() {}
|
||||||
|
|
||||||
public static UUID lookupUuid(ProgressLogger log, String s) {
|
public static UUID lookupUuid(ProgressLogger log, String s) {
|
||||||
UUID uuid = Uuids.parse(s);
|
UUID uuid = Uuids.parse(s);
|
||||||
@@ -50,6 +51,4 @@ public final class BukkitUuids {
|
|||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BukkitUuids() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+12
-12
@@ -35,9 +35,11 @@ import me.lucko.luckperms.api.ChatMetaType;
|
|||||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||||
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
@@ -45,9 +47,9 @@ import me.lucko.luckperms.common.node.factory.NodeFactory;
|
|||||||
import me.lucko.luckperms.common.node.model.NodeTypes;
|
import me.lucko.luckperms.common.node.model.NodeTypes;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Iterators;
|
import me.lucko.luckperms.common.util.Iterators;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.util.Predicates;
|
||||||
import me.lucko.luckperms.common.utils.ProgressLogger;
|
import me.lucko.luckperms.common.util.ProgressLogger;
|
||||||
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@@ -59,8 +61,6 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import static me.lucko.luckperms.common.command.access.CommandPermission.MIGRATION;
|
|
||||||
|
|
||||||
public class MigrationBPermissions extends SubCommand<Object> {
|
public class MigrationBPermissions extends SubCommand<Object> {
|
||||||
private static final Field UCONFIG_FIELD;
|
private static final Field UCONFIG_FIELD;
|
||||||
static {
|
static {
|
||||||
@@ -73,12 +73,12 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MigrationBPermissions(LocaleManager locale) {
|
public MigrationBPermissions(LocaleManager locale) {
|
||||||
super(CommandSpec.MIGRATION_COMMAND.localize(locale), "bpermissions", MIGRATION, Predicates.alwaysFalse());
|
super(CommandSpec.MIGRATION_COMMAND.localize(locale), "bpermissions", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
||||||
ProgressLogger log = new ProgressLogger("bPermissions");
|
ProgressLogger log = new ProgressLogger(Message.MIGRATION_LOG, Message.MIGRATION_LOG_PROGRESS, "bPermissions");
|
||||||
log.addListener(plugin.getConsoleSender());
|
log.addListener(plugin.getConsoleSender());
|
||||||
log.addListener(sender);
|
log.addListener(sender);
|
||||||
|
|
||||||
@@ -116,10 +116,10 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
|||||||
return CommandResult.FAILURE;
|
return CommandResult.FAILURE;
|
||||||
}
|
}
|
||||||
AtomicInteger userLoadCount = new AtomicInteger(0);
|
AtomicInteger userLoadCount = new AtomicInteger(0);
|
||||||
users.forEach(s -> {
|
for (String user : users) {
|
||||||
world.loadOne(s, CalculableType.USER);
|
world.loadOne(user, CalculableType.USER);
|
||||||
log.logProgress("Forcefully loaded {} users so far.", userLoadCount.incrementAndGet());
|
log.logProgress("Forcefully loaded {} users so far.", userLoadCount.incrementAndGet(), ProgressLogger.DEFAULT_NOTIFY_FREQUENCY);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
log.log("Forcefully loaded all users.");
|
log.log("Forcefully loaded all users.");
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
|||||||
plugin.getStorage().saveUser(lpUser);
|
plugin.getStorage().saveUser(lpUser);
|
||||||
plugin.getUserManager().cleanup(lpUser);
|
plugin.getUserManager().cleanup(lpUser);
|
||||||
|
|
||||||
log.logProgress("Migrated {} users so far.", userCount.incrementAndGet());
|
log.logProgress("Migrated {} users so far.", userCount.incrementAndGet(), ProgressLogger.DEFAULT_NOTIFY_FREQUENCY);
|
||||||
});
|
});
|
||||||
|
|
||||||
log.log("Migrated " + userCount.get() + " users in world " + world.getName() + ".");
|
log.log("Migrated " + userCount.get() + " users in world " + world.getName() + ".");
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import me.lucko.luckperms.common.command.access.CommandPermission;
|
|||||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.model.UserIdentifier;
|
import me.lucko.luckperms.common.model.UserIdentifier;
|
||||||
@@ -41,10 +42,10 @@ import me.lucko.luckperms.common.node.factory.NodeFactory;
|
|||||||
import me.lucko.luckperms.common.node.model.NodeTypes;
|
import me.lucko.luckperms.common.node.model.NodeTypes;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Iterators;
|
import me.lucko.luckperms.common.util.Iterators;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.util.Predicates;
|
||||||
import me.lucko.luckperms.common.utils.ProgressLogger;
|
import me.lucko.luckperms.common.util.ProgressLogger;
|
||||||
import me.lucko.luckperms.common.utils.Uuids;
|
import me.lucko.luckperms.common.util.Uuids;
|
||||||
|
|
||||||
import org.anjocaido.groupmanager.GlobalGroups;
|
import org.anjocaido.groupmanager.GlobalGroups;
|
||||||
import org.anjocaido.groupmanager.GroupManager;
|
import org.anjocaido.groupmanager.GroupManager;
|
||||||
@@ -70,7 +71,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
||||||
ProgressLogger log = new ProgressLogger("GroupManager");
|
ProgressLogger log = new ProgressLogger(Message.MIGRATION_LOG, Message.MIGRATION_LOG_PROGRESS, "GroupManager");
|
||||||
log.addListener(plugin.getConsoleSender());
|
log.addListener(plugin.getConsoleSender());
|
||||||
log.addListener(sender);
|
log.addListener(sender);
|
||||||
|
|
||||||
@@ -210,7 +211,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.logProgress("Migrated {} users so far in world " + world, userWorldCount.incrementAndGet());
|
log.logProgress("Migrated {} users so far in world " + world, userWorldCount.incrementAndGet(), ProgressLogger.DEFAULT_NOTIFY_FREQUENCY);
|
||||||
});
|
});
|
||||||
log.log("Migrated " + userWorldCount.get() + " users in world " + world);
|
log.log("Migrated " + userWorldCount.get() + " users in world " + world);
|
||||||
});
|
});
|
||||||
@@ -250,7 +251,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
|||||||
|
|
||||||
plugin.getStorage().saveUser(user);
|
plugin.getStorage().saveUser(user);
|
||||||
plugin.getUserManager().cleanup(user);
|
plugin.getUserManager().cleanup(user);
|
||||||
log.logProgress("Migrated {} users so far.", userCount.incrementAndGet());
|
log.logProgress("Migrated {} users so far.", userCount.incrementAndGet(), ProgressLogger.DEFAULT_NOTIFY_FREQUENCY);
|
||||||
});
|
});
|
||||||
|
|
||||||
log.log("Migrated " + userCount.get() + " users.");
|
log.log("Migrated " + userCount.get() + " users.");
|
||||||
|
|||||||
+6
-5
@@ -34,15 +34,16 @@ import me.lucko.luckperms.common.command.access.CommandPermission;
|
|||||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Iterators;
|
import me.lucko.luckperms.common.util.Iterators;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.util.Predicates;
|
||||||
import me.lucko.luckperms.common.utils.ProgressLogger;
|
import me.lucko.luckperms.common.util.ProgressLogger;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@@ -59,7 +60,7 @@ public class MigrationPermissionsBukkit extends SubCommand<Object> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
||||||
ProgressLogger log = new ProgressLogger("PermissionsBukkit");
|
ProgressLogger log = new ProgressLogger(Message.MIGRATION_LOG, Message.MIGRATION_LOG_PROGRESS, "PermissionsBukkit");
|
||||||
log.addListener(plugin.getConsoleSender());
|
log.addListener(plugin.getConsoleSender());
|
||||||
log.addListener(sender);
|
log.addListener(sender);
|
||||||
|
|
||||||
@@ -114,7 +115,7 @@ public class MigrationPermissionsBukkit extends SubCommand<Object> {
|
|||||||
|
|
||||||
plugin.getUserManager().cleanup(lpUser);
|
plugin.getUserManager().cleanup(lpUser);
|
||||||
plugin.getStorage().saveUser(lpUser);
|
plugin.getStorage().saveUser(lpUser);
|
||||||
log.logProgress("Migrated {} users so far.", userCount.incrementAndGet());
|
log.logProgress("Migrated {} users so far.", userCount.incrementAndGet(), ProgressLogger.DEFAULT_NOTIFY_FREQUENCY);
|
||||||
});
|
});
|
||||||
|
|
||||||
log.log("Migrated " + userCount.get() + " users.");
|
log.log("Migrated " + userCount.get() + " users.");
|
||||||
|
|||||||
+6
-7
@@ -34,6 +34,7 @@ import me.lucko.luckperms.common.command.access.CommandPermission;
|
|||||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.Track;
|
import me.lucko.luckperms.common.model.Track;
|
||||||
@@ -42,9 +43,9 @@ import me.lucko.luckperms.common.node.factory.NodeFactory;
|
|||||||
import me.lucko.luckperms.common.node.model.NodeTypes;
|
import me.lucko.luckperms.common.node.model.NodeTypes;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Iterators;
|
import me.lucko.luckperms.common.util.Iterators;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.util.Predicates;
|
||||||
import me.lucko.luckperms.common.utils.ProgressLogger;
|
import me.lucko.luckperms.common.util.ProgressLogger;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
@@ -90,10 +91,9 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
super(CommandSpec.MIGRATION_COMMAND.localize(locale), "permissionsex", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
super(CommandSpec.MIGRATION_COMMAND.localize(locale), "permissionsex", CommandPermission.MIGRATION, Predicates.alwaysFalse());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
||||||
ProgressLogger log = new ProgressLogger("PermissionsEx");
|
ProgressLogger log = new ProgressLogger(Message.MIGRATION_LOG, Message.MIGRATION_LOG_PROGRESS, "PermissionsEx");
|
||||||
log.addListener(plugin.getConsoleSender());
|
log.addListener(plugin.getConsoleSender());
|
||||||
log.addListener(sender);
|
log.addListener(sender);
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
|
|
||||||
plugin.getUserManager().cleanup(lpUser);
|
plugin.getUserManager().cleanup(lpUser);
|
||||||
plugin.getStorage().saveUser(lpUser);
|
plugin.getStorage().saveUser(lpUser);
|
||||||
log.logProgress("Migrated {} users so far.", userCount.incrementAndGet());
|
log.logProgress("Migrated {} users so far.", userCount.incrementAndGet(), ProgressLogger.DEFAULT_NOTIFY_FREQUENCY);
|
||||||
});
|
});
|
||||||
|
|
||||||
log.log("Migrated " + userCount.get() + " users.");
|
log.log("Migrated " + userCount.get() + " users.");
|
||||||
@@ -186,7 +186,6 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
|
|
||||||
private static Map<String, List<String>> getPermanentPermissions(PermissionEntity entity) {
|
private static Map<String, List<String>> getPermanentPermissions(PermissionEntity entity) {
|
||||||
try {
|
try {
|
||||||
//noinspection unchecked
|
|
||||||
PermissionsData data = (PermissionsData) GET_DATA_METHOD.invoke(entity);
|
PermissionsData data = (PermissionsData) GET_DATA_METHOD.invoke(entity);
|
||||||
return data.getPermissionsMap();
|
return data.getPermissionsMap();
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
|||||||
+10
-12
@@ -37,19 +37,21 @@ import me.lucko.luckperms.api.Node;
|
|||||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||||
|
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.storage.StorageType;
|
import me.lucko.luckperms.common.storage.StorageType;
|
||||||
import me.lucko.luckperms.common.utils.Iterators;
|
import me.lucko.luckperms.common.util.Iterators;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.util.Predicates;
|
||||||
import me.lucko.luckperms.common.utils.ProgressLogger;
|
import me.lucko.luckperms.common.util.ProgressLogger;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
@@ -68,17 +70,15 @@ import java.util.concurrent.ExecutionException;
|
|||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import static me.lucko.luckperms.common.command.access.CommandPermission.MIGRATION;
|
|
||||||
|
|
||||||
// Only supports the latest versions of the PP API. (it seems to change randomly almost every release)
|
// Only supports the latest versions of the PP API. (it seems to change randomly almost every release)
|
||||||
public class MigrationPowerfulPerms extends SubCommand<Object> {
|
public class MigrationPowerfulPerms extends SubCommand<Object> {
|
||||||
public MigrationPowerfulPerms(LocaleManager locale) {
|
public MigrationPowerfulPerms(LocaleManager locale) {
|
||||||
super(CommandSpec.MIGRATION_POWERFULPERMS.localize(locale), "powerfulperms", MIGRATION, Predicates.not(5));
|
super(CommandSpec.MIGRATION_POWERFULPERMS.localize(locale), "powerfulperms", CommandPermission.MIGRATION, Predicates.not(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
||||||
ProgressLogger log = new ProgressLogger("PowerfulPerms");
|
ProgressLogger log = new ProgressLogger(Message.MIGRATION_LOG, Message.MIGRATION_LOG_PROGRESS, "PowerfulPerms");
|
||||||
log.addListener(plugin.getConsoleSender());
|
log.addListener(plugin.getConsoleSender());
|
||||||
log.addListener(sender);
|
log.addListener(sender);
|
||||||
|
|
||||||
@@ -89,10 +89,8 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
|||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
String method = plugin.getConfiguration().get(ConfigKeys.STORAGE_METHOD);
|
StorageType type = plugin.getConfiguration().get(ConfigKeys.STORAGE_METHOD);
|
||||||
StorageType type = StorageType.parse(method);
|
if (type != StorageType.MYSQL) {
|
||||||
|
|
||||||
if (type == null || type != StorageType.MYSQL) {
|
|
||||||
// We need to load the Hikari/MySQL stuff.
|
// We need to load the Hikari/MySQL stuff.
|
||||||
plugin.getDependencyManager().loadStorageDependencies(ImmutableSet.of(StorageType.MYSQL));
|
plugin.getDependencyManager().loadStorageDependencies(ImmutableSet.of(StorageType.MYSQL));
|
||||||
}
|
}
|
||||||
@@ -265,7 +263,7 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
|||||||
|
|
||||||
plugin.getUserManager().cleanup(user);
|
plugin.getUserManager().cleanup(user);
|
||||||
plugin.getStorage().saveUser(user);
|
plugin.getStorage().saveUser(user);
|
||||||
log.logProgress("Migrated {} users so far.", userCount.incrementAndGet());
|
log.logProgress("Migrated {} users so far.", userCount.incrementAndGet(), ProgressLogger.DEFAULT_NOTIFY_FREQUENCY);
|
||||||
});
|
});
|
||||||
|
|
||||||
log.log("Migrated " + userCount.get() + " users.");
|
log.log("Migrated " + userCount.get() + " users.");
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import me.lucko.luckperms.common.command.access.CommandPermission;
|
|||||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.Track;
|
import me.lucko.luckperms.common.model.Track;
|
||||||
@@ -42,9 +43,9 @@ import me.lucko.luckperms.common.node.factory.NodeFactory;
|
|||||||
import me.lucko.luckperms.common.node.model.NodeTypes;
|
import me.lucko.luckperms.common.node.model.NodeTypes;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Iterators;
|
import me.lucko.luckperms.common.util.Iterators;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.util.Predicates;
|
||||||
import me.lucko.luckperms.common.utils.ProgressLogger;
|
import me.lucko.luckperms.common.util.ProgressLogger;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsService;
|
import org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsService;
|
||||||
@@ -70,7 +71,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
||||||
ProgressLogger log = new ProgressLogger("zPermissions");
|
ProgressLogger log = new ProgressLogger(Message.MIGRATION_LOG, Message.MIGRATION_LOG_PROGRESS, "zPermissions");
|
||||||
log.addListener(plugin.getConsoleSender());
|
log.addListener(plugin.getConsoleSender());
|
||||||
log.addListener(sender);
|
log.addListener(sender);
|
||||||
|
|
||||||
@@ -182,7 +183,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
|||||||
|
|
||||||
plugin.getUserManager().cleanup(user);
|
plugin.getUserManager().cleanup(user);
|
||||||
plugin.getStorage().saveUser(user);
|
plugin.getStorage().saveUser(user);
|
||||||
log.logProgress("Migrated {} users so far.", userCount.incrementAndGet());
|
log.logProgress("Migrated {} users so far.", userCount.incrementAndGet(), ProgressLogger.DEFAULT_NOTIFY_FREQUENCY);
|
||||||
});
|
});
|
||||||
|
|
||||||
log.log("Migrated " + userCount.get() + " users.");
|
log.log("Migrated " + userCount.get() + " users.");
|
||||||
|
|||||||
+44
-35
@@ -32,15 +32,15 @@ import me.lucko.luckperms.api.Contexts;
|
|||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
import me.lucko.luckperms.common.caching.type.MetaAccumulator;
|
import me.lucko.luckperms.common.cacheddata.type.MetaAccumulator;
|
||||||
import me.lucko.luckperms.common.caching.type.MetaCache;
|
import me.lucko.luckperms.common.cacheddata.type.MetaCache;
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
import me.lucko.luckperms.common.command.CommandManager;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.User;
|
|
||||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.node.model.NodeTypes;
|
import me.lucko.luckperms.common.node.model.NodeTypes;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.MetaCheckEvent;
|
||||||
|
|
||||||
import net.milkbowl.vault.chat.Chat;
|
import net.milkbowl.vault.chat.Chat;
|
||||||
|
|
||||||
@@ -60,19 +60,19 @@ import java.util.UUID;
|
|||||||
* which they simply cannot be, as LP utilises databases for data storage. Server admins
|
* which they simply cannot be, as LP utilises databases for data storage. Server admins
|
||||||
* willing to take the risk of lagging their server can disable these exceptions in the config file.
|
* willing to take the risk of lagging their server can disable these exceptions in the config file.
|
||||||
*/
|
*/
|
||||||
public class VaultChatHook extends AbstractVaultChat {
|
public class LuckPermsVaultChat extends AbstractVaultChat {
|
||||||
|
|
||||||
// the plugin instance
|
// the plugin instance
|
||||||
private final LPBukkitPlugin plugin;
|
private final LPBukkitPlugin plugin;
|
||||||
|
|
||||||
// the vault permission implementation
|
// the vault permission implementation
|
||||||
private final VaultPermissionHook permissionHook;
|
private final LuckPermsVaultPermission vaultPermission;
|
||||||
|
|
||||||
VaultChatHook(LPBukkitPlugin plugin, VaultPermissionHook permissionHook) {
|
LuckPermsVaultChat(LPBukkitPlugin plugin, LuckPermsVaultPermission vaultPermission) {
|
||||||
super(permissionHook);
|
super(vaultPermission);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.permissionHook = permissionHook;
|
this.vaultPermission = vaultPermission;
|
||||||
this.worldMappingFunction = world -> permissionHook.isIgnoreWorld() ? null : world;
|
this.worldMappingFunction = world -> vaultPermission.isIgnoreWorld() ? null : world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -84,10 +84,10 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
public String getUserChatPrefix(String world, UUID uuid) {
|
public String getUserChatPrefix(String world, UUID uuid) {
|
||||||
Objects.requireNonNull(uuid, "uuid");
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
|
|
||||||
User user = this.permissionHook.lookupUser(uuid);
|
PermissionHolder user = this.vaultPermission.lookupUser(uuid);
|
||||||
Contexts contexts = this.permissionHook.contextForLookup(user, world);
|
Contexts contexts = this.vaultPermission.contextForLookup(uuid, world);
|
||||||
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
||||||
String ret = metaData.getPrefix();
|
String ret = metaData.getPrefix(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#getUserChatPrefix: %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), ret);
|
logMsg("#getUserChatPrefix: %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), ret);
|
||||||
}
|
}
|
||||||
@@ -98,10 +98,10 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
public String getUserChatSuffix(String world, UUID uuid) {
|
public String getUserChatSuffix(String world, UUID uuid) {
|
||||||
Objects.requireNonNull(uuid, "uuid");
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
|
|
||||||
User user = this.permissionHook.lookupUser(uuid);
|
PermissionHolder user = this.vaultPermission.lookupUser(uuid);
|
||||||
Contexts contexts = this.permissionHook.contextForLookup(user, world);
|
Contexts contexts = this.vaultPermission.contextForLookup(uuid, world);
|
||||||
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
||||||
String ret = metaData.getSuffix();
|
String ret = metaData.getSuffix(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#getUserChatSuffix: %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), ret);
|
logMsg("#getUserChatSuffix: %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), ret);
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,10 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
public void setUserChatPrefix(String world, UUID uuid, String prefix) {
|
public void setUserChatPrefix(String world, UUID uuid, String prefix) {
|
||||||
Objects.requireNonNull(uuid, "uuid");
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
|
|
||||||
User user = this.permissionHook.lookupUser(uuid);
|
PermissionHolder user = this.vaultPermission.lookupUser(uuid);
|
||||||
|
if (user instanceof Group) {
|
||||||
|
throw new UnsupportedOperationException("Unable to modify the permissions of NPC players");
|
||||||
|
}
|
||||||
setChatMeta(user, ChatMetaType.PREFIX, prefix, world);
|
setChatMeta(user, ChatMetaType.PREFIX, prefix, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +123,10 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
public void setUserChatSuffix(String world, UUID uuid, String suffix) {
|
public void setUserChatSuffix(String world, UUID uuid, String suffix) {
|
||||||
Objects.requireNonNull(uuid, "uuid");
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
|
|
||||||
User user = this.permissionHook.lookupUser(uuid);
|
PermissionHolder user = this.vaultPermission.lookupUser(uuid);
|
||||||
|
if (user instanceof Group) {
|
||||||
|
throw new UnsupportedOperationException("Unable to modify the permissions of NPC players");
|
||||||
|
}
|
||||||
setChatMeta(user, ChatMetaType.SUFFIX, suffix, world);
|
setChatMeta(user, ChatMetaType.SUFFIX, suffix, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,10 +135,10 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
Objects.requireNonNull(uuid, "uuid");
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
Objects.requireNonNull(key, "key");
|
Objects.requireNonNull(key, "key");
|
||||||
|
|
||||||
User user = this.permissionHook.lookupUser(uuid);
|
PermissionHolder user = this.vaultPermission.lookupUser(uuid);
|
||||||
Contexts contexts = this.permissionHook.contextForLookup(user, world);
|
Contexts contexts = this.vaultPermission.contextForLookup(uuid, world);
|
||||||
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
||||||
String ret = metaData.getMeta().get(key);
|
String ret = metaData.getMeta(MetaCheckEvent.Origin.THIRD_PARTY_API).get(key);
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#getUserMeta: %s - %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), key, ret);
|
logMsg("#getUserMeta: %s - %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), key, ret);
|
||||||
}
|
}
|
||||||
@@ -144,7 +150,10 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
Objects.requireNonNull(uuid, "uuid");
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
Objects.requireNonNull(key, "key");
|
Objects.requireNonNull(key, "key");
|
||||||
|
|
||||||
User user = this.permissionHook.lookupUser(uuid);
|
PermissionHolder user = this.vaultPermission.lookupUser(uuid);
|
||||||
|
if (user instanceof Group) {
|
||||||
|
throw new UnsupportedOperationException("Unable to modify the permissions of NPC players");
|
||||||
|
}
|
||||||
setMeta(user, key, value, world);
|
setMeta(user, key, value, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,9 +164,9 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
if (group == null) {
|
if (group == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Contexts contexts = this.permissionHook.contextForLookup(null, world);
|
Contexts contexts = this.vaultPermission.contextForLookup(null, world);
|
||||||
MetaCache metaData = group.getCachedData().getMetaData(contexts);
|
MetaCache metaData = group.getCachedData().getMetaData(contexts);
|
||||||
String ret = metaData.getPrefix();
|
String ret = metaData.getPrefix(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#getGroupPrefix: %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), ret);
|
logMsg("#getGroupPrefix: %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), ret);
|
||||||
}
|
}
|
||||||
@@ -171,9 +180,9 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
if (group == null) {
|
if (group == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Contexts contexts = this.permissionHook.contextForLookup(null, world);
|
Contexts contexts = this.vaultPermission.contextForLookup(null, world);
|
||||||
MetaCache metaData = group.getCachedData().getMetaData(contexts);
|
MetaCache metaData = group.getCachedData().getMetaData(contexts);
|
||||||
String ret = metaData.getSuffix();
|
String ret = metaData.getSuffix(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#getGroupSuffix: %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), ret);
|
logMsg("#getGroupSuffix: %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), ret);
|
||||||
}
|
}
|
||||||
@@ -208,9 +217,9 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
if (group == null) {
|
if (group == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Contexts contexts = this.permissionHook.contextForLookup(null, world);
|
Contexts contexts = this.vaultPermission.contextForLookup(null, world);
|
||||||
MetaCache metaData = group.getCachedData().getMetaData(contexts);
|
MetaCache metaData = group.getCachedData().getMetaData(contexts);
|
||||||
String ret = metaData.getMeta().get(key);
|
String ret = metaData.getMeta(MetaCheckEvent.Origin.THIRD_PARTY_API).get(key);
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#getGroupMeta: %s - %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), key, ret);
|
logMsg("#getGroupMeta: %s - %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), key, ret);
|
||||||
}
|
}
|
||||||
@@ -254,7 +263,7 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
holder.removeIf(type::matches);
|
holder.removeIf(type::matches);
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
this.permissionHook.holderSave(holder);
|
this.vaultPermission.holderSave(holder);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,11 +273,11 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
int priority = metaAccumulator.getChatMeta(type).keySet().stream().mapToInt(e -> e).max().orElse(0) + 10;
|
int priority = metaAccumulator.getChatMeta(type).keySet().stream().mapToInt(e -> e).max().orElse(0) + 10;
|
||||||
|
|
||||||
Node.Builder chatMetaNode = NodeFactory.buildChatMetaNode(type, priority, value);
|
Node.Builder chatMetaNode = NodeFactory.buildChatMetaNode(type, priority, value);
|
||||||
chatMetaNode.setServer(this.permissionHook.getVaultServer());
|
chatMetaNode.setServer(this.vaultPermission.getVaultServer());
|
||||||
chatMetaNode.setWorld(world);
|
chatMetaNode.setWorld(world);
|
||||||
|
|
||||||
holder.setPermission(chatMetaNode.build()); // assume success
|
holder.setPermission(chatMetaNode.build()); // assume success
|
||||||
this.permissionHook.holderSave(holder);
|
this.vaultPermission.holderSave(holder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMeta(PermissionHolder holder, String key, Object value, String world) {
|
private void setMeta(PermissionHolder holder, String key, Object value, String world) {
|
||||||
@@ -279,7 +288,7 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
holder.removeIf(n -> n.isMeta() && n.getMeta().getKey().equals(key));
|
holder.removeIf(n -> n.isMeta() && n.getMeta().getKey().equals(key));
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
this.permissionHook.holderSave(holder);
|
this.vaultPermission.holderSave(holder);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,11 +299,11 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
metaNode = NodeFactory.buildMetaNode(key, value.toString());
|
metaNode = NodeFactory.buildMetaNode(key, value.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
metaNode.setServer(this.permissionHook.getVaultServer());
|
metaNode.setServer(this.vaultPermission.getVaultServer());
|
||||||
metaNode.setWorld(world);
|
metaNode.setWorld(world);
|
||||||
|
|
||||||
holder.setPermission(metaNode.build()); // assume success
|
holder.setPermission(metaNode.build()); // assume success
|
||||||
this.permissionHook.holderSave(holder);
|
this.vaultPermission.holderSave(holder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Contexts createContextForWorldSet(String world) {
|
private Contexts createContextForWorldSet(String world) {
|
||||||
@@ -302,7 +311,7 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
if (world != null && !world.equals("") && !world.equalsIgnoreCase("global")) {
|
if (world != null && !world.equals("") && !world.equalsIgnoreCase("global")) {
|
||||||
context.add(Contexts.WORLD_KEY, world.toLowerCase());
|
context.add(Contexts.WORLD_KEY, world.toLowerCase());
|
||||||
}
|
}
|
||||||
context.add(Contexts.SERVER_KEY, this.permissionHook.getVaultServer());
|
context.add(Contexts.SERVER_KEY, this.vaultPermission.getVaultServer());
|
||||||
return Contexts.of(context.build(), this.permissionHook.isIncludeGlobal(), true, true, true, true, false);
|
return Contexts.of(context.build(), this.vaultPermission.isIncludeGlobal(), true, true, true, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+81
-26
@@ -28,24 +28,31 @@ package me.lucko.luckperms.bukkit.vault;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
|
import me.lucko.luckperms.api.LookupSetting;
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
import me.lucko.luckperms.common.caching.type.PermissionCache;
|
import me.lucko.luckperms.common.cacheddata.type.PermissionCache;
|
||||||
|
import me.lucko.luckperms.common.calculator.processor.MapProcessor;
|
||||||
|
import me.lucko.luckperms.common.calculator.result.TristateResult;
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
import me.lucko.luckperms.common.command.CommandManager;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
import me.lucko.luckperms.common.util.Uuids;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.MetaCheckEvent;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
|
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -65,12 +72,12 @@ import java.util.UUID;
|
|||||||
* which they simply cannot be, as LP utilises databases for data storage. Server admins
|
* which they simply cannot be, as LP utilises databases for data storage. Server admins
|
||||||
* willing to take the risk of lagging their server can disable these exceptions in the config file.
|
* willing to take the risk of lagging their server can disable these exceptions in the config file.
|
||||||
*/
|
*/
|
||||||
public class VaultPermissionHook extends AbstractVaultPermission {
|
public class LuckPermsVaultPermission extends AbstractVaultPermission {
|
||||||
|
|
||||||
// the plugin instance
|
// the plugin instance
|
||||||
private final LPBukkitPlugin plugin;
|
private final LPBukkitPlugin plugin;
|
||||||
|
|
||||||
public VaultPermissionHook(LPBukkitPlugin plugin) {
|
public LuckPermsVaultPermission(LPBukkitPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.worldMappingFunction = world -> isIgnoreWorld() ? null : world;
|
this.worldMappingFunction = world -> isIgnoreWorld() ? null : world;
|
||||||
}
|
}
|
||||||
@@ -94,8 +101,14 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
return onlinePlayer.getUniqueId();
|
return onlinePlayer.getUniqueId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// account for plugins that for some reason think it's valid to pass the uuid as a string.
|
||||||
|
UUID uuid = Uuids.parse(player);
|
||||||
|
if (uuid != null) {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
// are we on the main thread?
|
// are we on the main thread?
|
||||||
if (!plugin.getBootstrap().isServerStarting() && Bukkit.isPrimaryThread() && !this.plugin.getConfiguration().get(ConfigKeys.VAULT_UNSAFE_LOOKUPS)) {
|
if (!this.plugin.getBootstrap().isServerStarting() && Bukkit.isPrimaryThread() && !this.plugin.getConfiguration().get(ConfigKeys.VAULT_UNSAFE_LOOKUPS)) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"The operation to lookup a UUID for '" + player + "' was cancelled by LuckPerms. This is NOT a bug. \n" +
|
"The operation to lookup a UUID for '" + player + "' was cancelled by LuckPerms. This is NOT a bug. \n" +
|
||||||
"The lookup request was made on the main server thread. It is not safe to execute a request to \n" +
|
"The lookup request was made on the main server thread. It is not safe to execute a request to \n" +
|
||||||
@@ -108,7 +121,7 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// lookup a username from the database
|
// lookup a username from the database
|
||||||
UUID uuid = this.plugin.getStorage().getPlayerUuid(player.toLowerCase()).join();
|
uuid = this.plugin.getStorage().getPlayerUuid(player.toLowerCase()).join();
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
uuid = this.plugin.getBootstrap().lookupUuid(player).orElse(null);
|
uuid = this.plugin.getBootstrap().lookupUuid(player).orElse(null);
|
||||||
}
|
}
|
||||||
@@ -121,7 +134,7 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User lookupUser(UUID uuid) {
|
public PermissionHolder lookupUser(UUID uuid) {
|
||||||
Objects.requireNonNull(uuid, "uuid");
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
|
|
||||||
// loaded already?
|
// loaded already?
|
||||||
@@ -130,12 +143,27 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the uuid is version 2, assume it is an NPC
|
||||||
|
// see: https://github.com/lucko/LuckPerms/issues/1470
|
||||||
|
// and https://github.com/lucko/LuckPerms/issues/1470#issuecomment-475403162
|
||||||
|
if (uuid.version() == 2) {
|
||||||
|
String npcGroupName = this.plugin.getConfiguration().get(ConfigKeys.VAULT_NPC_GROUP);
|
||||||
|
Group npcGroup = this.plugin.getGroupManager().getIfLoaded(npcGroupName);
|
||||||
|
if (npcGroup == null) {
|
||||||
|
npcGroup = this.plugin.getGroupManager().getIfLoaded(NodeFactory.DEFAULT_GROUP_NAME);
|
||||||
|
if (npcGroup == null) {
|
||||||
|
throw new IllegalStateException("unable to get default group");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return npcGroup;
|
||||||
|
}
|
||||||
|
|
||||||
// are we on the main thread?
|
// are we on the main thread?
|
||||||
if (!plugin.getBootstrap().isServerStarting() && Bukkit.isPrimaryThread() && !this.plugin.getConfiguration().get(ConfigKeys.VAULT_UNSAFE_LOOKUPS)) {
|
if (!this.plugin.getBootstrap().isServerStarting() && Bukkit.isPrimaryThread() && !this.plugin.getConfiguration().get(ConfigKeys.VAULT_UNSAFE_LOOKUPS)) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"The operation to load user data for '" + uuid + "' was cancelled by LuckPerms. This is NOT a bug. \n" +
|
"The operation to load user data for '" + uuid + "' was cancelled by LuckPerms. This is NOT a bug. \n" +
|
||||||
"The lookup request was made on the main server thread. It is not safe to execute a request to \n" +
|
"The lookup request was made on the main server thread. It is not safe to execute a request to \n" +
|
||||||
"load username data from the database in this context. \n" +
|
"load data for offline players from the database in this context. \n" +
|
||||||
"If you are a plugin author, please consider making your request asynchronously. \n" +
|
"If you are a plugin author, please consider making your request asynchronously. \n" +
|
||||||
"Alternatively, server admins can disable this catch by setting 'vault-unsafe-lookups' to true \n" +
|
"Alternatively, server admins can disable this catch by setting 'vault-unsafe-lookups' to true \n" +
|
||||||
"in the LP config, but should consider the consequences (lag) before doing so."
|
"in the LP config, but should consider the consequences (lag) before doing so."
|
||||||
@@ -158,15 +186,15 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
Objects.requireNonNull(uuid, "uuid");
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
|
|
||||||
User user = lookupUser(uuid);
|
PermissionHolder user = lookupUser(uuid);
|
||||||
Contexts contexts = contextForLookup(user, world);
|
Contexts contexts = contextForLookup(uuid, world);
|
||||||
PermissionCache permissionData = user.getCachedData().getPermissionData(contexts);
|
PermissionCache permissionData = user.getCachedData().getPermissionData(contexts);
|
||||||
|
|
||||||
Tristate result = permissionData.getPermissionValue(permission, CheckOrigin.INTERNAL);
|
Tristate result = permissionData.getPermissionValue(permission, PermissionCheckEvent.Origin.THIRD_PARTY_API).result();
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#userHasPermission: %s - %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), permission, result);
|
logMsg("#userHasPermission: %s - %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), permission, result);
|
||||||
}
|
}
|
||||||
return result.asBoolean();
|
return result != Tristate.UNDEFINED ? result.asBoolean() : org.bukkit.permissions.Permission.DEFAULT_PERMISSION.getValue(contexts.hasSetting(LookupSetting.IS_OP));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -174,7 +202,10 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
Objects.requireNonNull(uuid, "uuid");
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
|
|
||||||
User user = lookupUser(uuid);
|
PermissionHolder user = lookupUser(uuid);
|
||||||
|
if (user instanceof Group) {
|
||||||
|
throw new UnsupportedOperationException("Unable to modify the permissions of NPC players");
|
||||||
|
}
|
||||||
return holderAddPermission(user, permission, world);
|
return holderAddPermission(user, permission, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +214,10 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
Objects.requireNonNull(uuid, "uuid");
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
|
|
||||||
User user = lookupUser(uuid);
|
PermissionHolder user = lookupUser(uuid);
|
||||||
|
if (user instanceof Group) {
|
||||||
|
throw new UnsupportedOperationException("Unable to modify the permissions of NPC players");
|
||||||
|
}
|
||||||
return holderRemovePermission(user, permission, world);
|
return holderRemovePermission(user, permission, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +225,16 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
public boolean userInGroup(String world, UUID uuid, String group) {
|
public boolean userInGroup(String world, UUID uuid, String group) {
|
||||||
Objects.requireNonNull(uuid, "uuid");
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return userHasPermission(world, uuid, NodeFactory.groupNode(rewriteGroupName(group)));
|
|
||||||
|
PermissionHolder user = lookupUser(uuid);
|
||||||
|
Contexts contexts = contextForLookup(uuid, world);
|
||||||
|
PermissionCache permissionData = user.getCachedData().getPermissionData(contexts);
|
||||||
|
|
||||||
|
TristateResult result = permissionData.getPermissionValue(NodeFactory.groupNode(rewriteGroupName(group)), PermissionCheckEvent.Origin.THIRD_PARTY_API);
|
||||||
|
if (log()) {
|
||||||
|
logMsg("#userInGroup: %s - %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), group, result);
|
||||||
|
}
|
||||||
|
return result.processorClass() == MapProcessor.class && result.result().asBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -212,8 +255,8 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
public String[] userGetGroups(String world, UUID uuid) {
|
public String[] userGetGroups(String world, UUID uuid) {
|
||||||
Objects.requireNonNull(uuid, "uuid");
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
|
|
||||||
User user = lookupUser(uuid);
|
PermissionHolder user = lookupUser(uuid);
|
||||||
ContextSet contexts = contextForLookup(user, world).getContexts();
|
ContextSet contexts = contextForLookup(uuid, world).getContexts();
|
||||||
|
|
||||||
String[] ret = user.enduringData().immutable().values().stream()
|
String[] ret = user.enduringData().immutable().values().stream()
|
||||||
.filter(Node::isGroupNode)
|
.filter(Node::isGroupNode)
|
||||||
@@ -238,13 +281,18 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
public String userGetPrimaryGroup(String world, UUID uuid) {
|
public String userGetPrimaryGroup(String world, UUID uuid) {
|
||||||
Objects.requireNonNull(uuid, "uuid");
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
|
|
||||||
User user = lookupUser(uuid);
|
PermissionHolder user = lookupUser(uuid);
|
||||||
String value = user.getPrimaryGroup().getValue();
|
if (user instanceof Group) { // npc
|
||||||
|
return this.plugin.getConfiguration().get(ConfigKeys.VAULT_NPC_GROUP);
|
||||||
|
}
|
||||||
|
String value = ((User) user).getPrimaryGroup().getValue();
|
||||||
Group group = getGroup(value);
|
Group group = getGroup(value);
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
value = group.getPlainDisplayName();
|
value = group.getPlainDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.plugin.getVerboseHandler().offerMetaCheckEvent(MetaCheckEvent.Origin.THIRD_PARTY_API, user.getPlainDisplayName(), ContextSet.empty(), "primarygroup", value);
|
||||||
|
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#userGetPrimaryGroup: %s - %s - %s", user.getPlainDisplayName(), world, value);
|
logMsg("#userGetPrimaryGroup: %s - %s - %s", user.getPlainDisplayName(), world, value);
|
||||||
}
|
}
|
||||||
@@ -265,7 +313,7 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
Contexts contexts = contextForLookup(null, world);
|
Contexts contexts = contextForLookup(null, world);
|
||||||
PermissionCache permissionData = group.getCachedData().getPermissionData(contexts);
|
PermissionCache permissionData = group.getCachedData().getPermissionData(contexts);
|
||||||
|
|
||||||
Tristate result = permissionData.getPermissionValue(permission, CheckOrigin.INTERNAL);
|
Tristate result = permissionData.getPermissionValue(permission, PermissionCheckEvent.Origin.THIRD_PARTY_API).result();
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#groupHasPermission: %s - %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), permission, result);
|
logMsg("#groupHasPermission: %s - %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), permission, result);
|
||||||
}
|
}
|
||||||
@@ -328,10 +376,10 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// utility method for getting a contexts instance for a given vault lookup.
|
// utility method for getting a contexts instance for a given vault lookup.
|
||||||
Contexts contextForLookup(User user, String world) {
|
Contexts contextForLookup(@Nullable UUID uuid, @Nullable String world) {
|
||||||
MutableContextSet context;
|
MutableContextSet context;
|
||||||
|
|
||||||
Player player = Optional.ofNullable(user).flatMap(u -> this.plugin.getBootstrap().getPlayer(u.getUuid())).orElse(null);
|
Player player = Optional.ofNullable(uuid).flatMap(u -> this.plugin.getBootstrap().getPlayer(u)).orElse(null);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
context = this.plugin.getContextManager().getApplicableContext(player).mutableCopy();
|
context = this.plugin.getContextManager().getApplicableContext(player).mutableCopy();
|
||||||
} else {
|
} else {
|
||||||
@@ -360,7 +408,14 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Contexts.of(context, isIncludeGlobal(), true, true, true, true, false);
|
boolean op = false;
|
||||||
|
if (player != null) {
|
||||||
|
op = player.isOp();
|
||||||
|
} else if (uuid != null && uuid.version() == 2) { // npc
|
||||||
|
op = this.plugin.getConfiguration().get(ConfigKeys.VAULT_NPC_OP_STATUS);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Contexts.of(context, isIncludeGlobal(), true, true, true, true, op);
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility methods for modifying the state of PermissionHolders
|
// utility methods for modifying the state of PermissionHolders
|
||||||
@@ -394,13 +449,13 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean holderSave(PermissionHolder holder) {
|
boolean holderSave(PermissionHolder holder) {
|
||||||
if (holder.getType().isUser()) {
|
if (holder.getType() == HolderType.USER) {
|
||||||
User u = (User) holder;
|
User u = (User) holder;
|
||||||
|
|
||||||
// we don't need to join this call - the save operation
|
// we don't need to join this call - the save operation
|
||||||
// can happen in the background.
|
// can happen in the background.
|
||||||
this.plugin.getStorage().saveUser(u);
|
this.plugin.getStorage().saveUser(u);
|
||||||
} else if (holder.getType().isGroup()) {
|
} else if (holder.getType() == HolderType.GROUP) {
|
||||||
Group g = (Group) holder;
|
Group g = (Group) holder;
|
||||||
|
|
||||||
// invalidate caches - they have potentially been affected by
|
// invalidate caches - they have potentially been affected by
|
||||||
@@ -37,28 +37,32 @@ import org.bukkit.plugin.ServicesManager;
|
|||||||
* Handles hooking with the Vault API
|
* Handles hooking with the Vault API
|
||||||
*/
|
*/
|
||||||
public class VaultHookManager {
|
public class VaultHookManager {
|
||||||
private VaultChatHook chatHook = null;
|
private final LPBukkitPlugin plugin;
|
||||||
private VaultPermissionHook permissionHook = null;
|
|
||||||
|
private LuckPermsVaultChat chat = null;
|
||||||
|
private LuckPermsVaultPermission permission = null;
|
||||||
|
|
||||||
|
public VaultHookManager(LPBukkitPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the LuckPerms implementation of {@link Permission} and {@link Chat} with
|
* Registers the LuckPerms implementation of {@link Permission} and {@link Chat} with
|
||||||
* the service manager.
|
* the service manager.
|
||||||
*
|
|
||||||
* @param plugin the plugin
|
|
||||||
*/
|
*/
|
||||||
public void hook(LPBukkitPlugin plugin) {
|
public void hook() {
|
||||||
try {
|
try {
|
||||||
if (this.permissionHook == null) {
|
if (this.permission == null) {
|
||||||
this.permissionHook = new VaultPermissionHook(plugin);
|
this.permission = new LuckPermsVaultPermission(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.chatHook == null) {
|
if (this.chat == null) {
|
||||||
this.chatHook = new VaultChatHook(plugin, this.permissionHook);
|
this.chat = new LuckPermsVaultChat(plugin, this.permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ServicesManager sm = plugin.getBootstrap().getServer().getServicesManager();
|
final ServicesManager sm = plugin.getBootstrap().getServer().getServicesManager();
|
||||||
sm.register(Permission.class, this.permissionHook, plugin.getBootstrap(), ServicePriority.High);
|
sm.register(Permission.class, this.permission, plugin.getBootstrap(), ServicePriority.High);
|
||||||
sm.register(Chat.class, this.chatHook, plugin.getBootstrap(), ServicePriority.High);
|
sm.register(Chat.class, this.chat, plugin.getBootstrap(), ServicePriority.High);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -67,20 +71,18 @@ public class VaultHookManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregisters the LuckPerms Vault hooks, if present.
|
* Unregisters the LuckPerms Vault hooks, if present.
|
||||||
*
|
|
||||||
* @param plugin the plugin
|
|
||||||
*/
|
*/
|
||||||
public void unhook(LPBukkitPlugin plugin) {
|
public void unhook() {
|
||||||
final ServicesManager sm = plugin.getBootstrap().getServer().getServicesManager();
|
final ServicesManager sm = plugin.getBootstrap().getServer().getServicesManager();
|
||||||
|
|
||||||
if (this.permissionHook != null) {
|
if (this.permission != null) {
|
||||||
sm.unregister(Permission.class, this.permissionHook);
|
sm.unregister(Permission.class, this.permission);
|
||||||
this.permissionHook = null;
|
this.permission = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.chatHook != null) {
|
if (this.chat != null) {
|
||||||
sm.unregister(Chat.class, this.chatHook);
|
sm.unregister(Chat.class, this.chat);
|
||||||
this.chatHook = null;
|
this.chat = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
# | | | | / ` |__/ |__) |__ |__) |\/| /__` | #
|
# | | | | / ` |__/ |__) |__ |__) |\/| /__` | #
|
||||||
# | |___ \__/ \__, | \ | |___ | \ | | .__/ | #
|
# | |___ \__/ \__, | \ | |___ | \ | | .__/ | #
|
||||||
# | | #
|
# | | #
|
||||||
|
# | https://luckperms.github.io | #
|
||||||
# | | #
|
# | | #
|
||||||
# | SOURCE CODE: https://github.com/lucko/LuckPerms | #
|
# | SOURCE CODE: https://github.com/lucko/LuckPerms | #
|
||||||
# | WIKI: https://github.com/lucko/LuckPerms/wiki | #
|
# | WIKI: https://github.com/lucko/LuckPerms/wiki | #
|
||||||
@@ -300,6 +301,8 @@ log-notify: true
|
|||||||
# - It is explained and documented in more detail on the wiki under "Prefix & Suffix Stacking".
|
# - It is explained and documented in more detail on the wiki under "Prefix & Suffix Stacking".
|
||||||
#
|
#
|
||||||
# - The options are divided into separate sections for prefixes and suffixes.
|
# - The options are divided into separate sections for prefixes and suffixes.
|
||||||
|
# - The 'duplicates' setting refers to how duplicate elements are handled. Can be 'retain-all',
|
||||||
|
# 'first-only' or 'last-only'.
|
||||||
# - The value of 'start-spacer' is included at the start of the resultant prefix/suffix.
|
# - The value of 'start-spacer' is included at the start of the resultant prefix/suffix.
|
||||||
# - The value of 'end-spacer' is included at the end of the resultant prefix/suffix.
|
# - The value of 'end-spacer' is included at the end of the resultant prefix/suffix.
|
||||||
# - The value of 'middle-spacer' is included between each element in the resultant prefix/suffix.
|
# - The value of 'middle-spacer' is included between each element in the resultant prefix/suffix.
|
||||||
@@ -333,12 +336,14 @@ meta-formatting:
|
|||||||
prefix:
|
prefix:
|
||||||
format:
|
format:
|
||||||
- "highest"
|
- "highest"
|
||||||
|
duplicates: first-only
|
||||||
start-spacer: ""
|
start-spacer: ""
|
||||||
middle-spacer: " "
|
middle-spacer: " "
|
||||||
end-spacer: ""
|
end-spacer: ""
|
||||||
suffix:
|
suffix:
|
||||||
format:
|
format:
|
||||||
- "highest"
|
- "highest"
|
||||||
|
duplicates: first-only
|
||||||
start-spacer: ""
|
start-spacer: ""
|
||||||
middle-spacer: " "
|
middle-spacer: " "
|
||||||
end-spacer: ""
|
end-spacer: ""
|
||||||
@@ -362,6 +367,19 @@ meta-formatting:
|
|||||||
# => depth-first-post-order See: https://en.wikipedia.org/wiki/Depth-first_search
|
# => depth-first-post-order See: https://en.wikipedia.org/wiki/Depth-first_search
|
||||||
inheritance-traversal-algorithm: depth-first-pre-order
|
inheritance-traversal-algorithm: depth-first-pre-order
|
||||||
|
|
||||||
|
# If a final sort according to "inheritance rules" should be performed after the traversal algorithm
|
||||||
|
# has resolved the inheritance tree.
|
||||||
|
#
|
||||||
|
# "Inheritance rules" refers to things such as group weightings, primary group status, and the
|
||||||
|
# natural contextual ordering of the group nodes.
|
||||||
|
#
|
||||||
|
# Setting this to 'true' will allow for the inheritance rules to take priority over the structure of
|
||||||
|
# the inheritance tree.
|
||||||
|
#
|
||||||
|
# Effectively when this setting is 'true': the tree is flattened, and rules applied afterwards,
|
||||||
|
# and when this setting is 'false':, the rules are just applied during each step of the traversal.
|
||||||
|
post-traversal-inheritance-sort: false
|
||||||
|
|
||||||
# +----------------------------------------------------------------------------------------------+ #
|
# +----------------------------------------------------------------------------------------------+ #
|
||||||
# | Permission resolution settings | #
|
# | Permission resolution settings | #
|
||||||
# +----------------------------------------------------------------------------------------------+ #
|
# +----------------------------------------------------------------------------------------------+ #
|
||||||
@@ -496,6 +514,19 @@ commands-allow-op: true
|
|||||||
# option to 'true.
|
# option to 'true.
|
||||||
vault-unsafe-lookups: false
|
vault-unsafe-lookups: false
|
||||||
|
|
||||||
|
# Controls which group LuckPerms should use for NPC players when handling Vault requests.
|
||||||
|
#
|
||||||
|
# - As NPCs aren't actually real players, LuckPerms does not load any user data for them. This
|
||||||
|
# becomes an issue when plugins want to check for their permissions using Vault.
|
||||||
|
# - As a solution, Vault checks for NPCs fallback to a group, which is defined below.
|
||||||
|
vault-npc-group: default
|
||||||
|
|
||||||
|
# Controls how LuckPerms should consider the OP status of NPC players when handing Vault requests.
|
||||||
|
#
|
||||||
|
# - If you want NPCs to have the same permissions as "normal" players, set this option to false.
|
||||||
|
# - If you want NPCs to have OP status, set this option to true.
|
||||||
|
vault-npc-op-status: false
|
||||||
|
|
||||||
# If the vault-server option below should be used.
|
# If the vault-server option below should be used.
|
||||||
#
|
#
|
||||||
# - When this option is set to false, the server value defined above under "server" is used.
|
# - When this option is set to false, the server value defined above under "server" is used.
|
||||||
@@ -525,10 +556,6 @@ vault-debug: false
|
|||||||
# - Useful if you're having issues with UUID forwarding or data not being loaded.
|
# - Useful if you're having issues with UUID forwarding or data not being loaded.
|
||||||
debug-logins: false
|
debug-logins: false
|
||||||
|
|
||||||
# If LuckPerms should use the "server-name" property from the "server.properties" file as the
|
|
||||||
# "server" option within LuckPerms.
|
|
||||||
use-server-properties-name: false
|
|
||||||
|
|
||||||
# If LuckPerms should allow usernames with non alphanumeric characters.
|
# If LuckPerms should allow usernames with non alphanumeric characters.
|
||||||
#
|
#
|
||||||
# - Note that due to the design of the storage implementation, usernames must still be 16 characters
|
# - Note that due to the design of the storage implementation, usernames must still be 16 characters
|
||||||
|
|||||||
@@ -2,11 +2,16 @@ name: LuckPerms
|
|||||||
version: ${pluginVersion}
|
version: ${pluginVersion}
|
||||||
description: A permissions plugin
|
description: A permissions plugin
|
||||||
author: Luck
|
author: Luck
|
||||||
website: https://github.com/lucko/LuckPerms
|
website: https://luckperms.github.io
|
||||||
|
|
||||||
main: me.lucko.luckperms.bukkit.LPBukkitBootstrap
|
main: me.lucko.luckperms.bukkit.LPBukkitBootstrap
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
|
|
||||||
|
# Mark the plugin as 1.13 compatible to avoid CB having to perform quite as much unnecessary
|
||||||
|
# remapping when the plugin is loaded. Note that despite what this setting might otherwise imply,
|
||||||
|
# LP is still compatible with pre-1.13 releases.
|
||||||
|
api-version: 1.13
|
||||||
|
|
||||||
# This means that all plugins that (soft-)depend on Vault, depend on LuckPerms too.
|
# This means that all plugins that (soft-)depend on Vault, depend on LuckPerms too.
|
||||||
# It in turn fixes issues where plugins using Vault cache the provided instance
|
# It in turn fixes issues where plugins using Vault cache the provided instance
|
||||||
# when their plugin enables, or when they check for the presence of a service
|
# when their plugin enables, or when they check for the presence of a service
|
||||||
|
|||||||
+2
-1
@@ -5,7 +5,8 @@ plugins {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile project(':common')
|
compile project(':common')
|
||||||
|
|
||||||
compileOnly 'net.md-5:bungeecord-api:1.12-SNAPSHOT'
|
compileOnly 'net.md-5:bungeecord-api:1.14-SNAPSHOT'
|
||||||
|
compileOnly 'net.kyori:text-adapter-bungeecord:3.0.2'
|
||||||
compileOnly 'com.imaginarycode.minecraft:RedisBungee:0.4'
|
compileOnly 'com.imaginarycode.minecraft:RedisBungee:0.4'
|
||||||
|
|
||||||
// migration plugins
|
// migration plugins
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ package me.lucko.luckperms.bungee;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
|
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
|
||||||
import me.lucko.luckperms.common.plugin.scheduler.SchedulerTask;
|
import me.lucko.luckperms.common.plugin.scheduler.SchedulerTask;
|
||||||
import me.lucko.luckperms.common.utils.Iterators;
|
import me.lucko.luckperms.common.util.Iterators;
|
||||||
|
|
||||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||||
|
|
||||||
|
|||||||
@@ -27,16 +27,15 @@ package me.lucko.luckperms.bungee;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.bungee.event.TristateCheckEvent;
|
import me.lucko.luckperms.bungee.event.TristateCheckEvent;
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.sender.SenderFactory;
|
import me.lucko.luckperms.common.sender.SenderFactory;
|
||||||
import me.lucko.luckperms.common.utils.TextUtils;
|
import me.lucko.luckperms.common.util.TextUtils;
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.serializer.ComponentSerializers;
|
import net.kyori.text.adapter.bungeecord.TextAdapter;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -50,7 +49,7 @@ public class BungeeSenderFactory extends SenderFactory<CommandSender> {
|
|||||||
if (sender instanceof ProxiedPlayer) {
|
if (sender instanceof ProxiedPlayer) {
|
||||||
return sender.getName();
|
return sender.getName();
|
||||||
}
|
}
|
||||||
return CommandManager.CONSOLE_NAME;
|
return Sender.CONSOLE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -58,7 +57,7 @@ public class BungeeSenderFactory extends SenderFactory<CommandSender> {
|
|||||||
if (sender instanceof ProxiedPlayer) {
|
if (sender instanceof ProxiedPlayer) {
|
||||||
return ((ProxiedPlayer) sender).getUniqueId();
|
return ((ProxiedPlayer) sender).getUniqueId();
|
||||||
}
|
}
|
||||||
return CommandManager.CONSOLE_UUID;
|
return Sender.CONSOLE_UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -68,7 +67,7 @@ public class BungeeSenderFactory extends SenderFactory<CommandSender> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void sendMessage(CommandSender sender, Component message) {
|
protected void sendMessage(CommandSender sender, Component message) {
|
||||||
sender.sendMessage(ComponentSerializer.parse(ComponentSerializers.JSON.serialize(message)));
|
TextAdapter.sendComponent(sender, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -27,25 +27,25 @@ package me.lucko.luckperms.bungee;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.LuckPermsApi;
|
import me.lucko.luckperms.api.LuckPermsApi;
|
||||||
import me.lucko.luckperms.bungee.calculators.BungeeCalculatorFactory;
|
import me.lucko.luckperms.bungee.calculator.BungeeCalculatorFactory;
|
||||||
import me.lucko.luckperms.bungee.contexts.BackendServerCalculator;
|
import me.lucko.luckperms.bungee.context.BackendServerCalculator;
|
||||||
import me.lucko.luckperms.bungee.contexts.BungeeContextManager;
|
import me.lucko.luckperms.bungee.context.BungeeContextManager;
|
||||||
import me.lucko.luckperms.bungee.contexts.RedisBungeeCalculator;
|
import me.lucko.luckperms.bungee.context.RedisBungeeCalculator;
|
||||||
import me.lucko.luckperms.bungee.listeners.BungeeConnectionListener;
|
import me.lucko.luckperms.bungee.listeners.BungeeConnectionListener;
|
||||||
import me.lucko.luckperms.bungee.listeners.BungeePermissionCheckListener;
|
import me.lucko.luckperms.bungee.listeners.BungeePermissionCheckListener;
|
||||||
import me.lucko.luckperms.bungee.messaging.BungeeMessagingFactory;
|
import me.lucko.luckperms.bungee.messaging.BungeeMessagingFactory;
|
||||||
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculator.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.command.CommandManager;
|
import me.lucko.luckperms.common.command.CommandManager;
|
||||||
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter;
|
||||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
import me.lucko.luckperms.common.context.ContextManager;
|
||||||
import me.lucko.luckperms.common.dependencies.Dependency;
|
import me.lucko.luckperms.common.dependencies.Dependency;
|
||||||
import me.lucko.luckperms.common.event.AbstractEventBus;
|
import me.lucko.luckperms.common.event.AbstractEventBus;
|
||||||
import me.lucko.luckperms.common.managers.group.StandardGroupManager;
|
|
||||||
import me.lucko.luckperms.common.managers.track.StandardTrackManager;
|
|
||||||
import me.lucko.luckperms.common.managers.user.StandardUserManager;
|
|
||||||
import me.lucko.luckperms.common.messaging.MessagingFactory;
|
import me.lucko.luckperms.common.messaging.MessagingFactory;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
|
import me.lucko.luckperms.common.model.manager.group.StandardGroupManager;
|
||||||
|
import me.lucko.luckperms.common.model.manager.track.StandardTrackManager;
|
||||||
|
import me.lucko.luckperms.common.model.manager.user.StandardUserManager;
|
||||||
import me.lucko.luckperms.common.plugin.AbstractLuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.AbstractLuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.plugin.util.AbstractConnectionListener;
|
import me.lucko.luckperms.common.plugin.util.AbstractConnectionListener;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
@@ -58,7 +58,6 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -94,7 +93,9 @@ public class LPBungeePlugin extends AbstractLuckPermsPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Set<Dependency> getGlobalDependencies() {
|
protected Set<Dependency> getGlobalDependencies() {
|
||||||
return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP, Dependency.EVENT);
|
Set<Dependency> dependencies = super.getGlobalDependencies();
|
||||||
|
dependencies.add(Dependency.TEXT_ADAPTER_BUNGEECORD);
|
||||||
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -141,7 +142,7 @@ public class LPBungeePlugin extends AbstractLuckPermsPlugin {
|
|||||||
this.contextManager.registerCalculator(new BackendServerCalculator(this));
|
this.contextManager.registerCalculator(new BackendServerCalculator(this));
|
||||||
|
|
||||||
if (this.bootstrap.getProxy().getPluginManager().getPlugin("RedisBungee") != null) {
|
if (this.bootstrap.getProxy().getPluginManager().getPlugin("RedisBungee") != null) {
|
||||||
this.contextManager.registerStaticCalculator(new RedisBungeeCalculator());
|
this.contextManager.registerCalculator(new RedisBungeeCalculator());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -23,20 +23,20 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bungee.calculators;
|
package me.lucko.luckperms.bungee.calculator;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.bungee.LPBungeePlugin;
|
import me.lucko.luckperms.bungee.LPBungeePlugin;
|
||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.cacheddata.CacheMetadata;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
import me.lucko.luckperms.common.calculator.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
import me.lucko.luckperms.common.calculator.PermissionCalculator;
|
||||||
|
import me.lucko.luckperms.common.calculator.processor.MapProcessor;
|
||||||
|
import me.lucko.luckperms.common.calculator.processor.PermissionProcessor;
|
||||||
|
import me.lucko.luckperms.common.calculator.processor.RegexProcessor;
|
||||||
|
import me.lucko.luckperms.common.calculator.processor.WildcardProcessor;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.processors.MapProcessor;
|
|
||||||
import me.lucko.luckperms.common.processors.PermissionProcessor;
|
|
||||||
import me.lucko.luckperms.common.processors.RegexProcessor;
|
|
||||||
import me.lucko.luckperms.common.processors.WildcardProcessor;
|
|
||||||
|
|
||||||
public class BungeeCalculatorFactory implements CalculatorFactory {
|
public class BungeeCalculatorFactory implements CalculatorFactory {
|
||||||
private final LPBungeePlugin plugin;
|
private final LPBungeePlugin plugin;
|
||||||
@@ -46,7 +46,7 @@ public class BungeeCalculatorFactory implements CalculatorFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PermissionCalculator build(Contexts contexts, PermissionCalculatorMetadata metadata) {
|
public PermissionCalculator build(Contexts contexts, CacheMetadata metadata) {
|
||||||
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
||||||
|
|
||||||
processors.add(new MapProcessor());
|
processors.add(new MapProcessor());
|
||||||
+1
-1
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bungee.contexts;
|
package me.lucko.luckperms.bungee.context;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.context.ContextCalculator;
|
import me.lucko.luckperms.api.context.ContextCalculator;
|
||||||
+5
-10
@@ -23,16 +23,16 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bungee.contexts;
|
package me.lucko.luckperms.bungee.context;
|
||||||
|
|
||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
|
||||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
import me.lucko.luckperms.bungee.LPBungeePlugin;
|
import me.lucko.luckperms.bungee.LPBungeePlugin;
|
||||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
import me.lucko.luckperms.common.context.ContextManager;
|
||||||
import me.lucko.luckperms.common.contexts.ContextsSupplier;
|
import me.lucko.luckperms.common.context.ContextsSupplier;
|
||||||
|
import me.lucko.luckperms.common.util.CaffeineFactory;
|
||||||
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
|
|
||||||
public class BungeeContextManager extends ContextManager<ProxiedPlayer> {
|
public class BungeeContextManager extends ContextManager<ProxiedPlayer> {
|
||||||
|
|
||||||
private final LoadingCache<ProxiedPlayer, Contexts> contextsCache = Caffeine.newBuilder()
|
private final LoadingCache<ProxiedPlayer, Contexts> contextsCache = CaffeineFactory.newBuilder()
|
||||||
.expireAfterWrite(50, TimeUnit.MILLISECONDS)
|
.expireAfterWrite(50, TimeUnit.MILLISECONDS)
|
||||||
.build(this::calculate);
|
.build(this::calculate);
|
||||||
|
|
||||||
@@ -90,10 +90,5 @@ public class BungeeContextManager extends ContextManager<ProxiedPlayer> {
|
|||||||
public Contexts getContexts() {
|
public Contexts getContexts() {
|
||||||
return this.contextsCache.get(this.key);
|
return this.contextsCache.get(this.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ImmutableContextSet getContextSet() {
|
|
||||||
return getContexts().getContexts().makeImmutable();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.bungee.contexts;
|
package me.lucko.luckperms.bungee.context;
|
||||||
|
|
||||||
import com.imaginarycode.minecraft.redisbungee.RedisBungee;
|
import com.imaginarycode.minecraft.redisbungee.RedisBungee;
|
||||||
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
|
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
|
||||||
+2
-1
@@ -82,8 +82,8 @@ public class BungeeConnectionListener extends AbstractConnectionListener impleme
|
|||||||
- setting up cached data. */
|
- setting up cached data. */
|
||||||
try {
|
try {
|
||||||
User user = loadUser(c.getUniqueId(), c.getName());
|
User user = loadUser(c.getUniqueId(), c.getName());
|
||||||
this.plugin.getEventFactory().handleUserLoginProcess(c.getUniqueId(), c.getName(), user);
|
|
||||||
recordConnection(c.getUniqueId());
|
recordConnection(c.getUniqueId());
|
||||||
|
this.plugin.getEventFactory().handlePlayerLoginProcess(c.getUniqueId(), c.getName(), user);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + c.getUniqueId() + " - " + c.getName());
|
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + c.getUniqueId() + " - " + c.getName());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@@ -94,6 +94,7 @@ public class BungeeConnectionListener extends AbstractConnectionListener impleme
|
|||||||
e.setCancelReason(TextComponent.fromLegacyText(Message.LOADING_DATABASE_ERROR.asString(this.plugin.getLocaleManager())));
|
e.setCancelReason(TextComponent.fromLegacyText(Message.LOADING_DATABASE_ERROR.asString(this.plugin.getLocaleManager())));
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
this.plugin.getEventFactory().handlePlayerLoginProcess(c.getUniqueId(), c.getName(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally, complete our intent to modify state, so the proxy can continue handling the connection.
|
// finally, complete our intent to modify state, so the proxy can continue handling the connection.
|
||||||
|
|||||||
+5
-5
@@ -30,9 +30,9 @@ import me.lucko.luckperms.api.Tristate;
|
|||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.bungee.LPBungeePlugin;
|
import me.lucko.luckperms.bungee.LPBungeePlugin;
|
||||||
import me.lucko.luckperms.bungee.event.TristateCheckEvent;
|
import me.lucko.luckperms.bungee.event.TristateCheckEvent;
|
||||||
|
import me.lucko.luckperms.common.calculator.result.TristateResult;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PermissionCheckEvent;
|
import net.md_5.bungee.api.event.PermissionCheckEvent;
|
||||||
@@ -67,7 +67,7 @@ public class BungeePermissionCheckListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Contexts contexts = this.plugin.getContextManager().getApplicableContexts(player);
|
Contexts contexts = this.plugin.getContextManager().getApplicableContexts(player);
|
||||||
Tristate result = user.getCachedData().getPermissionData(contexts).getPermissionValue(e.getPermission(), CheckOrigin.PLATFORM_PERMISSION_CHECK);
|
Tristate result = user.getCachedData().getPermissionData(contexts).getPermissionValue(e.getPermission(), me.lucko.luckperms.common.verbose.event.PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK).result();
|
||||||
if (result == Tristate.UNDEFINED && this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUNGEE_CONFIG_PERMISSIONS)) {
|
if (result == Tristate.UNDEFINED && this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUNGEE_CONFIG_PERMISSIONS)) {
|
||||||
return; // just use the result provided by the proxy when the event was created
|
return; // just use the result provided by the proxy when the event was created
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ public class BungeePermissionCheckListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Contexts contexts = this.plugin.getContextManager().getApplicableContexts(player);
|
Contexts contexts = this.plugin.getContextManager().getApplicableContexts(player);
|
||||||
Tristate result = user.getCachedData().getPermissionData(contexts).getPermissionValue(e.getPermission(), CheckOrigin.PLATFORM_LOOKUP_CHECK);
|
Tristate result = user.getCachedData().getPermissionData(contexts).getPermissionValue(e.getPermission(), me.lucko.luckperms.common.verbose.event.PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK).result();
|
||||||
if (result == Tristate.UNDEFINED && this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUNGEE_CONFIG_PERMISSIONS)) {
|
if (result == Tristate.UNDEFINED && this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUNGEE_CONFIG_PERMISSIONS)) {
|
||||||
return; // just use the result provided by the proxy when the event was created
|
return; // just use the result provided by the proxy when the event was created
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ public class BungeePermissionCheckListener implements Listener {
|
|||||||
Tristate result = Tristate.fromBoolean(e.hasPermission());
|
Tristate result = Tristate.fromBoolean(e.hasPermission());
|
||||||
String name = "internal/" + e.getSender().getName();
|
String name = "internal/" + e.getSender().getName();
|
||||||
|
|
||||||
this.plugin.getVerboseHandler().offerCheckData(CheckOrigin.PLATFORM_PERMISSION_CHECK, name, ContextSet.empty(), permission, result);
|
this.plugin.getVerboseHandler().offerPermissionCheckEvent(me.lucko.luckperms.common.verbose.event.PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK, name, ContextSet.empty(), permission, TristateResult.of(result));
|
||||||
this.plugin.getPermissionRegistry().offer(permission);
|
this.plugin.getPermissionRegistry().offer(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ public class BungeePermissionCheckListener implements Listener {
|
|||||||
Tristate result = e.getResult();
|
Tristate result = e.getResult();
|
||||||
String name = "internal/" + e.getSender().getName();
|
String name = "internal/" + e.getSender().getName();
|
||||||
|
|
||||||
this.plugin.getVerboseHandler().offerCheckData(CheckOrigin.PLATFORM_LOOKUP_CHECK, name, ContextSet.empty(), permission, result);
|
this.plugin.getVerboseHandler().offerPermissionCheckEvent(me.lucko.luckperms.common.verbose.event.PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK, name, ContextSet.empty(), permission, TristateResult.of(result));
|
||||||
this.plugin.getPermissionRegistry().offer(permission);
|
this.plugin.getPermissionRegistry().offer(permission);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,13 +32,14 @@ import me.lucko.luckperms.common.command.access.CommandPermission;
|
|||||||
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
import me.lucko.luckperms.common.commands.migration.MigrationUtils;
|
||||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||||
|
import me.lucko.luckperms.common.locale.message.Message;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Iterators;
|
import me.lucko.luckperms.common.util.Iterators;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.util.Predicates;
|
||||||
import me.lucko.luckperms.common.utils.ProgressLogger;
|
import me.lucko.luckperms.common.util.ProgressLogger;
|
||||||
|
|
||||||
import net.alpenblock.bungeeperms.BungeePerms;
|
import net.alpenblock.bungeeperms.BungeePerms;
|
||||||
import net.alpenblock.bungeeperms.Group;
|
import net.alpenblock.bungeeperms.Group;
|
||||||
@@ -57,7 +58,7 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
|
||||||
ProgressLogger log = new ProgressLogger("BungeePerms");
|
ProgressLogger log = new ProgressLogger(Message.MIGRATION_LOG, Message.MIGRATION_LOG_PROGRESS, "BungeePerms");
|
||||||
log.addListener(plugin.getConsoleSender());
|
log.addListener(plugin.getConsoleSender());
|
||||||
log.addListener(sender);
|
log.addListener(sender);
|
||||||
|
|
||||||
@@ -118,7 +119,7 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
|||||||
plugin.getStorage().saveUser(user);
|
plugin.getStorage().saveUser(user);
|
||||||
plugin.getUserManager().cleanup(user);
|
plugin.getUserManager().cleanup(user);
|
||||||
|
|
||||||
log.logProgress("Migrated {} users so far.", userCount.incrementAndGet());
|
log.logProgress("Migrated {} users so far.", userCount.incrementAndGet(), ProgressLogger.DEFAULT_NOTIFY_FREQUENCY);
|
||||||
});
|
});
|
||||||
|
|
||||||
log.log("Migrated " + userCount.get() + " users.");
|
log.log("Migrated " + userCount.get() + " users.");
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import java.util.Optional;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public final class RedisBungeeUtil {
|
public final class RedisBungeeUtil {
|
||||||
|
private RedisBungeeUtil() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks up a UUID from username via RedisBungee's uuid cache.
|
* Looks up a UUID from username via RedisBungee's uuid cache.
|
||||||
@@ -46,6 +47,4 @@ public final class RedisBungeeUtil {
|
|||||||
return Optional.ofNullable(RedisBungee.getApi()).map(a -> a.getNameFromUuid(uuid, true));
|
return Optional.ofNullable(RedisBungee.getApi()).map(a -> a.getNameFromUuid(uuid, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private RedisBungeeUtil() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
# | | | | / ` |__/ |__) |__ |__) |\/| /__` | #
|
# | | | | / ` |__/ |__) |__ |__) |\/| /__` | #
|
||||||
# | |___ \__/ \__, | \ | |___ | \ | | .__/ | #
|
# | |___ \__/ \__, | \ | |___ | \ | | .__/ | #
|
||||||
# | | #
|
# | | #
|
||||||
|
# | https://luckperms.github.io | #
|
||||||
# | | #
|
# | | #
|
||||||
# | SOURCE CODE: https://github.com/lucko/LuckPerms | #
|
# | SOURCE CODE: https://github.com/lucko/LuckPerms | #
|
||||||
# | WIKI: https://github.com/lucko/LuckPerms/wiki | #
|
# | WIKI: https://github.com/lucko/LuckPerms/wiki | #
|
||||||
@@ -247,7 +248,7 @@ redis:
|
|||||||
# If LuckPerms should ensure all players have permission data when they connect to the server.
|
# If LuckPerms should ensure all players have permission data when they connect to the server.
|
||||||
#
|
#
|
||||||
# - When set to true, LuckPerms will cancel login attempts if it is unable to load permissions data
|
# - When set to true, LuckPerms will cancel login attempts if it is unable to load permissions data
|
||||||
# for a user, of if the storage provider is unavailable.
|
# for a user, or if the storage provider is unavailable.
|
||||||
# - When set to false, LuckPerms will allow a player to connect regardless of whether their
|
# - When set to false, LuckPerms will allow a player to connect regardless of whether their
|
||||||
# permissions data could be loaded.
|
# permissions data could be loaded.
|
||||||
# - This option does not exist on other platforms, and effectively defaults to true - however,
|
# - This option does not exist on other platforms, and effectively defaults to true - however,
|
||||||
@@ -308,6 +309,8 @@ log-notify: true
|
|||||||
# - It is explained and documented in more detail on the wiki under "Prefix & Suffix Stacking".
|
# - It is explained and documented in more detail on the wiki under "Prefix & Suffix Stacking".
|
||||||
#
|
#
|
||||||
# - The options are divided into separate sections for prefixes and suffixes.
|
# - The options are divided into separate sections for prefixes and suffixes.
|
||||||
|
# - The 'duplicates' setting refers to how duplicate elements are handled. Can be 'retain-all',
|
||||||
|
# 'first-only' or 'last-only'.
|
||||||
# - The value of 'start-spacer' is included at the start of the resultant prefix/suffix.
|
# - The value of 'start-spacer' is included at the start of the resultant prefix/suffix.
|
||||||
# - The value of 'end-spacer' is included at the end of the resultant prefix/suffix.
|
# - The value of 'end-spacer' is included at the end of the resultant prefix/suffix.
|
||||||
# - The value of 'middle-spacer' is included between each element in the resultant prefix/suffix.
|
# - The value of 'middle-spacer' is included between each element in the resultant prefix/suffix.
|
||||||
@@ -341,12 +344,14 @@ meta-formatting:
|
|||||||
prefix:
|
prefix:
|
||||||
format:
|
format:
|
||||||
- "highest"
|
- "highest"
|
||||||
|
duplicates: first-only
|
||||||
start-spacer: ""
|
start-spacer: ""
|
||||||
middle-spacer: " "
|
middle-spacer: " "
|
||||||
end-spacer: ""
|
end-spacer: ""
|
||||||
suffix:
|
suffix:
|
||||||
format:
|
format:
|
||||||
- "highest"
|
- "highest"
|
||||||
|
duplicates: first-only
|
||||||
start-spacer: ""
|
start-spacer: ""
|
||||||
middle-spacer: " "
|
middle-spacer: " "
|
||||||
end-spacer: ""
|
end-spacer: ""
|
||||||
@@ -370,6 +375,19 @@ meta-formatting:
|
|||||||
# => depth-first-post-order See: https://en.wikipedia.org/wiki/Depth-first_search
|
# => depth-first-post-order See: https://en.wikipedia.org/wiki/Depth-first_search
|
||||||
inheritance-traversal-algorithm: depth-first-pre-order
|
inheritance-traversal-algorithm: depth-first-pre-order
|
||||||
|
|
||||||
|
# If a final sort according to "inheritance rules" should be performed after the traversal algorithm
|
||||||
|
# has resolved the inheritance tree.
|
||||||
|
#
|
||||||
|
# "Inheritance rules" refers to things such as group weightings, primary group status, and the
|
||||||
|
# natural contextual ordering of the group nodes.
|
||||||
|
#
|
||||||
|
# Setting this to 'true' will allow for the inheritance rules to take priority over the structure of
|
||||||
|
# the inheritance tree.
|
||||||
|
#
|
||||||
|
# Effectively when this setting is 'true': the tree is flattened, and rules applied afterwards,
|
||||||
|
# and when this setting is 'false':, the rules are just applied during each step of the traversal.
|
||||||
|
post-traversal-inheritance-sort: false
|
||||||
|
|
||||||
# +----------------------------------------------------------------------------------------------+ #
|
# +----------------------------------------------------------------------------------------------+ #
|
||||||
# | Permission resolution settings | #
|
# | Permission resolution settings | #
|
||||||
# +----------------------------------------------------------------------------------------------+ #
|
# +----------------------------------------------------------------------------------------------+ #
|
||||||
|
|||||||
+14
-9
@@ -2,9 +2,14 @@ dependencies {
|
|||||||
compile project(':luckperms-api')
|
compile project(':luckperms-api')
|
||||||
|
|
||||||
compile 'org.checkerframework:checker-qual:2.5.5'
|
compile 'org.checkerframework:checker-qual:2.5.5'
|
||||||
compile('net.kyori:text:1.11-1.6.4') {
|
compile('net.kyori:text-api:3.0.0') {
|
||||||
exclude(module: 'checker-qual')
|
exclude(module: 'checker-qual')
|
||||||
exclude(module: 'guava')
|
}
|
||||||
|
compile('net.kyori:text-serializer-legacy:3.0.0') {
|
||||||
|
exclude(module: 'text-api')
|
||||||
|
}
|
||||||
|
compile('net.kyori:text-serializer-gson:3.0.0') {
|
||||||
|
exclude(module: 'text-api')
|
||||||
exclude(module: 'gson')
|
exclude(module: 'gson')
|
||||||
}
|
}
|
||||||
compile('net.kyori:event-api:3.0.0') {
|
compile('net.kyori:event-api:3.0.0') {
|
||||||
@@ -13,9 +18,9 @@ dependencies {
|
|||||||
}
|
}
|
||||||
compile 'com.google.code.gson:gson:2.7'
|
compile 'com.google.code.gson:gson:2.7'
|
||||||
compile 'com.google.guava:guava:19.0'
|
compile 'com.google.guava:guava:19.0'
|
||||||
compile 'com.github.ben-manes.caffeine:caffeine:2.6.2'
|
compile 'com.github.ben-manes.caffeine:caffeine:2.7.0'
|
||||||
compile 'com.squareup.okhttp3:okhttp:3.11.0'
|
compile 'com.squareup.okhttp3:okhttp:3.14.1'
|
||||||
compile 'com.squareup.okio:okio:1.15.0'
|
compile 'com.squareup.okio:okio:1.17.3'
|
||||||
compile('me.lucko.configurate:configurate-core:3.5') {
|
compile('me.lucko.configurate:configurate-core:3.5') {
|
||||||
exclude(module: 'guava')
|
exclude(module: 'guava')
|
||||||
}
|
}
|
||||||
@@ -29,8 +34,8 @@ dependencies {
|
|||||||
compile('me.lucko.configurate:configurate-toml:3.5') {
|
compile('me.lucko.configurate:configurate-toml:3.5') {
|
||||||
exclude(module: 'toml4j')
|
exclude(module: 'toml4j')
|
||||||
}
|
}
|
||||||
compile 'com.zaxxer:HikariCP:3.2.0'
|
compile 'com.zaxxer:HikariCP:3.3.1'
|
||||||
compile 'redis.clients:jedis:2.9.0'
|
compile 'redis.clients:jedis:2.10.2'
|
||||||
compile 'org.mongodb:mongo-java-driver:3.8.1'
|
compile 'org.mongodb:mongo-java-driver:3.10.1'
|
||||||
compile 'org.yaml:snakeyaml:1.22'
|
compile 'org.yaml:snakeyaml:1.23'
|
||||||
}
|
}
|
||||||
@@ -31,6 +31,7 @@ import me.lucko.luckperms.api.Contexts;
|
|||||||
import me.lucko.luckperms.api.LogEntry;
|
import me.lucko.luckperms.api.LogEntry;
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.Track;
|
import me.lucko.luckperms.common.model.Track;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
@@ -46,7 +47,6 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of {@link LogEntry} and {@link LogEntry.Builder},
|
* An implementation of {@link LogEntry} and {@link LogEntry.Builder},
|
||||||
@@ -287,11 +287,11 @@ public class ExtendedLogEntry implements LogEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Builder acted(PermissionHolder acted) {
|
public Builder acted(PermissionHolder acted) {
|
||||||
if (acted.getType().isUser()) {
|
if (acted.getType() == HolderType.USER) {
|
||||||
actedName(((User) acted).getName().orElse("null"));
|
actedName(((User) acted).getName().orElse("null"));
|
||||||
acted(((User) acted).getUuid());
|
acted(((User) acted).getUuid());
|
||||||
type(Type.USER);
|
type(Type.USER);
|
||||||
} else if (acted.getType().isGroup()) {
|
} else if (acted.getType() == HolderType.GROUP) {
|
||||||
actedName(((Group) acted).getName());
|
actedName(((Group) acted).getName());
|
||||||
type(Type.GROUP);
|
type(Type.GROUP);
|
||||||
}
|
}
|
||||||
@@ -331,7 +331,7 @@ public class ExtendedLogEntry implements LogEntry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
action(parts.stream().collect(Collectors.joining(" ")));
|
action(String.join(" ", parts));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ package me.lucko.luckperms.common.actionlog;
|
|||||||
import com.google.common.collect.ImmutableSortedSet;
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.LogEntry;
|
import me.lucko.luckperms.api.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|||||||
+2
-2
@@ -35,6 +35,7 @@ import me.lucko.luckperms.api.LogEntry;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public final class LogEntryJsonSerializer {
|
public final class LogEntryJsonSerializer {
|
||||||
|
private LogEntryJsonSerializer() {}
|
||||||
|
|
||||||
public static JsonObject serialize(LogEntry logEntry) {
|
public static JsonObject serialize(LogEntry logEntry) {
|
||||||
JsonObject data = new JsonObject();
|
JsonObject data = new JsonObject();
|
||||||
@@ -58,7 +59,7 @@ public final class LogEntryJsonSerializer {
|
|||||||
|
|
||||||
builder.actor(UUID.fromString(data.get("actor").getAsString()));
|
builder.actor(UUID.fromString(data.get("actor").getAsString()));
|
||||||
builder.actorName(data.get("actorName").getAsString());
|
builder.actorName(data.get("actorName").getAsString());
|
||||||
builder.type(LogEntry.Type.valueOf(data.get("type").getAsString()));
|
builder.type(LogEntry.Type.parse(data.get("type").getAsString()));
|
||||||
if (data.has("acted")) {
|
if (data.has("acted")) {
|
||||||
builder.actor(UUID.fromString(data.get("acted").getAsString()));
|
builder.actor(UUID.fromString(data.get("acted").getAsString()));
|
||||||
}
|
}
|
||||||
@@ -68,5 +69,4 @@ public final class LogEntryJsonSerializer {
|
|||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private LogEntryJsonSerializer() {}
|
|
||||||
}
|
}
|
||||||
@@ -27,19 +27,25 @@ package me.lucko.luckperms.common.api;
|
|||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.storage.DataConstraints;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.storage.misc.DataConstraints;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public final class ApiUtils {
|
public final class ApiUtils {
|
||||||
|
private ApiUtils() {}
|
||||||
|
|
||||||
public static String checkUsername(String s) {
|
public static String checkUsername(String s, LuckPermsPlugin plugin) {
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Preconditions.checkArgument(
|
Predicate<String> test = plugin.getConfiguration().get(ConfigKeys.ALLOW_INVALID_USERNAMES) ?
|
||||||
DataConstraints.PLAYER_USERNAME_TEST.test(s),
|
DataConstraints.PLAYER_USERNAME_TEST_LENIENT :
|
||||||
"Invalid username entry '" + s + "'. Usernames must be less than 16 chars and only contain 'a-z A-Z 1-9 _'."
|
DataConstraints.PLAYER_USERNAME_TEST;
|
||||||
);
|
|
||||||
|
Preconditions.checkArgument(test.test(s), "Invalid username entry: " + s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,13 +54,8 @@ public final class ApiUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Preconditions.checkArgument(
|
Preconditions.checkArgument(DataConstraints.GROUP_NAME_TEST.test(s), "Invalid name entry: " + s);
|
||||||
DataConstraints.GROUP_NAME_TEST.test(s),
|
|
||||||
"Invalid name entry '" + s + "'. Names must be less than 37 chars and only contain 'a-z A-Z 1-9'."
|
|
||||||
);
|
|
||||||
return s.toLowerCase();
|
return s.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApiUtils() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -34,28 +34,31 @@ import me.lucko.luckperms.api.Storage;
|
|||||||
import me.lucko.luckperms.api.UuidCache;
|
import me.lucko.luckperms.api.UuidCache;
|
||||||
import me.lucko.luckperms.api.context.ContextManager;
|
import me.lucko.luckperms.api.context.ContextManager;
|
||||||
import me.lucko.luckperms.api.event.EventBus;
|
import me.lucko.luckperms.api.event.EventBus;
|
||||||
|
import me.lucko.luckperms.api.manager.CachedDataManager;
|
||||||
import me.lucko.luckperms.api.manager.GroupManager;
|
import me.lucko.luckperms.api.manager.GroupManager;
|
||||||
import me.lucko.luckperms.api.manager.TrackManager;
|
import me.lucko.luckperms.api.manager.TrackManager;
|
||||||
import me.lucko.luckperms.api.manager.UserManager;
|
import me.lucko.luckperms.api.manager.UserManager;
|
||||||
import me.lucko.luckperms.api.messenger.MessengerProvider;
|
import me.lucko.luckperms.api.messenger.MessengerProvider;
|
||||||
import me.lucko.luckperms.api.metastacking.MetaStackFactory;
|
import me.lucko.luckperms.api.metastacking.MetaStackFactory;
|
||||||
import me.lucko.luckperms.api.platform.PlatformInfo;
|
import me.lucko.luckperms.api.platform.PlatformInfo;
|
||||||
import me.lucko.luckperms.common.api.delegates.manager.ApiContextManager;
|
import me.lucko.luckperms.common.api.implementation.ApiActionLogger;
|
||||||
import me.lucko.luckperms.common.api.delegates.manager.ApiGroupManager;
|
import me.lucko.luckperms.common.api.implementation.ApiCachedDataManager;
|
||||||
import me.lucko.luckperms.common.api.delegates.manager.ApiTrackManager;
|
import me.lucko.luckperms.common.api.implementation.ApiContextManager;
|
||||||
import me.lucko.luckperms.common.api.delegates.manager.ApiUserManager;
|
import me.lucko.luckperms.common.api.implementation.ApiGroupManager;
|
||||||
import me.lucko.luckperms.common.api.delegates.misc.ApiActionLogger;
|
import me.lucko.luckperms.common.api.implementation.ApiMessagingService;
|
||||||
import me.lucko.luckperms.common.api.delegates.misc.ApiMessagingService;
|
import me.lucko.luckperms.common.api.implementation.ApiMetaStackFactory;
|
||||||
import me.lucko.luckperms.common.api.delegates.misc.ApiMetaStackFactory;
|
import me.lucko.luckperms.common.api.implementation.ApiNodeFactory;
|
||||||
import me.lucko.luckperms.common.api.delegates.misc.ApiNodeFactory;
|
import me.lucko.luckperms.common.api.implementation.ApiPlatformInfo;
|
||||||
import me.lucko.luckperms.common.api.delegates.misc.ApiPlatformInfo;
|
import me.lucko.luckperms.common.api.implementation.ApiTrackManager;
|
||||||
import me.lucko.luckperms.common.api.delegates.misc.NoopUuidCache;
|
import me.lucko.luckperms.common.api.implementation.ApiUserManager;
|
||||||
|
import me.lucko.luckperms.common.api.implementation.NoopUuidCache;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.messaging.LuckPermsMessagingService;
|
import me.lucko.luckperms.common.messaging.LuckPermsMessagingService;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@@ -70,6 +73,7 @@ public class LuckPermsApiProvider implements LuckPermsApi {
|
|||||||
private final UserManager userManager;
|
private final UserManager userManager;
|
||||||
private final GroupManager groupManager;
|
private final GroupManager groupManager;
|
||||||
private final TrackManager trackManager;
|
private final TrackManager trackManager;
|
||||||
|
private final CachedDataManager cachedDataManager;
|
||||||
private final ActionLogger actionLogger;
|
private final ActionLogger actionLogger;
|
||||||
private final ContextManager contextManager;
|
private final ContextManager contextManager;
|
||||||
private final MetaStackFactory metaStackFactory;
|
private final MetaStackFactory metaStackFactory;
|
||||||
@@ -81,6 +85,7 @@ public class LuckPermsApiProvider implements LuckPermsApi {
|
|||||||
this.userManager = new ApiUserManager(plugin, plugin.getUserManager());
|
this.userManager = new ApiUserManager(plugin, plugin.getUserManager());
|
||||||
this.groupManager = new ApiGroupManager(plugin, plugin.getGroupManager());
|
this.groupManager = new ApiGroupManager(plugin, plugin.getGroupManager());
|
||||||
this.trackManager = new ApiTrackManager(plugin, plugin.getTrackManager());
|
this.trackManager = new ApiTrackManager(plugin, plugin.getTrackManager());
|
||||||
|
this.cachedDataManager = new ApiCachedDataManager(plugin.getUserManager(), plugin.getGroupManager());
|
||||||
this.actionLogger = new ApiActionLogger(plugin);
|
this.actionLogger = new ApiActionLogger(plugin);
|
||||||
this.contextManager = new ApiContextManager(plugin, plugin.getContextManager());
|
this.contextManager = new ApiContextManager(plugin, plugin.getContextManager());
|
||||||
this.metaStackFactory = new ApiMetaStackFactory(plugin);
|
this.metaStackFactory = new ApiMetaStackFactory(plugin);
|
||||||
@@ -106,6 +111,11 @@ public class LuckPermsApiProvider implements LuckPermsApi {
|
|||||||
return this.trackManager;
|
return this.trackManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull CachedDataManager getCachedDataManager() {
|
||||||
|
return this.cachedDataManager;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull CompletableFuture<Void> runUpdateTask() {
|
public @NonNull CompletableFuture<Void> runUpdateTask() {
|
||||||
return this.plugin.getSyncTaskBuffer().request();
|
return this.plugin.getSyncTaskBuffer().request();
|
||||||
@@ -154,6 +164,11 @@ public class LuckPermsApiProvider implements LuckPermsApi {
|
|||||||
return this.contextManager;
|
return this.contextManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull Collection<String> getKnownPermissions() {
|
||||||
|
return this.plugin.getPermissionRegistry().rootAsList();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull NodeFactory getNodeFactory() {
|
public @NonNull NodeFactory getNodeFactory() {
|
||||||
return ApiNodeFactory.INSTANCE;
|
return ApiNodeFactory.INSTANCE;
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.api.delegates.manager;
|
package me.lucko.luckperms.common.api.implementation;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
+1
-2
@@ -23,13 +23,12 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.api.delegates.misc;
|
package me.lucko.luckperms.common.api.implementation;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.ActionLogger;
|
import me.lucko.luckperms.api.ActionLogger;
|
||||||
import me.lucko.luckperms.api.Log;
|
import me.lucko.luckperms.api.Log;
|
||||||
import me.lucko.luckperms.api.LogEntry;
|
import me.lucko.luckperms.api.LogEntry;
|
||||||
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
import me.lucko.luckperms.common.actionlog.ExtendedLogEntry;
|
||||||
import me.lucko.luckperms.common.api.delegates.model.ApiLog;
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* 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.common.api.implementation;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.manager.CachedDataManager;
|
||||||
|
import me.lucko.luckperms.common.model.manager.group.GroupManager;
|
||||||
|
import me.lucko.luckperms.common.model.manager.user.UserManager;
|
||||||
|
|
||||||
|
public class ApiCachedDataManager implements CachedDataManager {
|
||||||
|
private final UserManager<?> userManager;
|
||||||
|
private final GroupManager<?> groupManager;
|
||||||
|
|
||||||
|
public ApiCachedDataManager(UserManager<?> userManager, GroupManager<?> groupManager) {
|
||||||
|
this.userManager = userManager;
|
||||||
|
this.groupManager = groupManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invalidateAllUserCaches() {
|
||||||
|
this.userManager.invalidateAllUserCaches();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invalidateAllGroupCaches() {
|
||||||
|
this.groupManager.invalidateAllGroupCaches();
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
-8
@@ -23,14 +23,14 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.api.delegates.misc;
|
package me.lucko.luckperms.common.api.implementation;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.LPConfiguration;
|
import me.lucko.luckperms.api.LPConfiguration;
|
||||||
import me.lucko.luckperms.api.LookupSetting;
|
import me.lucko.luckperms.api.LookupSetting;
|
||||||
import me.lucko.luckperms.common.config.ConfigKey;
|
import me.lucko.luckperms.common.config.ConfigKey;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.config.LuckPermsConfiguration;
|
import me.lucko.luckperms.common.config.LuckPermsConfiguration;
|
||||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
@@ -52,27 +52,27 @@ public class ApiConfiguration implements LPConfiguration {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getIncludeGlobalPerms() {
|
public boolean getIncludeGlobalPerms() {
|
||||||
return this.handle.get(ConfigKeys.LOOKUP_SETTINGS).contains(LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER);
|
return this.handle.get(ConfigKeys.GLOBAL_CONTEXTS).hasSetting(LookupSetting.INCLUDE_NODES_SET_WITHOUT_SERVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getIncludeGlobalWorldPerms() {
|
public boolean getIncludeGlobalWorldPerms() {
|
||||||
return this.handle.get(ConfigKeys.LOOKUP_SETTINGS).contains(LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD);
|
return this.handle.get(ConfigKeys.GLOBAL_CONTEXTS).hasSetting(LookupSetting.INCLUDE_NODES_SET_WITHOUT_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getApplyGlobalGroups() {
|
public boolean getApplyGlobalGroups() {
|
||||||
return this.handle.get(ConfigKeys.LOOKUP_SETTINGS).contains(LookupSetting.APPLY_PARENTS_SET_WITHOUT_SERVER);
|
return this.handle.get(ConfigKeys.GLOBAL_CONTEXTS).hasSetting(LookupSetting.APPLY_PARENTS_SET_WITHOUT_SERVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getApplyGlobalWorldGroups() {
|
public boolean getApplyGlobalWorldGroups() {
|
||||||
return this.handle.get(ConfigKeys.LOOKUP_SETTINGS).contains(LookupSetting.APPLY_PARENTS_SET_WITHOUT_WORLD);
|
return this.handle.get(ConfigKeys.GLOBAL_CONTEXTS).hasSetting(LookupSetting.APPLY_PARENTS_SET_WITHOUT_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull String getStorageMethod() {
|
public @NonNull String getStorageMethod() {
|
||||||
return this.handle.get(ConfigKeys.STORAGE_METHOD);
|
return this.handle.get(ConfigKeys.STORAGE_METHOD).getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -83,7 +83,7 @@ public class ApiConfiguration implements LPConfiguration {
|
|||||||
@Override
|
@Override
|
||||||
public @NonNull Map<String, String> getSplitStorageOptions() {
|
public @NonNull Map<String, String> getSplitStorageOptions() {
|
||||||
return this.handle.get(ConfigKeys.SPLIT_STORAGE_OPTIONS).entrySet().stream()
|
return this.handle.get(ConfigKeys.SPLIT_STORAGE_OPTIONS).entrySet().stream()
|
||||||
.collect(ImmutableCollectors.toMap(e -> e.getKey().name().toLowerCase(), Map.Entry::getValue));
|
.collect(ImmutableCollectors.toMap(e -> e.getKey().name().toLowerCase(), e -> e.getValue().getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
+4
-6
@@ -23,15 +23,13 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.api.delegates.manager;
|
package me.lucko.luckperms.common.api.implementation;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.User;
|
import me.lucko.luckperms.api.User;
|
||||||
import me.lucko.luckperms.api.context.ContextCalculator;
|
import me.lucko.luckperms.api.context.ContextCalculator;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
import me.lucko.luckperms.api.context.StaticContextCalculator;
|
import me.lucko.luckperms.common.context.ContextManager;
|
||||||
import me.lucko.luckperms.common.api.delegates.model.ApiUser;
|
|
||||||
import me.lucko.luckperms.common.contexts.ContextManager;
|
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
@@ -110,9 +108,9 @@ public class ApiContextManager implements me.lucko.luckperms.api.context.Context
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerStaticCalculator(@NonNull StaticContextCalculator calculator) {
|
public void unregisterCalculator(@NonNull ContextCalculator<?> calculator) {
|
||||||
Objects.requireNonNull(calculator, "calculator");
|
Objects.requireNonNull(calculator, "calculator");
|
||||||
this.handle.registerStaticCalculator(calculator);
|
this.handle.unregisterCalculator(calculator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
+2
-2
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.api.delegates.model;
|
package me.lucko.luckperms.common.api.implementation;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
public final class ApiGroup extends ApiPermissionHolder implements me.lucko.luckperms.api.Group {
|
public class ApiGroup extends ApiPermissionHolder implements me.lucko.luckperms.api.Group {
|
||||||
public static Group cast(me.lucko.luckperms.api.Group group) {
|
public static Group cast(me.lucko.luckperms.api.Group group) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Preconditions.checkState(group instanceof ApiGroup, "Illegal instance " + group.getClass() + " cannot be handled by this implementation.");
|
Preconditions.checkState(group instanceof ApiGroup, "Illegal instance " + group.getClass() + " cannot be handled by this implementation.");
|
||||||
+18
-8
@@ -23,20 +23,19 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.api.delegates.manager;
|
package me.lucko.luckperms.common.api.implementation;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.HeldPermission;
|
import me.lucko.luckperms.api.HeldPermission;
|
||||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||||
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
||||||
import me.lucko.luckperms.common.api.ApiUtils;
|
import me.lucko.luckperms.common.api.ApiUtils;
|
||||||
import me.lucko.luckperms.common.api.delegates.model.ApiGroup;
|
import me.lucko.luckperms.common.bulkupdate.comparison.Constraint;
|
||||||
import me.lucko.luckperms.common.bulkupdate.comparisons.Constraint;
|
import me.lucko.luckperms.common.bulkupdate.comparison.StandardComparison;
|
||||||
import me.lucko.luckperms.common.bulkupdate.comparisons.StandardComparison;
|
|
||||||
import me.lucko.luckperms.common.managers.group.GroupManager;
|
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
|
import me.lucko.luckperms.common.model.manager.group.GroupManager;
|
||||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
@@ -76,7 +75,12 @@ public class ApiGroupManager extends ApiAbstractManager<Group, me.lucko.luckperm
|
|||||||
@Override
|
@Override
|
||||||
public @NonNull CompletableFuture<Void> saveGroup(me.lucko.luckperms.api.@NonNull Group group) {
|
public @NonNull CompletableFuture<Void> saveGroup(me.lucko.luckperms.api.@NonNull Group group) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return this.plugin.getStorage().saveGroup(ApiGroup.cast(group));
|
return this.plugin.getStorage().saveGroup(ApiGroup.cast(group)).thenRun(() -> {
|
||||||
|
// invalidate caches - they have potentially been affected by
|
||||||
|
// this change.
|
||||||
|
this.plugin.getGroupManager().invalidateAllGroupCaches();
|
||||||
|
this.plugin.getUserManager().invalidateAllUserCaches();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -85,7 +89,13 @@ public class ApiGroupManager extends ApiAbstractManager<Group, me.lucko.luckperm
|
|||||||
if (group.getName().equalsIgnoreCase(NodeFactory.DEFAULT_GROUP_NAME)) {
|
if (group.getName().equalsIgnoreCase(NodeFactory.DEFAULT_GROUP_NAME)) {
|
||||||
throw new IllegalArgumentException("Cannot delete the default group.");
|
throw new IllegalArgumentException("Cannot delete the default group.");
|
||||||
}
|
}
|
||||||
return this.plugin.getStorage().deleteGroup(ApiGroup.cast(group), DeletionCause.API);
|
|
||||||
|
return this.plugin.getStorage().deleteGroup(ApiGroup.cast(group), DeletionCause.API).thenRun(() -> {
|
||||||
|
// invalidate caches - they have potentially been affected by
|
||||||
|
// this change.
|
||||||
|
this.plugin.getGroupManager().invalidateAllGroupCaches();
|
||||||
|
this.plugin.getUserManager().invalidateAllUserCaches();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
+4
-5
@@ -23,10 +23,11 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.api.delegates.model;
|
package me.lucko.luckperms.common.api.implementation;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.LogEntry;
|
import me.lucko.luckperms.api.LogEntry;
|
||||||
import me.lucko.luckperms.common.actionlog.Log;
|
import me.lucko.luckperms.common.actionlog.Log;
|
||||||
|
import me.lucko.luckperms.common.api.ApiUtils;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
@@ -34,8 +35,6 @@ import java.util.Objects;
|
|||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static me.lucko.luckperms.common.api.ApiUtils.checkName;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class ApiLog implements me.lucko.luckperms.api.Log {
|
public class ApiLog implements me.lucko.luckperms.api.Log {
|
||||||
private final Log handle;
|
private final Log handle;
|
||||||
@@ -64,12 +63,12 @@ public class ApiLog implements me.lucko.luckperms.api.Log {
|
|||||||
@Override
|
@Override
|
||||||
public @NonNull SortedSet<LogEntry> getGroupHistory(@NonNull String name) {
|
public @NonNull SortedSet<LogEntry> getGroupHistory(@NonNull String name) {
|
||||||
Objects.requireNonNull(name, "name");
|
Objects.requireNonNull(name, "name");
|
||||||
return (SortedSet) this.handle.getGroupHistory(checkName(name));
|
return (SortedSet) this.handle.getGroupHistory(ApiUtils.checkName(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull SortedSet<LogEntry> getTrackHistory(@NonNull String name) {
|
public @NonNull SortedSet<LogEntry> getTrackHistory(@NonNull String name) {
|
||||||
Objects.requireNonNull(name, "name");
|
Objects.requireNonNull(name, "name");
|
||||||
return (SortedSet) this.handle.getTrackHistory(checkName(name));
|
return (SortedSet) this.handle.getTrackHistory(ApiUtils.checkName(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-2
@@ -23,11 +23,10 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.api.delegates.misc;
|
package me.lucko.luckperms.common.api.implementation;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.MessagingService;
|
import me.lucko.luckperms.api.MessagingService;
|
||||||
import me.lucko.luckperms.api.User;
|
import me.lucko.luckperms.api.User;
|
||||||
import me.lucko.luckperms.common.api.delegates.model.ApiUser;
|
|
||||||
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
+4
-3
@@ -23,10 +23,11 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.api.delegates.misc;
|
package me.lucko.luckperms.common.api.implementation;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.metastacking.DuplicateRemovalFunction;
|
||||||
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
|
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
|
||||||
import me.lucko.luckperms.api.metastacking.MetaStackElement;
|
import me.lucko.luckperms.api.metastacking.MetaStackElement;
|
||||||
import me.lucko.luckperms.api.metastacking.MetaStackFactory;
|
import me.lucko.luckperms.api.metastacking.MetaStackFactory;
|
||||||
@@ -63,7 +64,7 @@ public class ApiMetaStackFactory implements MetaStackFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull MetaStackDefinition createDefinition(@NonNull List<MetaStackElement> elements, @NonNull String startSpacer, @NonNull String middleSpacer, @NonNull String endSpacer) {
|
public @NonNull MetaStackDefinition createDefinition(@NonNull List<MetaStackElement> elements, @NonNull DuplicateRemovalFunction duplicateRemovalFunction, @NonNull String startSpacer, @NonNull String middleSpacer, @NonNull String endSpacer) {
|
||||||
return new SimpleMetaStackDefinition(elements, startSpacer, middleSpacer, endSpacer);
|
return new SimpleMetaStackDefinition(elements, duplicateRemovalFunction, startSpacer, middleSpacer, endSpacer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-2
@@ -23,12 +23,11 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.api.delegates.misc;
|
package me.lucko.luckperms.common.api.implementation;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.ChatMetaType;
|
import me.lucko.luckperms.api.ChatMetaType;
|
||||||
import me.lucko.luckperms.api.Group;
|
import me.lucko.luckperms.api.Group;
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.api.delegates.model.ApiGroup;
|
|
||||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
+6
-5
@@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.api.delegates.model;
|
package me.lucko.luckperms.common.api.implementation;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
@@ -44,6 +44,7 @@ import me.lucko.luckperms.api.caching.CachedData;
|
|||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.model.NodeMapType;
|
import me.lucko.luckperms.common.model.NodeMapType;
|
||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
@@ -51,7 +52,7 @@ import me.lucko.luckperms.common.node.comparator.NodeWithContextComparator;
|
|||||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.node.utils.MetaType;
|
import me.lucko.luckperms.common.node.utils.MetaType;
|
||||||
import me.lucko.luckperms.common.node.utils.NodeTools;
|
import me.lucko.luckperms.common.node.utils.NodeTools;
|
||||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
@@ -217,7 +218,7 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
|||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
|
|
||||||
Group g = ApiGroup.cast(group);
|
Group g = ApiGroup.cast(group);
|
||||||
if (this.handle.getType().isGroup() && g.getName().equals(this.handle.getObjectName())) {
|
if (this.handle.getType() == HolderType.GROUP && g.getName().equals(this.handle.getObjectName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +231,7 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
|||||||
Objects.requireNonNull(contextSet, "contextSet");
|
Objects.requireNonNull(contextSet, "contextSet");
|
||||||
|
|
||||||
Group g = ApiGroup.cast(group);
|
Group g = ApiGroup.cast(group);
|
||||||
if (this.handle.getType().isGroup() && g.getName().equals(this.handle.getObjectName())) {
|
if (this.handle.getType() == HolderType.GROUP && g.getName().equals(this.handle.getObjectName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +280,7 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol
|
|||||||
public void clearMatching(@NonNull Predicate<Node> test) {
|
public void clearMatching(@NonNull Predicate<Node> test) {
|
||||||
Objects.requireNonNull(test, "test");
|
Objects.requireNonNull(test, "test");
|
||||||
this.handle.removeIf(test);
|
this.handle.removeIf(test);
|
||||||
if (this.handle.getType().isUser()) {
|
if (this.handle.getType() == HolderType.USER) {
|
||||||
this.handle.getPlugin().getUserManager().giveDefaultIfNeeded((User) this.handle, false);
|
this.handle.getPlugin().getUserManager().giveDefaultIfNeeded((User) this.handle, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loaded 100 of 509 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user