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


Java SubjectReference类代码示例

本文整理汇总了Java中org.spongepowered.api.service.permission.SubjectReference的典型用法代码示例。如果您正苦于以下问题:Java SubjectReference类的具体用法?Java SubjectReference怎么用?Java SubjectReference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SubjectReference类属于org.spongepowered.api.service.permission包,在下文中一共展示了SubjectReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHighestGroup

import org.spongepowered.api.service.permission.SubjectReference; //导入依赖的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

示例2: getParentGroup

import org.spongepowered.api.service.permission.SubjectReference; //导入依赖的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

示例3: newSubjectReference

import org.spongepowered.api.service.permission.SubjectReference; //导入依赖的package包/类
@Nonnull
@Override
public SubjectReference newSubjectReference(@Nonnull String collectionIdentifier, @Nonnull String subjectIdentifier) {
    Objects.requireNonNull(collectionIdentifier, "collectionIdentifier");
    Objects.requireNonNull(subjectIdentifier, "subjectIdentifier");

    // test the identifiers
    String collection = collectionIdentifier.toLowerCase();
    if (collection.equals("user") && !this.handle.getUserSubjects().getIdentifierValidityPredicate().test(subjectIdentifier)) {
        throw new IllegalArgumentException("Subject identifier '" + subjectIdentifier + "' does not pass the validity predicate for the user subject collection");
    } else if (collection.equals("group") && !this.handle.getGroupSubjects().getIdentifierValidityPredicate().test(subjectIdentifier)) {
        throw new IllegalArgumentException("Subject identifier '" + subjectIdentifier + "' does not pass the validity predicate for the group subject collection");
    }

    // obtain a reference
    return SubjectReferenceFactory.obtain(this.handle, collectionIdentifier, subjectIdentifier);
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:18,代码来源:PermissionServiceProxy.java

示例4: removeParent

import org.spongepowered.api.service.permission.SubjectReference; //导入依赖的package包/类
public CompletableFuture<Boolean> removeParent(final String typeWorld, final SubjectReference parent) {
	Preconditions.checkNotNull(typeWorld, "typeWorld");
	Preconditions.checkNotNull(parent, "parent");
	
	return CompletableFuture.supplyAsync(() -> {
		this.read_lock.lock();
		try {
			List<SubjectReference> parents = this.parents.get(typeWorld);
			if (parents == null || !parents.contains(parent)) return false;
		} finally {
			this.read_lock.unlock();
		}
		
		if (!this.getSubject().getContainingCollection().getStorage().removeParent(this, typeWorld, parent)) return false;
		
		this.removeParentExecute(typeWorld, parent);
		this.onUpdate();
		return true;
	}, this.plugin.getThreadAsync());
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:21,代码来源:EPGroupData.java

示例5: setGroup

import org.spongepowered.api.service.permission.SubjectReference; //导入依赖的package包/类
@Override
public CompletableFuture<Boolean> setGroup(final String typeWorld, final SubjectReference parent) {
	Preconditions.checkNotNull(typeWorld, "typeWorld");
	Preconditions.checkNotNull(parent, "parent");
	
	return CompletableFuture.supplyAsync(() -> {
		boolean insert = true;
		
		this.read_lock.lock();
		try {
			SubjectReference oldParents = this.groups.get(typeWorld);
			insert = oldParents == null;
			
			if (!insert && oldParents.equals(parent)) return false;
		} finally {
			this.read_lock.unlock();
		}
		
		if (!this.getSubject().getContainingCollection().getStorage().setGroup(this, typeWorld, parent, insert)) return false;
		
		this.setGroupExecute(typeWorld, parent);
		this.onUpdate();
		return true;
	}, this.plugin.getThreadAsync());
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:26,代码来源:EPUserData.java

示例6: removeParent

import org.spongepowered.api.service.permission.SubjectReference; //导入依赖的package包/类
@Override
public CompletableFuture<Boolean> removeParent(final String typeWorld, final SubjectReference parent) {
	Preconditions.checkNotNull(typeWorld, "typeWorld");
	Preconditions.checkNotNull(parent, "parent");
	
	return CompletableFuture.supplyAsync(() -> {
		this.read_lock.lock();
		try {
			SubjectReference group = this.groups.get(typeWorld);
			List<SubjectReference> parents = this.parents.get(typeWorld);
			if (!(group == null || !group.equals(parent))  && !(parents == null || !parents.contains(parent))) return false;
		} finally {
			this.read_lock.unlock();
		}
		
		if (!this.getSubject().getContainingCollection().getStorage().removeParent(this, typeWorld, parent)) return false;
		
		this.removeParentExecute(typeWorld, parent);
		this.onUpdate();
		return true;
	}, this.plugin.getThreadAsync());
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:23,代码来源:EPUserData.java

示例7: addParent

import org.spongepowered.api.service.permission.SubjectReference; //导入依赖的package包/类
@Override
public CompletableFuture<Boolean> addParent(final String typeWorld, final SubjectReference parent) {
	Preconditions.checkNotNull(typeWorld, "typeWorld");
	Preconditions.checkNotNull(parent, "parent");
	
	return CompletableFuture.supplyAsync(() -> {
		this.read_lock.lock();
		try {
			List<SubjectReference> parents = this.parents.get(typeWorld);
			if (parents != null && parents.contains(parent)) return false;
		} finally {
			this.read_lock.unlock();
		}
		
		if (!this.getSubject().getContainingCollection().getStorage().addParent(this, typeWorld, parent)) return false;
		
		this.addParentExecute(typeWorld, parent);
		this.onUpdate();
		return true;
	}, this.plugin.getThreadAsync());
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:22,代码来源:EPSubjectData.java

示例8: removeParent

import org.spongepowered.api.service.permission.SubjectReference; //导入依赖的package包/类
public boolean removeParent(final EPSubjectData<?> subject, final SubjectReference parent) {
	ConfigurationNode group = this.get(subject.getIdentifier() + ".group");
	if (!group.isVirtual() && group.getString("").equals(parent.getSubjectIdentifier())) {
		this.get(subject.getIdentifier()).removeChild("group");
		return this.save(true);
	}
	
	try {
		List<String> subgroups = new ArrayList<String>(this.get(subject.getIdentifier() + "." + this.parentIdentifier).getList(TypeToken.of(String.class)));
		subgroups.remove(parent.getSubjectIdentifier());
		if (subgroups.isEmpty()) {
			this.get(subject.getIdentifier()).removeChild(this.parentIdentifier);
		} else {
			this.get(subject.getIdentifier() + "." + this.parentIdentifier).setValue(subgroups);
		}
		this.plugin.getELogger().debug("Removed from configs file : (identifier='" + subject + "';subgroup='" + parent.getSubjectIdentifier() + "';type='" + this.typeWorld + "')");
		return this.save(true);
	} catch (ObjectMappingException e) {}
	return false;
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:21,代码来源:EConfigSubjectStorage.java

示例9: getGroupAndTag

import org.spongepowered.api.service.permission.SubjectReference; //导入依赖的package包/类
public Subject getGroupAndTag(User player) throws InterruptedException, ExecutionException{
	HashMap<Integer, Subject> subs = new HashMap<>();
	for (SubjectReference sub:player.getParents()){
		if (sub.getCollectionIdentifier().equals(getGroups().getIdentifier()) && (sub.getSubjectIdentifier() != null)){
			Subject subj = sub.resolve().get();
			subs.put(subj.getParents().size(), subj);				
		}			
	}
	return subs.isEmpty() ? null : subs.get(Collections.max(subs.keySet()));
}
 
开发者ID:FabioZumbi12,项目名称:UltimateChat,代码行数:11,代码来源:UCPerms78.java

示例10: newSubjectReference

import org.spongepowered.api.service.permission.SubjectReference; //导入依赖的package包/类
@Nonnull
@Override
public SubjectReference newSubjectReference(@Nonnull String subjectIdentifier) {
    Objects.requireNonNull(subjectIdentifier, "identifier");
    if (!this.handle.getIdentifierValidityPredicate().test(subjectIdentifier)) {
        throw new IllegalArgumentException("Subject identifier '" + subjectIdentifier + "' does not pass the validity predicate");
    }

    return SubjectReferenceFactory.obtain(this.handle.getService(), getIdentifier(), subjectIdentifier);
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:11,代码来源:SubjectCollectionProxy.java

示例11: obtain

import org.spongepowered.api.service.permission.SubjectReference; //导入依赖的package包/类
public LPSubjectReference obtain(SubjectReference reference) {
    Objects.requireNonNull(reference, "reference");
    if (reference instanceof LPSubjectReference) {
        return ((LPSubjectReference) reference);
    } else {
        return obtain(reference.getCollectionIdentifier(), reference.getSubjectIdentifier());
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:9,代码来源:SubjectReferenceFactory.java

示例12: addInheritances

import org.spongepowered.api.service.permission.SubjectReference; //导入依赖的package包/类
public void addInheritances(List<Text> list, EGroupSubject group, String worldName, String typeGroup) {
	List<SubjectReference> groups = group.getSubjectData().getParents(typeGroup);
	if (groups.isEmpty()) {
		list.add(EPMessages.GROUP_INFO_INHERITANCE_EMPTY.getText());
	} else {
		list.add(EPMessages.GROUP_INFO_INHERITANCE.getText());
		for (SubjectReference inheritance : groups) {
			list.add(EPMessages.GROUP_INFO_INHERITANCE_LINE.getFormat()
					.toText("{inheritance}", this.parent.getButtonInfo(inheritance.resolve().join().getFriendlyIdentifier().orElse(inheritance.getSubjectIdentifier()), worldName)));
		}
	}
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:13,代码来源:EPGroupInfo.java

示例13: command

import org.spongepowered.api.service.permission.SubjectReference; //导入依赖的package包/类
private CompletableFuture<Boolean> command(final CommandSource player, final String groupName, final String inheritanceName, final String worldName) throws EMessageException {
	String typeGroup = EPCommand.getTypeWorld(player, this.plugin.getService().getGroupSubjects(), worldName);
	EGroupSubject group = EPCommand.getGroup(player, this.plugin.getService(), groupName, typeGroup);
	EGroupSubject inheritance = EPCommand.getGroup(player, this.plugin.getService(), inheritanceName, typeGroup);
	SubjectReference inheritanceReference = inheritance.asSubjectReference();
	
	if (!group.getParents(typeGroup).contains(inheritanceReference)) {
		EPMessages.GROUP_INHERITANCE_REMOVE_ERROR.sender()
			.replace("{inheritance}", inheritance.getFriendlyIdentifier().orElse(inheritanceName))
			.replace("{group}", group.getFriendlyIdentifier().orElse(groupName))
			.replace("{type}", typeGroup)
			.sendTo(player);
		return CompletableFuture.completedFuture(false);
	}
	
	// L'inheritance n'a pas été supprimé
	return group.getSubjectData().removeParent(typeGroup, inheritanceReference)
		.exceptionally(e -> false)
		.thenApply(result -> {
			if (!result) {
				EAMessages.COMMAND_ERROR.sender()
					.prefix(EPMessages.PREFIX)
					.sendTo(player);
				return false;
			}
			
			EPMessages.GROUP_INHERITANCE_REMOVE_STAFF.sender()
				.replace("{inheritance}", inheritance.getFriendlyIdentifier().orElse(inheritanceName))
				.replace("{group}", group.getFriendlyIdentifier().orElse(groupName))
				.replace("{type}", typeGroup)
				.sendTo(player);
			return true;
		});
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:35,代码来源:EPGroupInheritanceRemove.java

示例14: getGroup

import org.spongepowered.api.service.permission.SubjectReference; //导入依赖的package包/类
public Optional<SubjectReference> getGroup(final Set<Context> contexts) {
Preconditions.checkNotNull(contexts, "contexts");

List<SubjectReference> groups = this.getSubjectData().getParents(contexts);
if (!groups.isEmpty()) {
	return Optional.of(groups.get(0));
}
return Optional.empty();
  }
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:10,代码来源:EUser.java

示例15: addSubGroupsTransient

import org.spongepowered.api.service.permission.SubjectReference; //导入依赖的package包/类
public void addSubGroupsTransient(List<Text> list, EUser user, EUserSubject subject, String worldName, String typeUser) {
	List<SubjectReference> groups = subject.getTransientSubjectData().getSubGroup(typeUser);
	if (!groups.isEmpty()) {
		list.add(EPMessages.USER_INFO_SUBGROUP_TRANSIENT.getText());
		for (SubjectReference inheritance : groups) {
			list.add(EPMessages.USER_INFO_SUBGROUP_TRANSIENT_LINE.getFormat()
					.toText("{subgroup}", this.parent.getButtonInfo(inheritance.resolve().join().getFriendlyIdentifier().orElse(inheritance.getSubjectIdentifier()), worldName)));
		}
	}
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:11,代码来源:EPUserInfo.java


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