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


Java Subject.getCommandSource方法代码示例

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


在下文中一共展示了Subject.getCommandSource方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: from

import org.spongepowered.api.service.permission.Subject; //导入方法依赖的package包/类
/**
 * Obtain a {@link CommandSource} from a {@link Subject}.
 * Either the Subject's real CommandSource, or a fake CommandSource implementation which just logs.
 * Useful instead of using null MessageReceiver.
 */
public static MessageReceiver from(Subject subject) {
    Optional<CommandSource> optionalCommandSource = subject.getCommandSource();
    if (optionalCommandSource.isPresent()) {
        return optionalCommandSource.get();
    } else {
        return new LoggingMessageReceiver(subject);
    }
}
 
开发者ID:vorburger,项目名称:ch.vorburger.minecraft.osgi,代码行数:14,代码来源:MessageReceivers.java

示例4: accumulateContexts

import org.spongepowered.api.service.permission.Subject; //导入方法依赖的package包/类
/**
 * Ajoute le monde
 */
@Override
public void accumulateContexts(final Subject subject, final Set<Context> accumulator) {
	Optional<CommandSource> subjSource = subject.getCommandSource();
    if (subjSource.isPresent()) {
        CommandSource source = subjSource.get();
        if (source instanceof Locatable) {
            accumulator.add(new Context(Context.WORLD_KEY, ((Locatable) source).getWorld().getName()));
        }
    }
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:14,代码来源:EPContextCalculator.java

示例5: 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


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