本文整理汇总了Java中org.spongepowered.api.service.permission.PermissionService类的典型用法代码示例。如果您正苦于以下问题:Java PermissionService类的具体用法?Java PermissionService怎么用?Java PermissionService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PermissionService类属于org.spongepowered.api.service.permission包,在下文中一共展示了PermissionService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderSubject
import org.spongepowered.api.service.permission.PermissionService; //导入依赖的package包/类
Text renderSubject(Subject subject) {
HoverAction<?> hover = null;
if (this.collection.getIdentifier().equals(PermissionService.SUBJECTS_USER)) {
try {
UUID uuid = UUID.fromString(subject.getIdentifier());
Optional<User> user = Sponge.getServiceManager().provideUnchecked(UserStorageService.class).get(uuid);
if (user.isPresent()) {
hover = TextActions.showText(Text.of(user.get().getName()));
}
} catch (Exception e) {
}
}
return Text.builder(subject.getIdentifier())
.onHover(hover)
.onClick(ExtraUtils.clickAction(() -> {
this.tab.getSubjViewer().setActive(subject, true);
this.tab.setRoot(this.tab.getSubjViewer());
}, SubjectListPane.this.tab)).build();
}
示例2: initNewTab
import org.spongepowered.api.service.permission.PermissionService; //导入依赖的package包/类
private void initNewTab(Player player) {
this.newTab.addButton("Player List", new NewTab.LaunchTabAction(() -> new Tab(Text.of("Player List"), this.playerList.getRoot())));
if (ImplementationConfig.isSupported()) {
if (player.hasPermission(PERM_CONFIG)) {
ConfigEditTab.Options opts = new ConfigEditTab.Options(
player.hasPermission(PERM_CONFIG + ".add"),
player.hasPermission(PERM_CONFIG + ".edit"),
player.hasPermission(PERM_CONFIG + ".delete"), null);
this.newTab.addButton("Edit Config", new NewTab.LaunchTabAction(() -> new ConfigEditTab(ImplementationConfig.getRootNode(),
ImplementationConfig.getTitle(), opts, ImplementationConfig.getHandler())));
}
}
if (player.hasPermission(PERM_PERMISSIONS)) {
Optional<PermissionService> optService = Sponge.getServiceManager().provide(PermissionService.class);
if (optService.isPresent()) {
this.newTab.addButton("Permissions", new NewTab.LaunchTabAction(() -> new PermissionsTab(optService.get())));
}
}
UUID uuid = player.getUniqueId();
this.newTab.addButton("Settings", new NewTab.LaunchTabAction(() -> createSettingsTab(uuid)));
}
示例3: register
import org.spongepowered.api.service.permission.PermissionService; //导入依赖的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();
}
示例4: registerCollection
import org.spongepowered.api.service.permission.PermissionService; //导入依赖的package包/类
public void registerCollection(String collection) {
if (collection.equals(PermissionService.SUBJECTS_DEFAULT)) return;
ConfigurationNode config = this.get("collections." + collection).getNode(EPConfig.DEFAULT);
boolean save = false;
List<String> worlds = new ArrayList<String>();
try {
worlds.addAll(config.getList(TypeToken.of(String.class)));
} catch (ObjectMappingException e) {}
for (World world : this.plugin.getGame().getServer().getWorlds()) {
if (this.getTypeWorld(collection, world.getName()).equals(EPConfig.DEFAULT) && !worlds.contains(world.getName())) {
worlds.add(world.getName());
save = true;
}
}
config.setValue(worlds);
if (config.isVirtual()) {
config.setValue(ImmutableList.of());
save = true;
}
if (save) this.save(true);
}
示例5: getCommandSource
import org.spongepowered.api.service.permission.PermissionService; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Optional<CommandSource> getCommandSource() {
if (this.getContainingCollection().getIdentifier().equals(PermissionService.SUBJECTS_USER)) {
try {
return (Optional) this.plugin.getGame().getServer().getPlayer(UUID.fromString(this.getIdentifier()));
} catch (Exception e) {}
} else if (this.getContainingCollection().getIdentifier().equals(PermissionService.SUBJECTS_SYSTEM)) {
if (this.getIdentifier().equals("Server")) {
return Optional.of(this.plugin.getGame().getServer().getConsole());
} else if (this.getIdentifier().equals("RCON")) {
// TODO: Implement RCON API?
}
} else if (this.getContainingCollection().getIdentifier().equals(PermissionService.SUBJECTS_COMMAND_BLOCK)) {
// TODO: Implement CommandBlock API?
}
return Optional.empty();
}
示例6: reloadConfig
import org.spongepowered.api.service.permission.PermissionService; //导入依赖的package包/类
public void reloadConfig() {
// Stop
this.worlds.clear();
// Start
this.plugin.getConfigs().registerCollection(this.identifier);
this.worlds.putAll(this.plugin.getConfigs().getTypeWorld(this.identifier));
if (!this.isTransient()) {
if (this.plugin.getDataBases().isEnable() && (this.storage == null || !(this.storage instanceof ESqlCollectionStorage)) && this.identifier.equals(PermissionService.SUBJECTS_GROUP)) {
if (this.identifier.equals(PermissionService.SUBJECTS_GROUP) ) {
this.storage = new ESqlCollectionStorage(this.plugin, this.identifier);
}
} else if ((!this.plugin.getDataBases().isEnable() || this.identifier.equals(PermissionService.SUBJECTS_GROUP)) && (this.storage == null || !(this.storage instanceof EConfigCollectionStorage))) {
this.storage = new EConfigCollectionStorage(this.plugin, this.identifier);
} else {
this.storage.reload();
}
for (String typeWorld : new HashSet<String>(this.worlds.values())) {
this.storage.register(typeWorld);
}
}
}
示例7: EPPermissionService
import org.spongepowered.api.service.permission.PermissionService; //导入依赖的package包/类
public EPPermissionService(final EverPermissions plugin) throws PluginDisableException {
this.plugin = plugin;
// Context
this.context = new EPContextCalculator(this.plugin);
// Collection
this.defaults = new EPUserCollection(this.plugin, PermissionService.SUBJECTS_DEFAULT);
this.groups = new EPGroupCollection(this.plugin);
this.users = new EPUserCollection(this.plugin, PermissionService.SUBJECTS_USER);
this.systems = new EPUserCollection(this.plugin, PermissionService.SUBJECTS_SYSTEM);
this.commandBlocks = new EPCommandBlockCollection(this.plugin, PermissionService.SUBJECTS_COMMAND_BLOCK);
this.descriptions = new ConcurrentHashMap<String, EPPermissionDescription>();
this.collections = new ConcurrentHashMap<String, EPSubjectCollection<?>>();
this.collections.put(PermissionService.SUBJECTS_USER.toLowerCase(), this.users);
this.collections.put(PermissionService.SUBJECTS_GROUP.toLowerCase(), this.groups);
this.collections.put(PermissionService.SUBJECTS_SYSTEM.toLowerCase(), this.systems);
this.collections.put(PermissionService.SUBJECTS_COMMAND_BLOCK.toLowerCase(), this.commandBlocks);
this.collections.put(PermissionService.SUBJECTS_DEFAULT.toLowerCase(), this.defaults);
this.collections.put(PermissionService.SUBJECTS_ROLE_TEMPLATE.toLowerCase(), new EPTransientCollection(this.plugin, PermissionService.SUBJECTS_ROLE_TEMPLATE));
}
示例8: execute
import org.spongepowered.api.service.permission.PermissionService; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext ctx) {
if (!src.hasPermission(GPPermissions.COMMAND_VERSION)) {
return CommandResult.success();
}
String version = GriefPreventionPlugin.IMPLEMENTATION_VERSION;
if (version == null) {
version = "unknown";
}
final String spongePlatform = Sponge.getPlatform().getContainer(Component.IMPLEMENTATION).getName();
Text gpVersion = Text.of(GriefPreventionPlugin.GP_TEXT, "Running ", TextColors.AQUA, "GriefPrevention ", version);
Text spongeVersion = Text.of(GriefPreventionPlugin.GP_TEXT, "Running ", TextColors.YELLOW, spongePlatform, " ", GriefPreventionPlugin.SPONGE_VERSION);
String permissionPlugin = Sponge.getServiceManager().getRegistration(PermissionService.class).get().getPlugin().getId();
String permissionVersion = Sponge.getServiceManager().getRegistration(PermissionService.class).get().getPlugin().getVersion().orElse("unknown");
Text permVersion = Text.of(GriefPreventionPlugin.GP_TEXT, "Running ", TextColors.GREEN, permissionPlugin, " ", permissionVersion);
src.sendMessage(Text.of(gpVersion, "\n", spongeVersion, "\n", permVersion));
return CommandResult.success();
}
示例9: listaccess
import org.spongepowered.api.service.permission.PermissionService; //导入依赖的package包/类
@Command(desc = "Lists the access levels for a bank")
public void listaccess(CommandSource context, @Default BaseAccount.Virtual bank)
{
i18n.send(context, POSITIVE, "Access Levels for {account}:", bank);
// TODO global access levels
// Everyone can SEE(hidden) DEPOSIT(needInvite)
// Noone can ...
for (Subject subject : Sponge.getServiceManager().provideUnchecked(PermissionService.class).getUserSubjects().getLoadedSubjects())
{
Optional<String> option = subject.getOption(bank.getActiveContexts(), "conomy.bank.access-level." + bank.getIdentifier());
if (option.isPresent())
{
// TODO list players highlight granted access
// <player> SEE DEPOSIT WITHDRAW MANAGE
}
}
}
示例10: findPermission
import org.spongepowered.api.service.permission.PermissionService; //导入依赖的package包/类
public static FoundPermission findPermission(PermissionService service, Subject subject, String permission, Set<Context> contexts)
{
FoundPermission found = findPermission(service, subject, permission, contexts, new HashSet<>());
if (debug)
{
String name = subject.getIdentifier();
if (subject.getCommandSource().isPresent())
{
name = subject.getCommandSource().get().getName();
}
name = subject.getContainingCollection().getIdentifier() + ":" + name;
if (found == null)
{
System.out.print("[PermCheck] " + name + " has not " + permission + "\n");
}
else
{
System.out.print("[PermCheck] " + name + " has " + permission + " set to " + found.value + " as " + found.permission + " in " + found.subject.getIdentifier() + "\n");
}
}
return found;
}
示例11: addParent
import org.spongepowered.api.service.permission.PermissionService; //导入依赖的package包/类
@Override
public CompletableFuture<Boolean> addParent(Set<Context> contexts, SubjectReference parent)
{
CompletableFuture<Boolean> ret = parent.resolve().thenApply(p -> {
if (PermissionService.SUBJECTS_DEFAULT.equals(parent.getCollectionIdentifier())) {
return false; // You can never add defaults as parents
}
checkForCircularDependency(contexts, p, 0);
if (contexts.isEmpty() && parents.get(GLOBAL) != null && parents.get(GLOBAL).contains(parent)) {
return false;
}
for (Context context : contexts) {
if (parents.containsKey(context) && parents.get(context).contains(parent)) {
return false;
}
}
return operate(contexts, parents, l -> l.add(p.asSubjectReference()), ArrayList::new);
});
RolesUtil.invalidateCache();
return ret;
}
示例12: onSetup
import org.spongepowered.api.service.permission.PermissionService; //导入依赖的package包/类
@Listener
public void onSetup(GamePreInitializationEvent event)
{
cm.getProviders().getExceptionHandler().addHandler(new RolesExceptionHandler(i18n));
this.permLogger = factory.getLog(LogFactory.class, "Permissions");
ThreadFactory threadFactory = mm.getThreadFactory(Roles.class);
this.permLogger.addTarget(
new AsyncFileTarget.Builder(LoggingUtil.getLogFile(fm, "Permissions").toPath(),
LoggingUtil.getFileFormat(false, true)
).setAppend(true).setCycler(LoggingUtil.getCycler()).setThreadFactory(threadFactory).build());
Optional<PermissionService> previous = Sponge.getServiceManager().provide(PermissionService.class);
Sponge.getServiceManager().setProvider(plugin.getInstance().get(), PermissionService.class, service);
if (previous.isPresent())
{
if (!previous.get().getClass().getName().equals(RolesPermissionService.class.getName()))
{
this.service.getLog().info("Replaced existing Permission Service: {}", previous.get().getClass().getName());
}
}
}
示例13: register
import org.spongepowered.api.service.permission.PermissionService; //导入依赖的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();
});
}
示例14: onInitializationEvent
import org.spongepowered.api.service.permission.PermissionService; //导入依赖的package包/类
@Listener
public void onInitializationEvent(GameInitializationEvent event) {
loadConfiguration();
initializeCommands();
logger.info("Finished initialization");
Sponge.getServiceManager().provide(PermissionService.class);
}
示例15: init
import org.spongepowered.api.service.permission.PermissionService; //导入依赖的package包/类
public void init()
{
PermissionService permissionService = Sponge.getServiceManager().provideUnchecked(PermissionService.class);
if (SpongeUnimplemented.isPermissionServiceProvidedBySponge(permissionService))
{
this.logger.warn("VirtualChest could not find the permission service. ");
this.logger.warn("Features related to permissions may not work normally.");
}
else
{
permissionService.registerContextCalculator(this);
}
}