本文整理汇总了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);
}
}
}
}
示例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;
}
示例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);
}
}
示例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()));
}
}
}
示例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;
}