本文整理汇总了Java中org.spongepowered.api.service.permission.SubjectCollection类的典型用法代码示例。如果您正苦于以下问题:Java SubjectCollection类的具体用法?Java SubjectCollection怎么用?Java SubjectCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SubjectCollection类属于org.spongepowered.api.service.permission包,在下文中一共展示了SubjectCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDashboard
import org.spongepowered.api.service.permission.SubjectCollection; //导入依赖的package包/类
private UIPane createDashboard() {
FlowPaneUI dashboard = new FlowPaneUI(FlowPaneUI.WRAP_HORIZONALLY);
for (Entry<String, SubjectCollection> subjEntry : this.service.getKnownSubjects().entrySet()) {
Button button = new Button(subjEntry.getKey()) {
@Override
public int getPrefWidth(PlayerContext ctx) {
return ctx.width / 2;
}
};
button.setClickHandler(ExtraUtils.clickHandler(view -> {
this.subjListPane.setSubjectList(subjEntry.getValue());
this.setRoot(this.subjListPane);
return true;
}, this));
dashboard.getChildren().add(button);
}
return dashboard;
}
示例2: addDescription
import org.spongepowered.api.service.permission.SubjectCollection; //导入依赖的package包/类
protected PermissionDescription addDescription(RolesPermissionDescription desc, Map<String, Tristate> roleAssignments)
{
SubjectCollection subjects = getCollection(SUBJECTS_ROLE_TEMPLATE).get(); // TODO prevent infinite recursion
roleAssignments.forEach((key, value) ->
subjects.loadSubject(key).thenAccept(s -> s.getTransientSubjectData().setPermission(GLOBAL_CONTEXT, desc.getId(), value)));
if (descriptionMap.put(desc.getId().toLowerCase(), desc) == null)
{
if (config.debug)
{
logger.debug(desc.getId().toLowerCase());
}
}
descriptions = null;
return desc;
}
示例3: addSubjectToCollection
import org.spongepowered.api.service.permission.SubjectCollection; //导入依赖的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;
}
示例4: removeSubjectFromCollection
import org.spongepowered.api.service.permission.SubjectCollection; //导入依赖的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;
}
示例5: getLoadedCollections
import org.spongepowered.api.service.permission.SubjectCollection; //导入依赖的package包/类
@Nonnull
@Override
public Map<String, SubjectCollection> getLoadedCollections() {
return this.handle.getLoadedCollections().entrySet().stream()
.collect(ImmutableCollectors.toMap(
Map.Entry::getKey,
e -> e.getValue().sponge()
));
}
示例6: sponge
import org.spongepowered.api.service.permission.SubjectCollection; //导入依赖的package包/类
@Override
public synchronized SubjectCollection sponge() {
if (this.spongeProxy == null) {
Objects.requireNonNull(this.plugin.getService(), "service");
this.spongeProxy = ProxyFactory.toSponge(this);
}
return this.spongeProxy;
}
示例7: getKnownSubjects
import org.spongepowered.api.service.permission.SubjectCollection; //导入依赖的package包/类
@Nonnull
@Override
public Map<String, SubjectCollection> getKnownSubjects() {
return this.handle.getLoadedCollections().entrySet().stream()
.collect(ImmutableCollectors.toMap(
Map.Entry::getKey,
e -> e.getValue().sponge()
));
}
示例8: getAllSubjects
import org.spongepowered.api.service.permission.SubjectCollection; //导入依赖的package包/类
protected Set<String> getAllSubjects(String identifierCollection) {
Optional<SubjectCollection> collection = this.plugin.getEverAPI().getManagerService().getPermission().getCollection(identifierCollection);
if (!collection.isPresent()) return new HashSet<String>();
return collection.get().getLoadedSubjects().stream()
.map(subject -> subject.getFriendlyIdentifier().orElse(subject.getIdentifier()))
.collect(Collectors.toSet());
}
示例9: getAllSubjects
import org.spongepowered.api.service.permission.SubjectCollection; //导入依赖的package包/类
public static Set<String> getAllSubjects(EPPermissionService service, String collectionIdentifier) throws EMessageException {
Optional<SubjectCollection> collection = service.getCollection(collectionIdentifier);
if (!collection.isPresent()) return ImmutableSet.of();
if (!(collection.get() instanceof EPUserCollection || collection.get() instanceof EPCommandBlockCollection)) return ImmutableSet.of();
return collection.get().getLoadedSubjects().stream()
.map(subject -> subject.getIdentifier())
.collect(Collectors.toSet());
}
示例10: getCollection
import org.spongepowered.api.service.permission.SubjectCollection; //导入依赖的package包/类
public static EUserCollection getCollection(CommandSource source, EPPermissionService service, String collectionIdentifier) throws EMessageException {
Optional<SubjectCollection> collection = service.getCollection(collectionIdentifier);
if (!collection.isPresent() || !(collection.get() instanceof EUserCollection) || collection.get().getIdentifier().equals(PermissionService.SUBJECTS_USER))
throw new CollectionNotFoundException(source, collectionIdentifier);
return (EUserCollection) collection.get();
}
示例11: getSubject
import org.spongepowered.api.service.permission.SubjectCollection; //导入依赖的package包/类
public static EUserSubject getSubject(CommandSource source, EPPermissionService service, String collectionIdentifier, String subjectIdentifier) throws EMessageException {
Optional<SubjectCollection> collection = service.getCollection(collectionIdentifier);
if (!collection.isPresent() || collection.get().getIdentifier().equals(PermissionService.SUBJECTS_USER)) throw new CollectionNotFoundException(source, collectionIdentifier);
Optional<Subject> subject = collection.get().getSubject(subjectIdentifier);
if (!subject.isPresent() || !(subject.get() instanceof EPUserSubject)) throw new SubjectNotFoundException(source, collectionIdentifier, subjectIdentifier);
return (EUserSubject) subject.get();
}
示例12: getAssignedSubjects
import org.spongepowered.api.service.permission.SubjectCollection; //导入依赖的package包/类
@Override
public Map<Subject, Boolean> getAssignedSubjects(String type) {
Optional<SubjectCollection> collection = this.service.getCollection(type);
if (!collection.isPresent()) return ImmutableMap.of();
return collection.get().getLoadedWithPermission(this.permission);
}
示例13: register
import org.spongepowered.api.service.permission.SubjectCollection; //导入依赖的package包/类
@Override
public EPPermissionDescription register() throws IllegalStateException {
checkState(this.id != null, "No id set");
EPPermissionDescription description = new EPPermissionDescription(this.service, this.plugin, this.id, this.description);
this.service.registerDescription(description);
// Set role-templates
SubjectCollection subjects = this.service.loadCollection(PermissionService.SUBJECTS_ROLE_TEMPLATE).join();
for (Entry<String, Tristate> assignment : this.roleAssignments.entrySet()) {
Subject subject = subjects.loadSubject(assignment.getKey()).join();
subject.getTransientSubjectData().setPermission(SubjectData.GLOBAL_CONTEXT, this.id, assignment.getValue());
}
return description;
}
示例14: loadCollection
import org.spongepowered.api.service.permission.SubjectCollection; //导入依赖的package包/类
@Override
public CompletableFuture<SubjectCollection> loadCollection(String identifier) {
EPSubjectCollection<?> collection = this.collections.get(identifier.toLowerCase());
if (collection != null) return CompletableFuture.completedFuture(collection);
final EPSubjectCollection<?> newCollection = new EPUserCollection(this.plugin, identifier);
this.collections.put(identifier.toLowerCase(), newCollection);
return CompletableFuture.supplyAsync(() -> {
newCollection.load();
return newCollection;
}, this.plugin.getThreadAsync());
}
示例15: BaseSubject
import org.spongepowered.api.service.permission.SubjectCollection; //导入依赖的package包/类
public BaseSubject(SubjectCollection collection, RolesPermissionService service, T data)
{
this.collection = collection;
this.service = service;
this.data = data;
this.transientData = new BaseSubjectData(service);
}