当前位置: 首页>>代码示例>>Java>>正文


Java Subject类代码示例

本文整理汇总了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);
            }
        }
    }
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:26,代码来源:VirtualChestPermissionManager.java

示例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;
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:23,代码来源:VirtualChestPermissionManager.java

示例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;
   }
 
开发者ID:EverCraft,项目名称:EverChat,代码行数:17,代码来源:EChatService.java

示例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;
}
 
开发者ID:FabioZumbi12,项目名称:Sponge-RankUpper,代码行数:19,代码来源:RUPermsAPI.java

示例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);
}
 
开发者ID:rojo8399,项目名称:PlaceholderAPI,代码行数:25,代码来源:Defaults.java

示例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();
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:21,代码来源:EESpawn.java

示例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());
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:27,代码来源:EPSubjectCollection.java

示例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;
		});
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:22,代码来源:EPSubjectReference.java

示例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;
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:18,代码来源:WorldCalculator.java

示例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;
}
 
开发者ID:FabioZumbi12,项目名称:Sponge-RankUpper,代码行数:9,代码来源:RUPermsAPI.java

示例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;
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:17,代码来源:EPContextCalculator.java

示例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;
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:11,代码来源:PEXActions.java

示例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;
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:9,代码来源:PEXActions.java

示例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;	
}
 
开发者ID:FabioZumbi12,项目名称:PixelVip,代码行数:9,代码来源:PermsAPI.java

示例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());
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:8,代码来源:PEXActions.java


注:本文中的org.spongepowered.api.service.permission.Subject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。