本文整理汇总了Java中org.spongepowered.api.service.permission.PermissionDescription类的典型用法代码示例。如果您正苦于以下问题:Java PermissionDescription类的具体用法?Java PermissionDescription怎么用?Java PermissionDescription使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PermissionDescription类属于org.spongepowered.api.service.permission包,在下文中一共展示了PermissionDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerPermissions
import org.spongepowered.api.service.permission.PermissionDescription; //导入依赖的package包/类
public void registerPermissions() {
registerPermission(BASE, PermissionDescription.ROLE_ADMIN);
registerPermission(SYNC, "Base permission for all synchronizing", PermissionDescription.ROLE_USER);
registerPermission(SYNC_INVENTORY, "Allow this user's inventory to be synchronized",
PermissionDescription.ROLE_USER);
registerPermission(SYNC_ENDER_CHEST, "Allow this user's ender chest to be synchronized",
PermissionDescription.ROLE_USER);
registerPermission(SYNC_GAME_MODE, "Allow this user's game mode to be synchronized",
PermissionDescription.ROLE_USER);
registerPermission(SYNC_EXPERIENCE, "Allow this user's experience to be synchronized",
PermissionDescription.ROLE_USER);
registerPermission(SYNC_HEALTH, "Allow this user's health to be synchronized", PermissionDescription.ROLE_USER);
registerPermission(SYNC_HUNGER, "Allow this user's hunger to be synchronized", PermissionDescription.ROLE_USER);
registerPermission(SYNC_POTION_EFFECTS, "Allow this user's potion effects to be synchronized",
PermissionDescription.ROLE_USER);
}
示例2: register
import org.spongepowered.api.service.permission.PermissionDescription; //导入依赖的package包/类
@Nonnull
@Override
public PermissionDescription register() throws IllegalStateException {
if (this.id == null) {
throw new IllegalStateException("id cannot be null");
}
LPPermissionDescription description = this.service.registerPermissionDescription(this.id, this.description, this.container);
// Set role-templates
LPSubjectCollection subjects = this.service.getCollection(PermissionService.SUBJECTS_ROLE_TEMPLATE);
for (Map.Entry<String, Tristate> assignment : this.roles.entrySet()) {
LPSubject subject = subjects.loadSubject(assignment.getKey()).join();
subject.getTransientSubjectData().setPermission(ContextSet.empty(), this.id, assignment.getValue());
}
this.service.getPlugin().getPermissionVault().offer(this.id);
// null stuff so this instance can be reused
this.roles.clear();
this.id = null;
this.description = null;
return description.sponge();
}
示例3: addDescription
import org.spongepowered.api.service.permission.PermissionDescription; //导入依赖的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;
}
示例4: register
import org.spongepowered.api.service.permission.PermissionDescription; //导入依赖的package包/类
public static void register(AuraSunDial plugin) {
CommandSpec realTime = CommandSpec.builder()
.description(Text.of("Enables or disables synchronizing the world time with realtime."))
.executor(new CommandRealTime())
.arguments(
GenericArguments.choices(Text.of(PARAM_MODE),
ImmutableMap.<String, Boolean>builder().put("enable", true).put("disable", false)
.build(),
true),
GenericArguments.optional(GenericArguments.firstParsing(
GenericArguments.allOf(GenericArguments.world(Text.of(PARAM_WORLD))),
GenericArguments.literal(Text.of(PARAM_ALL), PARAM_ALL))))
.build();
Sponge.getCommandManager().register(plugin, realTime, "realtime", "rt", "sundial", "sd");
Sponge.getServiceManager().provide(PermissionService.class).ifPresent(permissionService -> {
permissionService.newDescriptionBuilder(plugin).id(BASE_PERMISSION)
.description(Text.of("Allows the user to execute the realtime command."))
.assign(PermissionDescription.ROLE_STAFF, true).register();
permissionService.newDescriptionBuilder(plugin).id(BASE_PERMISSION + ".enable")
.description(Text.of("Allows the user to to enable realtime on all worlds."))
.assign(PermissionDescription.ROLE_STAFF, true).register();
permissionService.newDescriptionBuilder(plugin).id(BASE_PERMISSION + ".enable.<world>")
.description(Text.of("Allows the user to to enable realtime on the specific world."))
.assign(PermissionDescription.ROLE_STAFF, true).register();
permissionService.newDescriptionBuilder(plugin).id(BASE_PERMISSION + ".disable")
.description(Text.of("Allows the user to to disable realtime on all worlds."))
.assign(PermissionDescription.ROLE_STAFF, true).register();
permissionService.newDescriptionBuilder(plugin).id(BASE_PERMISSION + ".disable.<world>")
.description(Text.of("Allows the user to to disable realtime on the specific world."))
.assign(PermissionDescription.ROLE_STAFF, true).register();
});
}
示例5: assign
import org.spongepowered.api.service.permission.PermissionDescription; //导入依赖的package包/类
@Nonnull
@Override
public PermissionDescription.Builder assign(@Nonnull String permission, boolean value) {
Objects.requireNonNull(permission, "permission");
this.roles.put(permission, Tristate.fromBoolean(value));
return this;
}
示例6: newDescriptionBuilder
import org.spongepowered.api.service.permission.PermissionDescription; //导入依赖的package包/类
@Override
public PermissionDescription.Builder newDescriptionBuilder(@Nonnull Object o) {
Optional<PluginContainer> container = Sponge.getGame().getPluginManager().fromInstance(o);
if (!container.isPresent()) {
throw new IllegalArgumentException("Couldn't find a plugin container for " + o.getClass().getSimpleName());
}
return new LPDescriptionBuilder(this.handle, container.get());
}
示例7: sponge
import org.spongepowered.api.service.permission.PermissionDescription; //导入依赖的package包/类
@Override
public synchronized PermissionDescription sponge() {
if (this.spongeProxy == null) {
this.spongeProxy = ProxyFactory.toSponge(this);
}
return this.spongeProxy;
}
示例8: newDescriptionBuilder
import org.spongepowered.api.service.permission.PermissionDescription; //导入依赖的package包/类
@Override
public Optional<PermissionDescription.Builder> newDescriptionBuilder(@Nonnull Object o) {
Optional<PluginContainer> container = Sponge.getGame().getPluginManager().fromInstance(o);
if (!container.isPresent()) {
throw new IllegalArgumentException("Couldn't find a plugin container for " + o.getClass().getSimpleName());
}
return Optional.of(new LPDescriptionBuilder(this.handle, container.get()));
}
示例9: newDescriptionBuilder
import org.spongepowered.api.service.permission.PermissionDescription; //导入依赖的package包/类
@Override
public PermissionDescription.Builder newDescriptionBuilder(final Object instance) {
Optional<PluginContainer> container = this.plugin.getGame().getPluginManager().fromInstance(instance);
if (!container.isPresent()) {
throw new IllegalArgumentException("Couldn't find a plugin container for " + instance.getClass().getSimpleName());
}
return new EPPermissionDescription.Builder(this, container.get());
}
示例10: getDescriptions
import org.spongepowered.api.service.permission.PermissionDescription; //导入依赖的package包/类
@Override
public Collection<PermissionDescription> getDescriptions() {
Collection<PermissionDescription> descriptions = this.descriptions;
if (descriptions == null) {
descriptions = ImmutableList.copyOf(this.descriptionMap.values());
this.descriptions = descriptions;
}
return descriptions;
}
示例11: ModuleDocs
import org.spongepowered.api.service.permission.PermissionDescription; //导入依赖的package包/类
public ModuleDocs(PluginContainer plugin, Class module, Reflector reflector, PermissionManager pm, PermissionService ps, CommandManager cm, ModuleManager mm)
{
this.pc = plugin;
this.name = plugin.getName();
this.moduleName = mm.getModuleName(module).get();
this.id = plugin.getId();
this.moduleId = mm.getModuleID(module).get();
InputStream is = plugin.getClass().getResourceAsStream("/assets/cubeengine/"+ moduleId + "-info.yml");
if (is == null)
{
this.config = reflector.create(Info.class);
}
else
{
this.config = reflector.load(Info.class, new InputStreamReader(is));
}
this.basePermission = pm.getBasePermission(module);
for (PermissionDescription perm : ps.getDescriptions())
{
if (perm.getId().startsWith(basePermission.getId() + ".") || perm.getId().equals(basePermission.getId()))
{
this.permissions.add(perm);
}
}
for (CommandBase base : cm.getCommands())
{
if (base.getDescriptor().getOwner().equals(module))
{
this.commands.add(base);
}
}
}
示例12: findPermission
import org.spongepowered.api.service.permission.PermissionDescription; //导入依赖的package包/类
@Command(desc = "Searches for registered Permissions")
public void findPermission(CommandSource sender, @Complete(PermissionCompleter.class) String permission)
{
PermissionDescription perm = service.getDescription(permission).orElse(null);
if (perm == null)
{
i18n.send(sender, NEGATIVE, "Permission {name} not found!", permission);
}
else
{
i18n.send(sender, POSITIVE, "Permission {name} found:", permission);
if (perm.getDescription().isPresent())
{
sender.sendMessage(perm.getDescription().get().toBuilder().color(GOLD).build());
}
Map<Subject, Boolean> roles = perm.getAssignedSubjects(PermissionService.SUBJECTS_ROLE_TEMPLATE);
if (!roles.isEmpty())
{
i18n.send(sender, POSITIVE, "Permission is assigned to the following templates:");
for (Entry<Subject, Boolean> entry : roles.entrySet())
{
sender.sendMessage(Text.of(" - ", GOLD, entry.getKey().getIdentifier(), ": ",
entry.getValue() ? DARK_GREEN : DARK_RED,
entry.getValue() ? "true" : "false")); // TODO translate
}
}
}
}
示例13: getDescriptions
import org.spongepowered.api.service.permission.PermissionDescription; //导入依赖的package包/类
@Override
public Collection<PermissionDescription> getDescriptions()
{
if (descriptions == null)
{
descriptions = Collections.unmodifiableCollection(descriptionMap.values());
}
return descriptions;
}
示例14: register
import org.spongepowered.api.service.permission.PermissionDescription; //导入依赖的package包/类
@Override
public void register(Permission perm) {
if (this.permissions.stream().filter(p -> p.get().equalsIgnoreCase(perm.get())).count() > 0) return;
this.permissions.add(perm);
org.spongepowered.api.service.permission.PermissionService service = Sponge.getServiceManager().provide(org.spongepowered.api.service.permission.PermissionService.class).get();
Optional<PermissionDescription.Builder> builder = service.newDescriptionBuilder(UltimateCore.get());
if (!builder.isPresent()) return;
builder.get().id(perm.get()).description(perm.getDescription()).register();
}
示例15: getDescription
import org.spongepowered.api.service.permission.PermissionDescription; //导入依赖的package包/类
@Nonnull
@Override
public Optional<PermissionDescription> getDescription(@Nonnull String s) {
return this.handle.getDescription(s).map(LPPermissionDescription::sponge);
}