mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2026-11-24 08:14:25 +00:00
More work
This commit is contained in:
123 files changed
+680
-1098
No files matched your search
@@ -263,16 +263,16 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Player> getPlayer(UUID uuid) {
|
||||
public Optional<Player> getPlayer(UUID uniqueId) {
|
||||
if (!getGame().isServerAvailable()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
return getGame().getServer().getPlayer(uuid);
|
||||
return getGame().getServer().getPlayer(uniqueId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<UUID> lookupUuid(String username) {
|
||||
public Optional<UUID> lookupUniqueId(String username) {
|
||||
if (!getGame().isServerAvailable()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
@@ -284,12 +284,12 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> lookupUsername(UUID uuid) {
|
||||
public Optional<String> lookupUsername(UUID uniqueId) {
|
||||
if (!getGame().isServerAvailable()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
return getGame().getServer().getGameProfileManager().get(uuid)
|
||||
return getGame().getServer().getGameProfileManager().get(uniqueId)
|
||||
.thenApply(GameProfile::getName)
|
||||
.exceptionally(x -> Optional.empty())
|
||||
.join();
|
||||
@@ -311,8 +311,8 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerOnline(UUID uuid) {
|
||||
return getGame().isServerAvailable() ? getGame().getServer().getPlayer(uuid).map(Player::isOnline).orElse(false) : false;
|
||||
public boolean isPlayerOnline(UUID uniqueId) {
|
||||
return getGame().isServerAvailable() ? getGame().getServer().getPlayer(uniqueId).map(Player::isOnline).orElse(false) : false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -251,7 +251,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin {
|
||||
|
||||
@Override
|
||||
public Optional<QueryOptions> getQueryOptionsForUser(User user) {
|
||||
return this.bootstrap.getPlayer(user.getUuid()).map(player -> this.contextManager.getQueryOptions(player));
|
||||
return this.bootstrap.getPlayer(user.getUniqueId()).map(player -> this.contextManager.getQueryOptions(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -54,7 +54,7 @@ public class SpongeSenderFactory extends SenderFactory<CommandSource> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UUID getUuid(CommandSource source) {
|
||||
protected UUID getUniqueId(CommandSource source) {
|
||||
if (source instanceof Player) {
|
||||
return ((Player) source).getUniqueId();
|
||||
}
|
||||
|
||||
@@ -38,20 +38,14 @@ import java.util.UUID;
|
||||
public class SpongeUser extends User implements SpongePermissionHolder {
|
||||
private final UserSubject spongeData;
|
||||
|
||||
public SpongeUser(UUID uuid, LPSpongePlugin plugin) {
|
||||
super(uuid, plugin);
|
||||
this.spongeData = new UserSubject(plugin, this);
|
||||
}
|
||||
|
||||
public SpongeUser(UUID uuid, String name, LPSpongePlugin plugin) {
|
||||
super(uuid, name, plugin);
|
||||
public SpongeUser(UUID uniqueId, LPSpongePlugin plugin) {
|
||||
super(uniqueId, plugin);
|
||||
this.spongeData = new UserSubject(plugin, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void invalidateCache() {
|
||||
super.invalidateCache();
|
||||
|
||||
this.spongeData.fireUpdateEvent();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ import com.google.common.collect.Maps;
|
||||
import me.lucko.luckperms.common.bulkupdate.comparison.Constraint;
|
||||
import me.lucko.luckperms.common.bulkupdate.comparison.StandardComparison;
|
||||
import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl;
|
||||
import me.lucko.luckperms.common.model.UserIdentifier;
|
||||
import me.lucko.luckperms.common.model.manager.user.AbstractUserManager;
|
||||
import me.lucko.luckperms.common.model.manager.user.UserHousekeeper;
|
||||
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
||||
@@ -105,10 +104,8 @@ public class SpongeUserManager extends AbstractUserManager<SpongeUser> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpongeUser apply(UserIdentifier id) {
|
||||
return !id.getUsername().isPresent() ?
|
||||
new SpongeUser(id.getUuid(), this.plugin) :
|
||||
new SpongeUser(id.getUuid(), id.getUsername().get(), this.plugin);
|
||||
public SpongeUser apply(UUID id) {
|
||||
return new SpongeUser(id, this.plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,7 +167,7 @@ public class SpongeUserManager extends AbstractUserManager<SpongeUser> implement
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
|
||||
if (isLoaded(UserIdentifier.of(uuid, null))) {
|
||||
if (isLoaded(uuid)) {
|
||||
return CompletableFuture.completedFuture(true);
|
||||
}
|
||||
|
||||
@@ -203,7 +200,7 @@ public class SpongeUserManager extends AbstractUserManager<SpongeUser> implement
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
ImmutableSet.Builder<String> ids = ImmutableSet.builder();
|
||||
|
||||
getAll().keySet().forEach(uuid -> ids.add(uuid.getUuid().toString()));
|
||||
getAll().keySet().forEach(uuid -> ids.add(uuid.toString()));
|
||||
this.plugin.getStorage().getUniqueUsers().join().forEach(uuid -> ids.add(uuid.toString()));
|
||||
|
||||
return ids.build();
|
||||
|
||||
+20
-24
@@ -131,20 +131,20 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
if (tristate == Tristate.UNDEFINED) {
|
||||
// Unset
|
||||
Node node = NodeBuilders.determineMostApplicable(permission).withContext(contexts).build();
|
||||
this.holder.unsetPermission(this.type, node);
|
||||
this.holder.unsetNode(this.type, node);
|
||||
return save(this.holder).thenApply(v -> true);
|
||||
}
|
||||
|
||||
Node node = NodeBuilders.determineMostApplicable(permission).value(tristate.asBoolean()).withContext(contexts).build();
|
||||
// unset the inverse, to allow false -> true, true -> false overrides.
|
||||
this.holder.unsetPermission(this.type, node);
|
||||
this.holder.setPermission(this.type, node, true);
|
||||
this.holder.unsetNode(this.type, node);
|
||||
this.holder.setNode(this.type, node, true);
|
||||
return save(this.holder).thenApply(v -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> clearPermissions() {
|
||||
if (!this.holder.clearNodes(this.type, null)) {
|
||||
if (!this.holder.clearNodes(this.type, null, false)) {
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
@Override
|
||||
public CompletableFuture<Boolean> clearPermissions(ImmutableContextSet contexts) {
|
||||
Objects.requireNonNull(contexts, "contexts");
|
||||
if (!this.holder.clearNodes(this.type, contexts)) {
|
||||
if (!this.holder.clearNodes(this.type, contexts, false)) {
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
|
||||
@@ -172,12 +172,10 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
@Override
|
||||
public ImmutableMap<ImmutableContextSet, ImmutableList<LPSubjectReference>> getAllParents() {
|
||||
ImmutableMap.Builder<ImmutableContextSet, ImmutableList<LPSubjectReference>> ret = ImmutableMap.builder();
|
||||
for (Map.Entry<ImmutableContextSet, ? extends Collection<? extends Node>> entry : this.holder.getData(this.type).immutable().asMap().entrySet()) {
|
||||
for (Map.Entry<ImmutableContextSet, ? extends Collection<? extends InheritanceNode>> entry : this.holder.getData(this.type).immutableInheritance().asMap().entrySet()) {
|
||||
ImmutableList.Builder<LPSubjectReference> builder = ImmutableList.builder();
|
||||
for (Node n : entry.getValue()) {
|
||||
if (n instanceof InheritanceNode) {
|
||||
builder.add(this.service.getGroupSubjects().loadSubject(((InheritanceNode) n).getGroupName()).join().toReference());
|
||||
}
|
||||
for (InheritanceNode n : entry.getValue()) {
|
||||
builder.add(this.service.getGroupSubjects().loadSubject(n.getGroupName()).join().toReference());
|
||||
}
|
||||
ret.put(entry.getKey(), builder.build());
|
||||
}
|
||||
@@ -187,10 +185,8 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
@Override
|
||||
public ImmutableList<LPSubjectReference> getParents(ImmutableContextSet contexts) {
|
||||
ImmutableList.Builder<LPSubjectReference> builder = ImmutableList.builder();
|
||||
for (Node n : this.holder.getData(this.type).immutable().get(contexts)) {
|
||||
if (n instanceof InheritanceNode) {
|
||||
builder.add(this.service.getGroupSubjects().loadSubject(((InheritanceNode) n).getGroupName()).join().toReference());
|
||||
}
|
||||
for (InheritanceNode n : this.holder.getData(this.type).immutableInheritance().get(contexts)) {
|
||||
builder.add(this.service.getGroupSubjects().loadSubject(n.getGroupName()).join().toReference());
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
@@ -208,7 +204,7 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
.withContext(contexts)
|
||||
.build();
|
||||
|
||||
if (!this.holder.setPermission(this.type, node, true).wasSuccessful()) {
|
||||
if (!this.holder.setNode(this.type, node, true).wasSuccessful()) {
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
|
||||
@@ -228,7 +224,7 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
.withContext(contexts)
|
||||
.build();
|
||||
|
||||
if (!this.holder.unsetPermission(this.type, node).wasSuccessful()) {
|
||||
if (!this.holder.unsetNode(this.type, node).wasSuccessful()) {
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
|
||||
@@ -245,7 +241,7 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
case TRANSIENT:
|
||||
ret = streamNodes()
|
||||
.filter(n -> n instanceof InheritanceNode)
|
||||
.peek(n -> this.holder.unsetPermission(DataType.TRANSIENT, n))
|
||||
.peek(n -> this.holder.unsetNode(DataType.TRANSIENT, n))
|
||||
.findAny().isPresent();
|
||||
break;
|
||||
default:
|
||||
@@ -271,7 +267,7 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
ret = streamNodes()
|
||||
.filter(n -> n instanceof InheritanceNode)
|
||||
.filter(n -> n.getContexts().equals(contexts))
|
||||
.peek(n -> this.holder.unsetPermission(DataType.TRANSIENT, n))
|
||||
.peek(n -> this.holder.unsetNode(DataType.TRANSIENT, n))
|
||||
.findAny().isPresent();
|
||||
break;
|
||||
default:
|
||||
@@ -350,7 +346,7 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
streamNodes()
|
||||
.filter(n -> type.nodeType().matches(n))
|
||||
.filter(n -> n.getContexts().equals(contexts))
|
||||
.forEach(n -> this.holder.unsetPermission(this.type, n));
|
||||
.forEach(n -> this.holder.unsetNode(this.type, n));
|
||||
|
||||
MetaAccumulator metaAccumulator = this.holder.accumulateMeta(null, QueryOptions.defaultContextualOptions().toBuilder().context(contexts).build());
|
||||
metaAccumulator.complete();
|
||||
@@ -364,12 +360,12 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
streamNodes()
|
||||
.filter(n -> n instanceof MetaNode && ((MetaNode) n).getMetaKey().equals(key))
|
||||
.filter(n -> n.getContexts().equals(contexts))
|
||||
.forEach(n -> this.holder.unsetPermission(this.type, n));
|
||||
.forEach(n -> this.holder.unsetNode(this.type, n));
|
||||
|
||||
node = Meta.builder(key, value).withContext(contexts).build();
|
||||
}
|
||||
|
||||
this.holder.setPermission(this.type, node, true);
|
||||
this.holder.setNode(this.type, node, true);
|
||||
return save(this.holder).thenApply(v -> true);
|
||||
}
|
||||
|
||||
@@ -389,7 +385,7 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
}
|
||||
})
|
||||
.filter(n -> n.getContexts().equals(contexts))
|
||||
.forEach(n -> this.holder.unsetPermission(this.type, n));
|
||||
.forEach(n -> this.holder.unsetNode(this.type, n));
|
||||
|
||||
return save(this.holder).thenApply(v -> true);
|
||||
}
|
||||
@@ -401,7 +397,7 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
boolean success = streamNodes()
|
||||
.filter(NodeType.META_OR_CHAT_META::matches)
|
||||
.filter(n -> n.getContexts().equals(contexts))
|
||||
.peek(n -> this.holder.unsetPermission(this.type, n))
|
||||
.peek(n -> this.holder.unsetNode(this.type, n))
|
||||
.findAny().isPresent();
|
||||
|
||||
if (!success) {
|
||||
@@ -415,7 +411,7 @@ public class PermissionHolderSubjectData implements LPSubjectData {
|
||||
public CompletableFuture<Boolean> clearOptions() {
|
||||
boolean success = streamNodes()
|
||||
.filter(NodeType.META_OR_CHAT_META::matches)
|
||||
.peek(n -> this.holder.unsetPermission(this.type, n))
|
||||
.peek(n -> this.holder.unsetNode(this.type, n))
|
||||
.findAny().isPresent();
|
||||
|
||||
if (!success) {
|
||||
|
||||
+3
-3
@@ -47,17 +47,17 @@ public final class UserSubject extends PermissionHolderSubject<SpongeUser> imple
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.parent.getUuid().toString();
|
||||
return this.parent.getUniqueId().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> getFriendlyIdentifier() {
|
||||
return this.parent.getName();
|
||||
return this.parent.getUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<CommandSource> getCommandSource() {
|
||||
final UUID uuid = this.parent.getUuid();
|
||||
final UUID uuid = this.parent.getUniqueId();
|
||||
return Sponge.getServer().getPlayer(uuid).map(Function.identity());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user