本文整理汇总了Java中org.spongepowered.api.service.permission.Subject类的典型用法代码示例。如果您正苦于以下问题:Java Subject类的具体用法?Java Subject怎么用?Java Subject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Subject类属于org.spongepowered.api.service.permission包,在下文中一共展示了Subject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: accumulateContexts
import org.spongepowered.api.service.permission.Subject; //导入依赖的package包/类
@Override
public void accumulateContexts(Subject calculable, Set<Context> accumulator)
{
Optional<CommandSource> sourceOptional = calculable.getCommandSource();
if (sourceOptional.isPresent())
{
CommandSource source = sourceOptional.get();
if (source instanceof Identifiable)
{
UUID uuid = ((Identifiable) source).getUniqueId();
if (this.plugin.getVirtualChestActions().isPlayerActivated(uuid))
{
accumulator.add(this.contextInAction);
SubjectData data = source.getTransientSubjectData();
Map<String, Boolean> permissions = data.getPermissions(Collections.singleton(this.contextInAction));
this.logger.debug("Ignored {} permission(s) for {} (context):", permissions.size(), uuid);
permissions.forEach((permission, state) -> this.logger.debug("- {} ({})", permission, state));
}
else
{
accumulator.add(this.contextNotInAction);
}
}
}
}
示例2: matches
import org.spongepowered.api.service.permission.Subject; //导入依赖的package包/类
@Override
public boolean matches(Context context, Subject subject)
{
Optional<CommandSource> sourceOptional = subject.getCommandSource();
if (sourceOptional.isPresent())
{
CommandSource source = sourceOptional.get();
if (source instanceof Identifiable)
{
UUID uuid = ((Identifiable) source).getUniqueId();
if (this.plugin.getVirtualChestActions().isPlayerActivated(uuid))
{
return this.contextInAction.equals(context);
}
else
{
return this.contextNotInAction.equals(context);
}
}
}
return false;
}
示例3: getFormat
import org.spongepowered.api.service.permission.Subject; //导入依赖的package包/类
@Override
public String getFormat(final Subject subject, Set<Context> contexts) {
Preconditions.checkNotNull(subject, "subject");
String format = null;
Optional<SubjectReference> group = this.getGroup(subject, contexts);
if (group.isPresent()) {
format = this.format.get(group.get().getSubjectIdentifier());
}
if (format == null) {
format = this.plugin.getConfigs().getFormatDefault();
}
return format;
}
示例4: getHighestGroup
import org.spongepowered.api.service.permission.Subject; //导入依赖的package包/类
public Subject getHighestGroup(User player){
HashMap<Integer, Subject> subs = new HashMap<Integer, Subject>();
try {
for (SubjectReference sub:player.getParents()){
if (sub.getCollectionIdentifier().equals(getGroups().getIdentifier()) && (sub.getSubjectIdentifier() != null)){
Subject subj;
subj = sub.resolve().get();
subs.put(subj.getParents().size(), subj);
}
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
if (!subs.isEmpty()){
return subs.get(Collections.max(subs.keySet()));
}
return null;
}
示例5: getParentGroup
import org.spongepowered.api.service.permission.Subject; //导入依赖的package包/类
private static Subject getParentGroup(Subject subject) throws NoValueException {
List<SubjectReference> allParents = subject.getParents();
Subject temp;
List<Subject> loadedParents = new ArrayList<>();
for (SubjectReference ref : allParents) {
if ((temp = ref.resolve().getNow(null)) == null) {
throw new NoValueException("Parent groups not present for subject, consult permissions plugin!");
}
loadedParents.add(temp);
}
if (loadedParents.isEmpty()) {
return subject;
}
loadedParents.sort((s1, s2) -> {
if (s1.isChildOf(s2.asSubjectReference())) {
return -1;
}
if (s2.isChildOf(s1.asSubjectReference())) {
return 1;
}
return 0;
});
return loadedParents.get(0);
}
示例6: tabCompleter
import org.spongepowered.api.service.permission.Subject; //导入依赖的package包/类
@Override
public Collection<String> tabCompleter(final CommandSource source, final List<String> args) throws CommandException {
if (args.size() == 1 && source instanceof Player && source.hasPermission(EEPermissions.SPAWNS.get())) {
Set<String> spawns = new TreeSet<String>();
this.plugin.getSpawn().getAll().keySet().forEach(reference -> {
Optional<Subject> subject = this.plugin.getEverAPI().getManagerService().getPermission().getGroupSubjects().getSubject(reference.getSubjectIdentifier());
if (subject.isPresent()) {
spawns.add(subject.get().getFriendlyIdentifier().orElse(subject.get().getIdentifier()));
} else {
spawns.add(reference.getSubjectIdentifier());
}
});
spawns.add(SpawnSubjectService.NEWBIE);
spawns.add(SpawnSubjectService.DEFAULT);
return spawns;
}
return Arrays.asList();
}
示例7: loadSubjects
import org.spongepowered.api.service.permission.Subject; //导入依赖的package包/类
@Override
public CompletableFuture<Map<String, Subject>> loadSubjects(Set<String> identifiers) {
ImmutableMap.Builder<String, Subject> subjects = ImmutableMap.builder();
Set<ESubject> newSubjects = new HashSet<ESubject>();
for (String identifier : identifiers) {
identifier = identifier.toLowerCase();
T subject = this.get(identifier).orElse(null);
if (subject == null) {
T newSubject = this.add(identifier);
newSubjects.add(newSubject);
this.identifierSubjects.put(newSubject.getIdentifier().toLowerCase(), newSubject);
newSubject.getFriendlyIdentifier().ifPresent(name -> this.nameSubjects.put(name.toLowerCase(), newSubject));
} else {
subjects.put(subject.getIdentifier().toLowerCase(), subject);
}
}
if (newSubjects.isEmpty() || this.isTransient()) return CompletableFuture.completedFuture(subjects.build());
return CompletableFuture.supplyAsync(() -> {
this.storage.load(newSubjects);
return subjects.build();
}, this.plugin.getThreadAsync());
}
示例8: resolve
import org.spongepowered.api.service.permission.Subject; //导入依赖的package包/类
@Override
public CompletableFuture<Subject> resolve() {
long sinceLast = System.currentTimeMillis() - this.lastLookup;
if (sinceLast >= TimeUnit.SECONDS.toMillis(15)) {
if (this.cache != null) {
Subject subject = this.cache.get();
if (subject != null) {
return CompletableFuture.completedFuture(subject);
}
}
}
return service.loadCollection(this.collectionIdentifier)
.thenComposeAsync(collection -> collection.loadSubject(this.subjectIdentifier))
.thenApply(subject -> {
this.cache = new WeakReference<Subject>(subject);
this.lastLookup = System.currentTimeMillis();
return subject;
});
}
示例9: giveApplicableContext
import org.spongepowered.api.service.permission.Subject; //导入依赖的package包/类
@Nonnull
@Override
public MutableContextSet giveApplicableContext(@Nonnull Subject subject, @Nonnull MutableContextSet accumulator) {
CommandSource source = subject.getCommandSource().orElse(null);
if (source == null || !(source instanceof Player)) {
return accumulator;
}
Player p = ((Player) source);
String world = p.getWorld().getName().toLowerCase();
while (!accumulator.has(Contexts.WORLD_KEY, world)) {
accumulator.add(Contexts.WORLD_KEY, world);
world = this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).getOrDefault(world, world).toLowerCase();
}
return accumulator;
}
示例10: getAllGroups
import org.spongepowered.api.service.permission.Subject; //导入依赖的package包/类
public List<String> getAllGroups(){
List<String> groups = new ArrayList<String>();
for (Subject group:getGroups().getAllSubjects()){
RULogger.severe("group: "+group.getIdentifier());
groups.add(group.getIdentifier());
}
return groups;
}
示例11: matches
import org.spongepowered.api.service.permission.Subject; //导入依赖的package包/类
/**
* Vérifie le monde
*/
@Override
public boolean matches(final Context context, final Subject subject) {
if (context.getType().equals(Context.WORLD_KEY)) {
Optional<CommandSource> subjSource = subject.getCommandSource();
if (subjSource.isPresent()) {
CommandSource source = subjSource.get();
if (source instanceof Locatable) {
return context.getName().equals(((Locatable) source).getWorld().getName());
}
}
}
return false;
}
示例12: addSubjectToCollection
import org.spongepowered.api.service.permission.Subject; //导入依赖的package包/类
@Override
public Subject addSubjectToCollection(Player player, SubjectCollection collection, String subjIdentifier) {
CommandResult res = command(player, new StringBuilder("pex ")
.append(collection.getIdentifier()).append(' ')
.append(subjIdentifier).append(" info").toString());
if (res.getSuccessCount().isPresent() && res.getSuccessCount().get() > 0) {
return collection.get(subjIdentifier);
}
return null;
}
示例13: removeSubjectFromCollection
import org.spongepowered.api.service.permission.Subject; //导入依赖的package包/类
@Override
public boolean removeSubjectFromCollection(Player player, SubjectCollection collection, Subject subject) {
CommandResult res = command(player, new StringBuilder("pex ")
.append(subject.getContainingCollection().getIdentifier()).append(' ')
.append(subject.getIdentifier()).append(" delete")
.toString());
return res.getSuccessCount().isPresent() && res.getSuccessCount().get() > 0;
}
示例14: getGroup
import org.spongepowered.api.service.permission.Subject; //导入依赖的package包/类
public String getGroup(User player){
for (Subject sub:player.getParents()){
if (sub.getContainingCollection().equals(getGroups()) && (sub.getIdentifier() != null)){
return sub.getIdentifier();
}
}
return null;
}
示例15: removeParent
import org.spongepowered.api.service.permission.Subject; //导入依赖的package包/类
@Override
public void removeParent(Player player, Subject subject, Set<Context> contexts, Subject parent) {
command(player, subjContext(subject, contexts)
.append("parent remove ").append(parent.getContainingCollection().getIdentifier()).append(' ')
.append(parent.getIdentifier())
.toString());
}