Fix Sponge implementation, remove standalone module
This commit is contained in:
parent
83d9229295
commit
60e6ae6e23
1
pom.xml
1
pom.xml
@ -10,7 +10,6 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>common</module>
|
<module>common</module>
|
||||||
<module>api</module>
|
<module>api</module>
|
||||||
<module>standalone</module>
|
|
||||||
<module>bukkit</module>
|
<module>bukkit</module>
|
||||||
<module>bukkit-legacy</module>
|
<module>bukkit-legacy</module>
|
||||||
<module>bukkit-placeholders</module>
|
<module>bukkit-placeholders</module>
|
||||||
|
@ -24,10 +24,12 @@ package me.lucko.luckperms;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.LuckPermsApi;
|
import me.lucko.luckperms.api.LuckPermsApi;
|
||||||
import me.lucko.luckperms.api.PlatformType;
|
import me.lucko.luckperms.api.PlatformType;
|
||||||
import me.lucko.luckperms.api.implementation.ApiProvider;
|
import me.lucko.luckperms.api.implementation.ApiProvider;
|
||||||
import me.lucko.luckperms.api.sponge.LuckPermsService;
|
import me.lucko.luckperms.api.sponge.LuckPermsService;
|
||||||
|
import me.lucko.luckperms.calculators.CalculatorFactory;
|
||||||
import me.lucko.luckperms.commands.ConsecutiveExecutor;
|
import me.lucko.luckperms.commands.ConsecutiveExecutor;
|
||||||
import me.lucko.luckperms.commands.Sender;
|
import me.lucko.luckperms.commands.Sender;
|
||||||
import me.lucko.luckperms.config.LPConfiguration;
|
import me.lucko.luckperms.config.LPConfiguration;
|
||||||
@ -44,7 +46,6 @@ import me.lucko.luckperms.runnables.UpdateTask;
|
|||||||
import me.lucko.luckperms.storage.Datastore;
|
import me.lucko.luckperms.storage.Datastore;
|
||||||
import me.lucko.luckperms.storage.StorageFactory;
|
import me.lucko.luckperms.storage.StorageFactory;
|
||||||
import me.lucko.luckperms.tracks.TrackManager;
|
import me.lucko.luckperms.tracks.TrackManager;
|
||||||
import me.lucko.luckperms.users.SpongeUserManager;
|
|
||||||
import me.lucko.luckperms.users.UserManager;
|
import me.lucko.luckperms.users.UserManager;
|
||||||
import me.lucko.luckperms.utils.LocaleManager;
|
import me.lucko.luckperms.utils.LocaleManager;
|
||||||
import me.lucko.luckperms.utils.LogFactory;
|
import me.lucko.luckperms.utils.LogFactory;
|
||||||
@ -101,6 +102,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
private LuckPermsService service;
|
private LuckPermsService service;
|
||||||
private LocaleManager localeManager;
|
private LocaleManager localeManager;
|
||||||
private ContextManager<Player> contextManager; // TODO convert this to use Subject instead of Player
|
private ContextManager<Player> contextManager; // TODO convert this to use Subject instead of Player
|
||||||
|
private CalculatorFactory calculatorFactory;
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onEnable(GamePreInitializationEvent event) {
|
public void onEnable(GamePreInitializationEvent event) {
|
||||||
@ -138,6 +140,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
trackManager = new TrackManager();
|
trackManager = new TrackManager();
|
||||||
importer = new Importer(commandManager);
|
importer = new Importer(commandManager);
|
||||||
consecutiveExecutor = new ConsecutiveExecutor(commandManager);
|
consecutiveExecutor = new ConsecutiveExecutor(commandManager);
|
||||||
|
calculatorFactory = new SpongeCalculatorFactory(this);
|
||||||
|
|
||||||
contextManager = new ContextManager<>();
|
contextManager = new ContextManager<>();
|
||||||
contextManager.registerCalculator(new ServerCalculator<>(getConfiguration().getServer()));
|
contextManager.registerCalculator(new ServerCalculator<>(getConfiguration().getServer()));
|
||||||
@ -250,6 +253,11 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
return SpongeSenderFactory.get(this).wrap(game.getServer().getConsole());
|
return SpongeSenderFactory.get(this).wrap(game.getServer().getConsole());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Contexts> getPreProcessContexts(boolean op) {
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getPlugin(String name) {
|
public Object getPlugin(String name) {
|
||||||
return game.getPluginManager().getPlugin(name).get().getInstance().get();
|
return game.getPluginManager().getPlugin(name).get().getInstance().get();
|
||||||
|
@ -20,38 +20,35 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.internal;
|
package me.lucko.luckperms;
|
||||||
|
|
||||||
import me.lucko.luckperms.config.AbstractConfiguration;
|
import lombok.AllArgsConstructor;
|
||||||
|
import me.lucko.luckperms.api.Contexts;
|
||||||
|
import me.lucko.luckperms.api.sponge.LuckPermsService;
|
||||||
|
import me.lucko.luckperms.calculators.*;
|
||||||
|
import me.lucko.luckperms.users.User;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class StandaloneConfiguration extends AbstractConfiguration<StandaloneBase> {
|
@AllArgsConstructor
|
||||||
public StandaloneConfiguration(StandaloneBase plugin) {
|
public class SpongeCalculatorFactory implements CalculatorFactory {
|
||||||
super(plugin, "global", true, "null");
|
private final LPSpongePlugin plugin;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
public PermissionCalculator build(Contexts contexts, User user, Map<String, Boolean> map) {
|
||||||
}
|
List<PermissionProcessor> processors = new ArrayList<>(5);
|
||||||
|
processors.add(new MapProcessor(map));
|
||||||
|
if (plugin.getConfiguration().isApplyingWildcards()) {
|
||||||
|
processors.add(new SpongeWildcardProcessor(map));
|
||||||
|
processors.add(new WildcardProcessor(map));
|
||||||
|
}
|
||||||
|
if (plugin.getConfiguration().isApplyingRegex()) {
|
||||||
|
processors.add(new RegexProcessor(map));
|
||||||
|
}
|
||||||
|
processors.add(new DefaultsProcessor(plugin.getService(), LuckPermsService.convertContexts(contexts.getContext())));
|
||||||
|
|
||||||
@Override
|
return new PermissionCalculator(plugin, user.getName(), plugin.getConfiguration().isDebugPermissionChecks(), processors);
|
||||||
protected String getString(String path, String def) {
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getInt(String path, int def) {
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean getBoolean(String path, boolean def) {
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Map<String, String> getMap(String path, Map<String, String> def) {
|
|
||||||
return def;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,13 +22,23 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms;
|
package me.lucko.luckperms;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.sponge.LuckPermsService;
|
||||||
|
import me.lucko.luckperms.caching.UserData;
|
||||||
import me.lucko.luckperms.constants.Message;
|
import me.lucko.luckperms.constants.Message;
|
||||||
import me.lucko.luckperms.users.User;
|
import me.lucko.luckperms.users.User;
|
||||||
import me.lucko.luckperms.utils.AbstractListener;
|
import me.lucko.luckperms.utils.AbstractListener;
|
||||||
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
import org.spongepowered.api.event.Listener;
|
import org.spongepowered.api.event.Listener;
|
||||||
import org.spongepowered.api.event.network.ClientConnectionEvent;
|
import org.spongepowered.api.event.network.ClientConnectionEvent;
|
||||||
import org.spongepowered.api.profile.GameProfile;
|
import org.spongepowered.api.profile.GameProfile;
|
||||||
import org.spongepowered.api.text.serializer.TextSerializers;
|
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||||
|
import org.spongepowered.api.world.World;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
public class SpongeListener extends AbstractListener {
|
public class SpongeListener extends AbstractListener {
|
||||||
@ -49,7 +59,6 @@ public class SpongeListener extends AbstractListener {
|
|||||||
|
|
||||||
final GameProfile p = e.getProfile();
|
final GameProfile p = e.getProfile();
|
||||||
onAsyncLogin(p.getUniqueId(), p.getName().get()); // Load the user into LuckPerms
|
onAsyncLogin(p.getUniqueId(), p.getName().get()); // Load the user into LuckPerms
|
||||||
plugin.getService().getUserSubjects().load(p.getUniqueId()); // Load the user into the PermissionService
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@ -65,8 +74,26 @@ public class SpongeListener extends AbstractListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh permissions again
|
// Attempt to pre-process some permissions for the user to save time later. Might not work, but it's better than nothing.
|
||||||
plugin.doAsync(user::refreshPermissions);
|
Optional<Player> p = e.getCause().first(Player.class);
|
||||||
|
if (p.isPresent()) {
|
||||||
|
Map<String, String> context = plugin.getContextManager().giveApplicableContext(p.get(), new HashMap<>());
|
||||||
|
|
||||||
|
List<String> worlds = plugin.getGame().getServer().getWorlds().stream()
|
||||||
|
.map(World::getName)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
plugin.doAsync(() -> {
|
||||||
|
UserData data = user.getUserData();
|
||||||
|
data.preCalculate(plugin.getService().calculateContexts(LuckPermsService.convertContexts(context)));
|
||||||
|
|
||||||
|
for (String world : worlds) {
|
||||||
|
Map<String, String> modified = new HashMap<>(context);
|
||||||
|
modified.put("world", world);
|
||||||
|
data.preCalculate(plugin.getService().calculateContexts(LuckPermsService.convertContexts(modified)));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
@ -78,5 +105,6 @@ public class SpongeListener extends AbstractListener {
|
|||||||
@Listener
|
@Listener
|
||||||
public void onClientLeave(ClientConnectionEvent.Disconnect e) {
|
public void onClientLeave(ClientConnectionEvent.Disconnect e) {
|
||||||
onLeave(e.getTargetEntity().getUniqueId());
|
onLeave(e.getTargetEntity().getUniqueId());
|
||||||
|
plugin.getService().getUserSubjects().unload(plugin.getUuidCache().getUUID(e.getTargetEntity().getUniqueId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,18 +26,21 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.LocalizedNode;
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.core.PermissionHolder;
|
|
||||||
import me.lucko.luckperms.groups.Group;
|
import me.lucko.luckperms.groups.Group;
|
||||||
import org.spongepowered.api.command.CommandSource;
|
import org.spongepowered.api.command.CommandSource;
|
||||||
import org.spongepowered.api.service.context.Context;
|
import org.spongepowered.api.service.context.Context;
|
||||||
|
import org.spongepowered.api.service.permission.NodeTree;
|
||||||
import org.spongepowered.api.service.permission.Subject;
|
import org.spongepowered.api.service.permission.Subject;
|
||||||
import org.spongepowered.api.service.permission.SubjectCollection;
|
import org.spongepowered.api.service.permission.SubjectCollection;
|
||||||
import org.spongepowered.api.service.permission.SubjectData;
|
import org.spongepowered.api.service.permission.SubjectData;
|
||||||
import org.spongepowered.api.util.Tristate;
|
import org.spongepowered.api.util.Tristate;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static me.lucko.luckperms.utils.ArgumentChecker.unescapeCharacters;
|
import static me.lucko.luckperms.utils.ArgumentChecker.unescapeCharacters;
|
||||||
@ -49,7 +52,7 @@ public class LuckPermsGroupSubject implements Subject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private PermissionHolder group;
|
private Group group;
|
||||||
|
|
||||||
private LuckPermsService service;
|
private LuckPermsService service;
|
||||||
|
|
||||||
@ -59,7 +62,7 @@ public class LuckPermsGroupSubject implements Subject {
|
|||||||
@Getter
|
@Getter
|
||||||
private LuckPermsSubjectData transientSubjectData;
|
private LuckPermsSubjectData transientSubjectData;
|
||||||
|
|
||||||
private LuckPermsGroupSubject(PermissionHolder group, LuckPermsService service) {
|
private LuckPermsGroupSubject(Group group, LuckPermsService service) {
|
||||||
this.group = group;
|
this.group = group;
|
||||||
this.subjectData = new LuckPermsSubjectData(true, service, group);
|
this.subjectData = new LuckPermsSubjectData(true, service, group);
|
||||||
this.transientSubjectData = new LuckPermsSubjectData(false, service, group);
|
this.transientSubjectData = new LuckPermsSubjectData(false, service, group);
|
||||||
@ -88,23 +91,22 @@ public class LuckPermsGroupSubject implements Subject {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Tristate getPermissionValue(@NonNull Set<Context> contexts, @NonNull String node) {
|
public Tristate getPermissionValue(@NonNull Set<Context> contexts, @NonNull String node) {
|
||||||
Map<String, String> context = new HashMap<>();
|
Map<String, Boolean> permissions = group.getAllNodesFiltered(service.calculateContexts(contexts)).stream()
|
||||||
for (Context c : contexts) {
|
.map(LocalizedNode::getNode)
|
||||||
context.put(c.getKey(), c.getValue());
|
.collect(Collectors.toMap(Node::getPermission, Node::getValue));
|
||||||
|
|
||||||
|
Tristate t = NodeTree.of(permissions).get(node);
|
||||||
|
if (t != Tristate.UNDEFINED) {
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (group.inheritsPermission(new me.lucko.luckperms.core.Node.Builder(node).withExtraContext(context).build())) {
|
t = service.getGroupSubjects().getDefaults().getPermissionValue(contexts, node);
|
||||||
case UNDEFINED:
|
if (t != Tristate.UNDEFINED) {
|
||||||
return Tristate.UNDEFINED;
|
return t;
|
||||||
case TRUE:
|
|
||||||
return Tristate.TRUE;
|
|
||||||
case FALSE:
|
|
||||||
return Tristate.FALSE;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
t = service.getDefaults().getPermissionValue(contexts, node);
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -114,39 +116,42 @@ public class LuckPermsGroupSubject implements Subject {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Subject> getParents(@NonNull Set<Context> contexts) {
|
public List<Subject> getParents(@NonNull Set<Context> contexts) {
|
||||||
List<Subject> parents = new ArrayList<>();
|
List<Subject> subjects = group.getAllNodesFiltered(service.calculateContexts(contexts)).stream()
|
||||||
parents.addAll(subjectData.getParents(contexts));
|
.map(LocalizedNode::getNode)
|
||||||
parents.addAll(transientSubjectData.getParents(contexts));
|
.filter(Node::isGroupNode)
|
||||||
return ImmutableList.copyOf(parents);
|
.map(Node::getGroupName)
|
||||||
|
.map(s -> service.getGroupSubjects().get(s))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
subjects.addAll(service.getGroupSubjects().getDefaults().getParents(contexts));
|
||||||
|
subjects.addAll(service.getDefaults().getParents(contexts));
|
||||||
|
|
||||||
|
return ImmutableList.copyOf(subjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<String> getOption(Set<Context> set, String s) {
|
public Optional<String> getOption(Set<Context> set, String s) {
|
||||||
|
Optional<String> option;
|
||||||
if (s.equalsIgnoreCase("prefix")) {
|
if (s.equalsIgnoreCase("prefix")) {
|
||||||
String prefix = getChatMeta(set, true, group);
|
option = getChatMeta(set, true);
|
||||||
if (!prefix.equals("")) {
|
|
||||||
return Optional.of(prefix);
|
} else if (s.equalsIgnoreCase("suffix")) {
|
||||||
}
|
option = getChatMeta(set, false);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
option = getMeta(set, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.equalsIgnoreCase("suffix")) {
|
if (option.isPresent()) {
|
||||||
String suffix = getChatMeta(set, false, group);
|
return option;
|
||||||
if (!suffix.equals("")) {
|
|
||||||
return Optional.of(suffix);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> transientOptions = subjectData.getOptions(set);
|
option = service.getGroupSubjects().getDefaults().getOption(set, s);
|
||||||
if (transientOptions.containsKey(s)) {
|
if (option.isPresent()) {
|
||||||
return Optional.of(transientOptions.get(s));
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> enduringOptions = subjectData.getOptions(set);
|
return service.getDefaults().getOption(set, s);
|
||||||
if (enduringOptions.containsKey(s)) {
|
|
||||||
return Optional.of(enduringOptions.get(s));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -154,19 +159,11 @@ public class LuckPermsGroupSubject implements Subject {
|
|||||||
return SubjectData.GLOBAL_CONTEXT;
|
return SubjectData.GLOBAL_CONTEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getChatMeta(Set<Context> contexts, boolean prefix, PermissionHolder holder) {
|
private Optional<String> getChatMeta(Set<Context> contexts, boolean prefix) {
|
||||||
if (holder == null) return "";
|
|
||||||
|
|
||||||
Map<String, String> context = contexts.stream().collect(Collectors.toMap(Context::getKey, Context::getValue));
|
|
||||||
String server = context.get("server");
|
|
||||||
String world = context.get("world");
|
|
||||||
context.remove("server");
|
|
||||||
context.remove("world");
|
|
||||||
|
|
||||||
int priority = Integer.MIN_VALUE;
|
int priority = Integer.MIN_VALUE;
|
||||||
String meta = null;
|
String meta = null;
|
||||||
|
|
||||||
for (Node n : holder.getAllNodes(null, Contexts.allowAll())) {
|
for (Node n : group.getAllNodesFiltered(service.calculateContexts(contexts))) {
|
||||||
if (!n.getValue()) {
|
if (!n.getValue()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -175,18 +172,6 @@ public class LuckPermsGroupSubject implements Subject {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!n.shouldApplyOnServer(server, service.getPlugin().getConfiguration().isVaultIncludingGlobal(), false)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!n.shouldApplyOnWorld(world, true, false)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!n.shouldApplyWithContext(context, false)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map.Entry<Integer, String> value = prefix ? n.getPrefix() : n.getSuffix();
|
Map.Entry<Integer, String> value = prefix ? n.getPrefix() : n.getSuffix();
|
||||||
if (value.getKey() > priority) {
|
if (value.getKey() > priority) {
|
||||||
meta = value.getValue();
|
meta = value.getValue();
|
||||||
@ -194,6 +179,27 @@ public class LuckPermsGroupSubject implements Subject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return meta == null ? "" : unescapeCharacters(meta);
|
return meta == null ? Optional.empty() : Optional.of(unescapeCharacters(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Optional<String> getMeta(Set<Context> contexts, String key) {
|
||||||
|
for (Node n : group.getAllNodesFiltered(service.calculateContexts(contexts))) {
|
||||||
|
if (!n.getValue()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!n.isMeta()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map.Entry<String, String> m = n.getMeta();
|
||||||
|
if (!m.getKey().equalsIgnoreCase(key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Optional.of(m.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import me.lucko.luckperms.LPSpongePlugin;
|
import me.lucko.luckperms.LPSpongePlugin;
|
||||||
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.sponge.collections.GroupCollection;
|
import me.lucko.luckperms.api.sponge.collections.GroupCollection;
|
||||||
import me.lucko.luckperms.api.sponge.collections.UserCollection;
|
import me.lucko.luckperms.api.sponge.collections.UserCollection;
|
||||||
import me.lucko.luckperms.api.sponge.simple.SimpleCollection;
|
import me.lucko.luckperms.api.sponge.simple.SimpleCollection;
|
||||||
@ -142,6 +143,17 @@ public class LuckPermsService implements PermissionService {
|
|||||||
plugin.getContextManager().registerCalculator(new SpongeCalculatorLink(contextCalculator));
|
plugin.getContextManager().registerCalculator(new SpongeCalculatorLink(contextCalculator));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Contexts calculateContexts(Set<Context> contexts) {
|
||||||
|
return new Contexts(
|
||||||
|
LuckPermsService.convertContexts(contexts),
|
||||||
|
plugin.getConfiguration().isIncludingGlobalPerms(),
|
||||||
|
plugin.getConfiguration().isIncludingGlobalWorldPerms(),
|
||||||
|
true,
|
||||||
|
plugin.getConfiguration().isApplyingGlobalGroups(),
|
||||||
|
plugin.getConfiguration().isApplyingGlobalWorldGroups()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static Map<String, String> convertContexts(Set<Context> contexts) {
|
public static Map<String, String> convertContexts(Set<Context> contexts) {
|
||||||
return contexts.stream().collect(Collectors.toMap(Context::getKey, Context::getValue));
|
return contexts.stream().collect(Collectors.toMap(Context::getKey, Context::getValue));
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,10 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api.sponge;
|
package me.lucko.luckperms.api.sponge;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import me.lucko.luckperms.api.Contexts;
|
|
||||||
import me.lucko.luckperms.caching.MetaData;
|
import me.lucko.luckperms.caching.MetaData;
|
||||||
import me.lucko.luckperms.users.User;
|
import me.lucko.luckperms.users.User;
|
||||||
import org.spongepowered.api.Sponge;
|
import org.spongepowered.api.Sponge;
|
||||||
@ -73,17 +73,6 @@ public class LuckPermsUserSubject implements Subject {
|
|||||||
transientSubjectData = null;
|
transientSubjectData = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Contexts calculateContexts(Set<Context> contexts) {
|
|
||||||
return new Contexts(
|
|
||||||
LuckPermsService.convertContexts(contexts),
|
|
||||||
service.getPlugin().getConfiguration().isIncludingGlobalPerms(),
|
|
||||||
service.getPlugin().getConfiguration().isIncludingGlobalWorldPerms(),
|
|
||||||
true,
|
|
||||||
service.getPlugin().getConfiguration().isApplyingGlobalGroups(),
|
|
||||||
service.getPlugin().getConfiguration().isApplyingGlobalWorldGroups()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasData() {
|
private boolean hasData() {
|
||||||
return user.getUserData() != null;
|
return user.getUserData() != null;
|
||||||
}
|
}
|
||||||
@ -118,7 +107,7 @@ public class LuckPermsUserSubject implements Subject {
|
|||||||
@Override
|
@Override
|
||||||
public Tristate getPermissionValue(@NonNull Set<Context> contexts, @NonNull String permission) {
|
public Tristate getPermissionValue(@NonNull Set<Context> contexts, @NonNull String permission) {
|
||||||
if (hasData()) {
|
if (hasData()) {
|
||||||
return LuckPermsService.convertTristate(user.getUserData().getPermissionData(calculateContexts(contexts)).getPermissionValue(permission));
|
return LuckPermsService.convertTristate(user.getUserData().getPermissionData(service.calculateContexts(contexts)).getPermissionValue(permission));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Tristate.UNDEFINED;
|
return Tristate.UNDEFINED;
|
||||||
@ -131,10 +120,10 @@ public class LuckPermsUserSubject implements Subject {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Subject> getParents(Set<Context> contexts) {
|
public List<Subject> getParents(Set<Context> contexts) {
|
||||||
List<Subject> subjects = new ArrayList<>();
|
ImmutableList.Builder<Subject> subjects = ImmutableList.builder();
|
||||||
|
|
||||||
if (hasData()) {
|
if (hasData()) {
|
||||||
for (String perm : user.getUserData().getPermissionData(calculateContexts(contexts)).getImmutableBacking().keySet()) {
|
for (String perm : user.getUserData().getPermissionData(service.calculateContexts(contexts)).getImmutableBacking().keySet()) {
|
||||||
if (!perm.startsWith("group.")) {
|
if (!perm.startsWith("group.")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -149,13 +138,13 @@ public class LuckPermsUserSubject implements Subject {
|
|||||||
subjects.addAll(service.getUserSubjects().getDefaults().getParents(contexts));
|
subjects.addAll(service.getUserSubjects().getDefaults().getParents(contexts));
|
||||||
subjects.addAll(service.getDefaults().getParents(contexts));
|
subjects.addAll(service.getDefaults().getParents(contexts));
|
||||||
|
|
||||||
return subjects;
|
return subjects.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<String> getOption(Set<Context> contexts, String s) {
|
public Optional<String> getOption(Set<Context> contexts, String s) {
|
||||||
if (hasData()) {
|
if (hasData()) {
|
||||||
MetaData data = user.getUserData().getMetaData(calculateContexts(contexts));
|
MetaData data = user.getUserData().getMetaData(service.calculateContexts(contexts));
|
||||||
if (s.equalsIgnoreCase("prefix")) {
|
if (s.equalsIgnoreCase("prefix")) {
|
||||||
if (data.getPrefix() != null) {
|
if (data.getPrefix() != null) {
|
||||||
return Optional.of(data.getPrefix());
|
return Optional.of(data.getPrefix());
|
||||||
|
@ -32,6 +32,7 @@ import org.spongepowered.api.service.permission.PermissionService;
|
|||||||
import org.spongepowered.api.service.permission.Subject;
|
import org.spongepowered.api.service.permission.Subject;
|
||||||
import org.spongepowered.api.service.permission.SubjectCollection;
|
import org.spongepowered.api.service.permission.SubjectCollection;
|
||||||
import org.spongepowered.api.service.permission.SubjectData;
|
import org.spongepowered.api.service.permission.SubjectData;
|
||||||
|
import org.spongepowered.api.util.Tristate;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -83,7 +84,7 @@ public class GroupCollection implements SubjectCollection {
|
|||||||
public Map<Subject, Boolean> getAllWithPermission(@NonNull Set<Context> contexts, @NonNull String node) {
|
public Map<Subject, Boolean> getAllWithPermission(@NonNull Set<Context> contexts, @NonNull String node) {
|
||||||
return manager.getAll().values().stream()
|
return manager.getAll().values().stream()
|
||||||
.map(u -> LuckPermsGroupSubject.wrapGroup(u, service))
|
.map(u -> LuckPermsGroupSubject.wrapGroup(u, service))
|
||||||
.filter(sub -> sub.isPermissionSet(contexts, node))
|
.filter(sub -> sub.getPermissionValue(contexts, node) != Tristate.UNDEFINED)
|
||||||
.collect(Collectors.toMap(sub -> sub, sub -> sub.getPermissionValue(contexts, node).asBoolean()));
|
.collect(Collectors.toMap(sub -> sub, sub -> sub.getPermissionValue(contexts, node).asBoolean()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,15 +29,16 @@ import me.lucko.luckperms.api.sponge.LuckPermsUserSubject;
|
|||||||
import me.lucko.luckperms.api.sponge.simple.SimpleCollection;
|
import me.lucko.luckperms.api.sponge.simple.SimpleCollection;
|
||||||
import me.lucko.luckperms.commands.Util;
|
import me.lucko.luckperms.commands.Util;
|
||||||
import me.lucko.luckperms.users.User;
|
import me.lucko.luckperms.users.User;
|
||||||
import me.lucko.luckperms.users.UserIdentifier;
|
|
||||||
import me.lucko.luckperms.users.UserManager;
|
import me.lucko.luckperms.users.UserManager;
|
||||||
import org.spongepowered.api.service.context.Context;
|
import org.spongepowered.api.service.context.Context;
|
||||||
import org.spongepowered.api.service.permission.PermissionService;
|
import org.spongepowered.api.service.permission.PermissionService;
|
||||||
import org.spongepowered.api.service.permission.Subject;
|
import org.spongepowered.api.service.permission.Subject;
|
||||||
import org.spongepowered.api.service.permission.SubjectCollection;
|
import org.spongepowered.api.service.permission.SubjectCollection;
|
||||||
import org.spongepowered.api.service.permission.SubjectData;
|
import org.spongepowered.api.service.permission.SubjectData;
|
||||||
|
import org.spongepowered.api.util.Tristate;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@ -66,31 +67,6 @@ public class UserCollection implements SubjectCollection {
|
|||||||
return PermissionService.SUBJECTS_USER;
|
return PermissionService.SUBJECTS_USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load a user into this manager
|
|
||||||
* @param uuid the external uuid of the user
|
|
||||||
*/
|
|
||||||
public synchronized void load(UUID uuid) {
|
|
||||||
UUID internal = service.getPlugin().getUuidCache().getUUID(uuid);
|
|
||||||
if (!manager.isLoaded(UserIdentifier.of(internal, null))) {
|
|
||||||
return; // Not loaded at a higher level
|
|
||||||
}
|
|
||||||
|
|
||||||
if (users.containsKey(internal)) {
|
|
||||||
return; // Already loaded
|
|
||||||
}
|
|
||||||
|
|
||||||
User user = manager.get(internal);
|
|
||||||
LuckPermsUserSubject subject = LuckPermsUserSubject.wrapUser(user, service);
|
|
||||||
subject.calculateActivePermissions(true); // Pre-process some of their permissions
|
|
||||||
|
|
||||||
users.put(internal, subject);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unload a user from this manager
|
|
||||||
* @param uuid the internal uuid of the user
|
|
||||||
*/
|
|
||||||
public void unload(UUID uuid) {
|
public void unload(UUID uuid) {
|
||||||
if (users.containsKey(uuid)) {
|
if (users.containsKey(uuid)) {
|
||||||
users.remove(uuid).deprovision();
|
users.remove(uuid).deprovision();
|
||||||
@ -99,19 +75,9 @@ public class UserCollection implements SubjectCollection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Subject get(@NonNull String id) {
|
public Subject get(@NonNull String id) {
|
||||||
final UUID uuid = Util.parseUuid(id);
|
Optional<Subject> s = getIfLoaded(id);
|
||||||
if (uuid != null) {
|
if (s.isPresent()) {
|
||||||
UUID internal = service.getPlugin().getUuidCache().getUUID(uuid);
|
return s.get();
|
||||||
if (users.containsKey(internal)) {
|
|
||||||
return users.get(internal);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
for (LuckPermsUserSubject subject : users.values()) {
|
|
||||||
if (subject.getUser().getName().equals(id)) {
|
|
||||||
return subject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (service.getPlugin().getConfiguration().isDebugPermissionChecks()) {
|
if (service.getPlugin().getConfiguration().isDebugPermissionChecks()) {
|
||||||
@ -122,24 +88,46 @@ public class UserCollection implements SubjectCollection {
|
|||||||
return fallback.get(id);
|
return fallback.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private Optional<Subject> getIfLoaded(String id) {
|
||||||
public boolean hasRegistered(@NonNull String id) {
|
UUID uuid = Util.parseUuid(id);
|
||||||
final UUID uuid = Util.parseUuid(id);
|
|
||||||
if (uuid != null) {
|
|
||||||
UUID internal = service.getPlugin().getUuidCache().getUUID(uuid);
|
|
||||||
if (users.containsKey(internal)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
find:
|
||||||
|
if (uuid == null) {
|
||||||
for (LuckPermsUserSubject subject : users.values()) {
|
for (LuckPermsUserSubject subject : users.values()) {
|
||||||
if (subject.getUser().getName().equals(id)) {
|
if (subject.getUser().getName().equals(id)) {
|
||||||
return true;
|
return Optional.of(subject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (User user : manager.getAll().values()) {
|
||||||
|
if (user.getName().equalsIgnoreCase(id)) {
|
||||||
|
uuid = user.getUuid();
|
||||||
|
break find;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
if (uuid != null) {
|
||||||
|
UUID internal = service.getPlugin().getUuidCache().getUUID(uuid);
|
||||||
|
Subject s = users.computeIfAbsent(internal, u -> {
|
||||||
|
User user = manager.get(u);
|
||||||
|
if (user == null) return null;
|
||||||
|
|
||||||
|
return LuckPermsUserSubject.wrapUser(user, service);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (s != null) {
|
||||||
|
return Optional.of(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasRegistered(@NonNull String id) {
|
||||||
|
return getIfLoaded(id).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -155,7 +143,7 @@ public class UserCollection implements SubjectCollection {
|
|||||||
@Override
|
@Override
|
||||||
public Map<Subject, Boolean> getAllWithPermission(@NonNull Set<Context> contexts, @NonNull String node) {
|
public Map<Subject, Boolean> getAllWithPermission(@NonNull Set<Context> contexts, @NonNull String node) {
|
||||||
return users.values().stream()
|
return users.values().stream()
|
||||||
.filter(sub -> sub.isPermissionSet(contexts, node))
|
.filter(sub -> sub.getPermissionValue(contexts, node) != Tristate.UNDEFINED)
|
||||||
.collect(Collectors.toMap(sub -> sub, sub -> sub.getPermissionValue(contexts, node).asBoolean()));
|
.collect(Collectors.toMap(sub -> sub, sub -> sub.getPermissionValue(contexts, node).asBoolean()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api.sponge.simple;
|
package me.lucko.luckperms.api.sponge.simple;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import org.spongepowered.api.command.CommandSource;
|
import org.spongepowered.api.command.CommandSource;
|
||||||
@ -29,6 +30,7 @@ import org.spongepowered.api.service.context.Context;
|
|||||||
import org.spongepowered.api.service.permission.*;
|
import org.spongepowered.api.service.permission.*;
|
||||||
import org.spongepowered.api.util.Tristate;
|
import org.spongepowered.api.util.Tristate;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -69,41 +71,66 @@ public class SimpleSubject implements Subject {
|
|||||||
@Override
|
@Override
|
||||||
public Tristate getPermissionValue(@NonNull Set<Context> contexts, @NonNull String node) {
|
public Tristate getPermissionValue(@NonNull Set<Context> contexts, @NonNull String node) {
|
||||||
Tristate res = subjectData.getNodeTree(contexts).get(node);
|
Tristate res = subjectData.getNodeTree(contexts).get(node);
|
||||||
if (res == Tristate.UNDEFINED) {
|
if (res != Tristate.UNDEFINED) {
|
||||||
for (Subject parent : getParents(contexts)) {
|
return res;
|
||||||
Tristate tempRes = parent.getPermissionValue(contexts, node);
|
}
|
||||||
if (tempRes != Tristate.UNDEFINED) {
|
|
||||||
res = tempRes;
|
for (Subject parent : getParents(contexts)) {
|
||||||
break;
|
Tristate tempRes = parent.getPermissionValue(contexts, node);
|
||||||
}
|
if (tempRes != Tristate.UNDEFINED) {
|
||||||
|
return tempRes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getContainingCollection().getIdentifier().equalsIgnoreCase("defaults")) {
|
||||||
|
return Tristate.UNDEFINED;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = service.getGroupSubjects().getDefaults().getPermissionValue(contexts, node);
|
||||||
|
if (res != Tristate.UNDEFINED) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = service.getDefaults().getPermissionValue(contexts, node);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChildOf(@NonNull Set<Context> contexts, @NonNull Subject subject) {
|
public boolean isChildOf(@NonNull Set<Context> contexts, @NonNull Subject subject) {
|
||||||
return subjectData.getParents(contexts).contains(subject);
|
return subjectData.getParents(contexts).contains(subject) ||
|
||||||
|
getContainingCollection().getDefaults().getParents(contexts).contains(subject) ||
|
||||||
|
service.getDefaults().getParents(contexts).contains(subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Subject> getParents(@NonNull Set<Context> contexts) {
|
public List<Subject> getParents(@NonNull Set<Context> contexts) {
|
||||||
return subjectData.getParents(contexts);
|
List<Subject> s = new ArrayList<>();
|
||||||
|
s.addAll(subjectData.getParents(contexts));
|
||||||
|
s.addAll(getContainingCollection().getDefaults().getParents(contexts));
|
||||||
|
s.addAll(service.getDefaults().getParents(contexts));
|
||||||
|
return ImmutableList.copyOf(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<String> getOption(Set<Context> set, String key) {
|
public Optional<String> getOption(Set<Context> set, String key) {
|
||||||
Optional<String> res = Optional.ofNullable(subjectData.getOptions(getActiveContexts()).get(key));
|
Optional<String> res = Optional.ofNullable(subjectData.getOptions(getActiveContexts()).get(key));
|
||||||
if (!res.isPresent()) {
|
if (res.isPresent()) {
|
||||||
for (Subject parent : getParents(getActiveContexts())) {
|
return res;
|
||||||
Optional<String> tempRes = parent.getOption(getActiveContexts(), key);
|
}
|
||||||
if (tempRes.isPresent()) {
|
|
||||||
res = tempRes;
|
for (Subject parent : getParents(getActiveContexts())) {
|
||||||
break;
|
Optional<String> tempRes = parent.getOption(getActiveContexts(), key);
|
||||||
}
|
if (tempRes.isPresent()) {
|
||||||
|
return tempRes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
|
||||||
|
res = getContainingCollection().getDefaults().getOption(set, key);
|
||||||
|
if (res.isPresent()) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return service.getDefaults().getOption(set, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.api.sponge.simple.persisted;
|
package me.lucko.luckperms.api.sponge.simple.persisted;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import me.lucko.luckperms.api.sponge.LuckPermsService;
|
import me.lucko.luckperms.api.sponge.LuckPermsService;
|
||||||
@ -88,24 +89,42 @@ public class SimplePersistedSubject implements Subject {
|
|||||||
@Override
|
@Override
|
||||||
public Tristate getPermissionValue(@NonNull Set<Context> contexts, @NonNull String node) {
|
public Tristate getPermissionValue(@NonNull Set<Context> contexts, @NonNull String node) {
|
||||||
Tristate res = subjectData.getNodeTree(contexts).get(node);
|
Tristate res = subjectData.getNodeTree(contexts).get(node);
|
||||||
if (res == Tristate.UNDEFINED) {
|
if (res != Tristate.UNDEFINED) {
|
||||||
transientSubjectData.getNodeTree(contexts).get(node);
|
return res;
|
||||||
}
|
}
|
||||||
if (res == Tristate.UNDEFINED) {
|
|
||||||
for (Subject parent : getParents(contexts)) {
|
res = transientSubjectData.getNodeTree(contexts).get(node);
|
||||||
Tristate tempRes = parent.getPermissionValue(contexts, node);
|
if (res != Tristate.UNDEFINED) {
|
||||||
if (tempRes != Tristate.UNDEFINED) {
|
return res;
|
||||||
res = tempRes;
|
}
|
||||||
break;
|
|
||||||
}
|
for (Subject parent : getParents(contexts)) {
|
||||||
|
Tristate tempRes = parent.getPermissionValue(contexts, node);
|
||||||
|
if (tempRes != Tristate.UNDEFINED) {
|
||||||
|
return tempRes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getContainingCollection().getIdentifier().equalsIgnoreCase("defaults")) {
|
||||||
|
return Tristate.UNDEFINED;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = service.getGroupSubjects().getDefaults().getPermissionValue(contexts, node);
|
||||||
|
if (res != Tristate.UNDEFINED) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = service.getDefaults().getPermissionValue(contexts, node);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChildOf(@NonNull Set<Context> contexts, @NonNull Subject subject) {
|
public boolean isChildOf(@NonNull Set<Context> contexts, @NonNull Subject subject) {
|
||||||
return subjectData.getParents(contexts).contains(subject) || transientSubjectData.getParents(contexts).contains(subject);
|
return subjectData.getParents(contexts).contains(subject) ||
|
||||||
|
transientSubjectData.getParents(contexts).contains(subject) ||
|
||||||
|
getContainingCollection().getDefaults().getParents(contexts).contains(subject) ||
|
||||||
|
service.getDefaults().getParents(contexts).contains(subject);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -113,25 +132,36 @@ public class SimplePersistedSubject implements Subject {
|
|||||||
List<Subject> s = new ArrayList<>();
|
List<Subject> s = new ArrayList<>();
|
||||||
s.addAll(subjectData.getParents(contexts));
|
s.addAll(subjectData.getParents(contexts));
|
||||||
s.addAll(transientSubjectData.getParents(contexts));
|
s.addAll(transientSubjectData.getParents(contexts));
|
||||||
return s;
|
s.addAll(getContainingCollection().getDefaults().getParents(contexts));
|
||||||
|
s.addAll(service.getDefaults().getParents(contexts));
|
||||||
|
return ImmutableList.copyOf(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<String> getOption(Set<Context> set, String key) {
|
public Optional<String> getOption(Set<Context> set, String key) {
|
||||||
Optional<String> res = Optional.ofNullable(subjectData.getOptions(getActiveContexts()).get(key));
|
Optional<String> res = Optional.ofNullable(subjectData.getOptions(getActiveContexts()).get(key));
|
||||||
if (!res.isPresent()) {
|
if (res.isPresent()) {
|
||||||
res = Optional.ofNullable(transientSubjectData.getOptions(getActiveContexts()).get(key));
|
return res;
|
||||||
}
|
}
|
||||||
if (!res.isPresent()) {
|
|
||||||
for (Subject parent : getParents(getActiveContexts())) {
|
res = Optional.ofNullable(transientSubjectData.getOptions(getActiveContexts()).get(key));
|
||||||
Optional<String> tempRes = parent.getOption(getActiveContexts(), key);
|
if (res.isPresent()) {
|
||||||
if (tempRes.isPresent()) {
|
return res;
|
||||||
res = tempRes;
|
}
|
||||||
break;
|
|
||||||
}
|
for (Subject parent : getParents(getActiveContexts())) {
|
||||||
|
Optional<String> tempRes = parent.getOption(getActiveContexts(), key);
|
||||||
|
if (tempRes.isPresent()) {
|
||||||
|
return tempRes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
|
||||||
|
res = getContainingCollection().getDefaults().getOption(set, key);
|
||||||
|
if (res.isPresent()) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return service.getDefaults().getOption(set, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,145 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>luckperms</artifactId>
|
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
|
||||||
<version>2.11-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>luckperms-standalone</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<defaultGoal>clean package</defaultGoal>
|
|
||||||
<finalName>LuckPermsStandalone-${release.version}.${git.closest.tag.commit.count}</finalName>
|
|
||||||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.5.1</version>
|
|
||||||
<configuration>
|
|
||||||
<source>1.8</source>
|
|
||||||
<target>1.8</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
<version>3.0.2</version>
|
|
||||||
<configuration>
|
|
||||||
<archive>
|
|
||||||
<manifest>
|
|
||||||
<mainClass>me.lucko.luckperms.LPStandaloneApp</mainClass>
|
|
||||||
</manifest>
|
|
||||||
</archive>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>2.4.3</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<minimizeJar>false</minimizeJar>
|
|
||||||
<relocations>
|
|
||||||
<relocation>
|
|
||||||
<pattern>org.slf4j</pattern>
|
|
||||||
<shadedPattern>me.lucko.luckperms.lib.slf4j</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>com.zaxxer.hikari</pattern>
|
|
||||||
<shadedPattern>me.lucko.luckperms.lib.hikari</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>com.mongodb</pattern>
|
|
||||||
<shadedPattern>me.lucko.luckperms.lib.mongodb</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>org.bson</pattern>
|
|
||||||
<shadedPattern>me.lucko.luckperms.lib.bson</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>org.h2</pattern>
|
|
||||||
<shadedPattern>me.lucko.luckperms.lib.h2</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>org.sqlite</pattern>
|
|
||||||
<shadedPattern>me.lucko.luckperms.lib.sqlite</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
</relocations>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>pl.project13.maven</groupId>
|
|
||||||
<artifactId>git-commit-id-plugin</artifactId>
|
|
||||||
<version>2.2.1</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>revision</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<injectAllReactorProjects>true</injectAllReactorProjects>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- LuckPerms Common -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
|
||||||
<artifactId>luckperms-common</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- LuckPerms API -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
|
||||||
<artifactId>luckperms-api</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- Lombok -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.16.10</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- gson -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.code.gson</groupId>
|
|
||||||
<artifactId>gson</artifactId>
|
|
||||||
<version>2.7</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- guava -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.guava</groupId>
|
|
||||||
<artifactId>guava</artifactId>
|
|
||||||
<version>19.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package me.lucko.luckperms;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.internal.StandaloneBase;
|
|
||||||
|
|
||||||
public class LPStandaloneApp {
|
|
||||||
private StandaloneBase standaloneBase;
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new LPStandaloneApp().start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void start() {
|
|
||||||
standaloneBase = new StandaloneBase(this);
|
|
||||||
LuckPerms.registerProvider(standaloneBase.getApiProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stop() {
|
|
||||||
standaloneBase.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package me.lucko.luckperms.gui;
|
|
||||||
|
|
||||||
public class InterfaceManager {
|
|
||||||
// TODO
|
|
||||||
}
|
|
@ -1,235 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package me.lucko.luckperms.internal;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import me.lucko.luckperms.LPStandaloneApp;
|
|
||||||
import me.lucko.luckperms.LuckPermsPlugin;
|
|
||||||
import me.lucko.luckperms.api.Logger;
|
|
||||||
import me.lucko.luckperms.api.PlatformType;
|
|
||||||
import me.lucko.luckperms.api.implementation.ApiProvider;
|
|
||||||
import me.lucko.luckperms.commands.ConsecutiveExecutor;
|
|
||||||
import me.lucko.luckperms.commands.Sender;
|
|
||||||
import me.lucko.luckperms.config.LPConfiguration;
|
|
||||||
import me.lucko.luckperms.constants.Constants;
|
|
||||||
import me.lucko.luckperms.constants.Message;
|
|
||||||
import me.lucko.luckperms.constants.Permission;
|
|
||||||
import me.lucko.luckperms.contexts.ContextManager;
|
|
||||||
import me.lucko.luckperms.core.UuidCache;
|
|
||||||
import me.lucko.luckperms.data.Importer;
|
|
||||||
import me.lucko.luckperms.groups.GroupManager;
|
|
||||||
import me.lucko.luckperms.storage.Datastore;
|
|
||||||
import me.lucko.luckperms.tracks.TrackManager;
|
|
||||||
import me.lucko.luckperms.users.StandaloneUserManager;
|
|
||||||
import me.lucko.luckperms.users.UserManager;
|
|
||||||
import me.lucko.luckperms.utils.LocaleManager;
|
|
||||||
import me.lucko.luckperms.utils.LogFactory;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class StandaloneBase implements LuckPermsPlugin {
|
|
||||||
private final ExecutorService threadPool = Executors.newCachedThreadPool();
|
|
||||||
|
|
||||||
private final java.util.logging.Logger logger;
|
|
||||||
|
|
||||||
private final UserManager userManager;
|
|
||||||
private final GroupManager groupManager;
|
|
||||||
private final TrackManager trackManager;
|
|
||||||
private final LPConfiguration configuration;
|
|
||||||
private final Datastore datastore;
|
|
||||||
private final Logger log;
|
|
||||||
private final UuidCache uuidCache;
|
|
||||||
private final ApiProvider apiProvider;
|
|
||||||
private final LocaleManager localeManager;
|
|
||||||
|
|
||||||
public StandaloneBase(LPStandaloneApp app) {
|
|
||||||
logger = java.util.logging.Logger.getGlobal();
|
|
||||||
log = LogFactory.wrap(logger);
|
|
||||||
|
|
||||||
configuration = new StandaloneConfiguration(this);
|
|
||||||
localeManager = new LocaleManager();
|
|
||||||
|
|
||||||
// TODO datastore
|
|
||||||
datastore = null;
|
|
||||||
// Load everything, including all users.
|
|
||||||
|
|
||||||
uuidCache = new UuidCache(true);
|
|
||||||
userManager = new StandaloneUserManager(this);
|
|
||||||
groupManager = new GroupManager(this);
|
|
||||||
trackManager = new TrackManager();
|
|
||||||
|
|
||||||
apiProvider = new ApiProvider(this);
|
|
||||||
|
|
||||||
// TODO callback to the app, start gui stuff?
|
|
||||||
}
|
|
||||||
|
|
||||||
public void shutdown() {
|
|
||||||
datastore.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getVersion() {
|
|
||||||
return "2.9.0"; // TODO set dynamically
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PlatformType getType() {
|
|
||||||
return PlatformType.STANDALONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public File getMainDir() {
|
|
||||||
return null; // Is this needed? TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public File getDataFolder() {
|
|
||||||
return null; // Is this needed? TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void runUpdateTask() {
|
|
||||||
// Is this needed?? TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doAsync(Runnable r) {
|
|
||||||
threadPool.execute(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doSync(Runnable r) {
|
|
||||||
threadPool.execute(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Methods below are only required in plugins.
|
|
||||||
* They're just left empty / default.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Importer getImporter() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConsecutiveExecutor getConsecutiveExecutor() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ContextManager getContextManager() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Message getPlayerStatus(UUID uuid) {
|
|
||||||
return Message.PLAYER_OFFLINE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getPlayerCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getPlayerList() {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Sender> getNotifyListeners() {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Sender getConsoleSender() {
|
|
||||||
final LuckPermsPlugin instance = this;
|
|
||||||
return new Sender() {
|
|
||||||
@Override
|
|
||||||
public LuckPermsPlugin getPlatform() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return Constants.getConsoleName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getUuid() {
|
|
||||||
return Constants.getConsoleUUID();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendMessage(String s) {
|
|
||||||
getLogger().info(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPermission(Permission permission) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getPossiblePermissions() {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<UUID> getIgnoringLogs() {
|
|
||||||
return Collections.emptySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPlugin(String name) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getService(Class clazz) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getUUID(String playerName) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPluginLoaded(String name) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package me.lucko.luckperms.users;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.LuckPermsPlugin;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class StandaloneUser extends User {
|
|
||||||
|
|
||||||
StandaloneUser(UUID uuid, LuckPermsPlugin plugin) {
|
|
||||||
super(uuid, plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
StandaloneUser(UUID uuid, String username, LuckPermsPlugin plugin) {
|
|
||||||
super(uuid, username, plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void refreshPermissions() {
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package me.lucko.luckperms.users;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.LuckPermsPlugin;
|
|
||||||
|
|
||||||
public class StandaloneUserManager extends UserManager {
|
|
||||||
private final LuckPermsPlugin plugin;
|
|
||||||
|
|
||||||
public StandaloneUserManager(LuckPermsPlugin plugin) {
|
|
||||||
super(plugin);
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanup(User user) {
|
|
||||||
// unload(user);
|
|
||||||
// never unload????? TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public User apply(UserIdentifier id) {
|
|
||||||
StandaloneUser user = id.getUsername() == null ?
|
|
||||||
new StandaloneUser(id.getUuid(), plugin) :
|
|
||||||
new StandaloneUser(id.getUuid(), id.getUsername(), plugin);
|
|
||||||
giveDefaultIfNeeded(user, false);
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateAllUsers() {
|
|
||||||
getAll().values().forEach(u -> plugin.getDatastore().loadUser(u.getUuid(), u.getName()));
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user