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


Java Context类代码示例

本文整理汇总了Java中org.spongepowered.api.service.context.Context的典型用法代码示例。如果您正苦于以下问题:Java Context类的具体用法?Java Context怎么用?Java Context使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Context类属于org.spongepowered.api.service.context包,在下文中一共展示了Context类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: accumulateContexts

import org.spongepowered.api.service.context.Context; //导入依赖的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.context.Context; //导入依赖的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: clearPermissions

import org.spongepowered.api.service.context.Context; //导入依赖的package包/类
public static CompletableFuture<Boolean> clearPermissions(SubjectData data, Set<Context> contexts)
{
    try
    {
        Object result = SUBJECT_DATA_CLEAR_PERMISSIONS.invoke(data, contexts);
        if (result instanceof CompletableFuture)
        {
            @SuppressWarnings("unchecked")
            CompletableFuture<Boolean> future = (CompletableFuture) result;
            return future;
        }
        else
        {
            return CompletableFuture.completedFuture((Boolean) result);
        }
    }
    catch (Throwable throwable)
    {
        throw new UnsupportedOperationException(throwable);
    }
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:22,代码来源:SpongeUnimplemented.java

示例4: setPermission

import org.spongepowered.api.service.context.Context; //导入依赖的package包/类
public static CompletableFuture<Boolean> setPermission(SubjectData data, Set<Context> contexts, String permission)
{
    try
    {
        Object result = SUBJECT_DATA_SET_PERMISSION.invoke(data, contexts, permission, Tristate.TRUE);
        if (result instanceof CompletableFuture)
        {
            @SuppressWarnings("unchecked")
            CompletableFuture<Boolean> future = (CompletableFuture) result;
            return future;
        }
        else
        {
            return CompletableFuture.completedFuture((Boolean) result);
        }
    }
    catch (Throwable throwable)
    {
        throw new UnsupportedOperationException(throwable);
    }
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:22,代码来源:SpongeUnimplemented.java

示例5: command

import org.spongepowered.api.service.context.Context; //导入依赖的package包/类
private CompletableFuture<Boolean> command(final CommandSource player, final String groupName, final String option, final String worldName) throws EMessageException {
	String typeGroup = EPCommand.getTypeWorld(player, this.plugin.getService().getGroupSubjects(), worldName);
	EGroupSubject group = EPCommand.getGroup(player, this.plugin.getService(), groupName, typeGroup);
	
	Set<Context> contexts = EPContextCalculator.of(worldName);
	String value = group.getSubjectData().getOptions(contexts).get(option);
	// Si il y a une valeur
	if (value != null) {
		EPMessages.GROUP_OPTION_CHECK_DEFINED.sender()
			.replace("{group}", group.getFriendlyIdentifier().orElse(groupName))
			.replace("{option}", option)
			.replace("{type}", typeGroup)
			.replace("{value}", Text.of(value))
			.sendTo(player);
	// Il n'y a pas de valeur
	} else {
		EPMessages.GROUP_OPTION_CHECK_UNDEFINED.sender()
			.replace("{group}", group.getFriendlyIdentifier().orElse(groupName))
			.replace("{option}", option)
			.replace("{type}", typeGroup)
			.sendTo(player);
	}
	return CompletableFuture.completedFuture(true);
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:25,代码来源:EPGroupOptionCheck.java

示例6: setBalance

import org.spongepowered.api.service.context.Context; //导入依赖的package包/类
@Override
public TransactionResult setBalance(final Currency currency, final BigDecimal after, final Cause cause, final Set<Context> contexts) {
	TransactionType transaction = TransactionTypes.WITHDRAW;
	
	BigDecimal before = this.getBalance(currency);
	BigDecimal amount = before.subtract(after);
	
	// Si le changement est supérieur ou égal à 0 c'est que l'on dépose de l'argent
	if (amount.compareTo(BigDecimal.ZERO) >= 0) {
		transaction = TransactionTypes.DEPOSIT;
	}
	
	// Transfére
	this.setBalance(currency, after);
	this.log(currency, before, after, transaction, cause);
	
	return new ETransactionResult(this.plugin, this, currency, amount.abs(), contexts, ResultType.SUCCESS, transaction);
}
 
开发者ID:EverCraft,项目名称:EverEconomy,代码行数:19,代码来源:EAccount.java

示例7: resetBalances

import org.spongepowered.api.service.context.Context; //导入依赖的package包/类
@Override
public Map<Currency, TransactionResult> resetBalances(final Cause cause, final Set<Context> contexts) {		
	Map<Currency, TransactionResult> list = new HashMap<Currency, TransactionResult>();
	// Pour tous les monnaies
	for (Currency currency : this.currencies.keySet()){
		TransactionType transaction = TransactionTypes.WITHDRAW;
		
		BigDecimal before = this.getBalance(currency);
		BigDecimal after = getDefaultBalance(currency);
		BigDecimal amount = before.subtract(after);

		// Si le changement est supérieur ou égal à 0 c'est que l'on dépose de l'argent
		if (amount.compareTo(BigDecimal.ZERO) >= 0) {
			transaction = TransactionTypes.DEPOSIT;
		}
		
		// Transfére
		this.setBalance(currency, after);
		this.log(currency, before, after, transaction, cause);
		
		list.put(currency, new ETransactionResult(this.plugin, this, currency, amount.abs(), contexts, ResultType.SUCCESS, transaction));
	}
	this.plugin.getThreadAsync().execute(() -> this.delete());
	return list;
}
 
开发者ID:EverCraft,项目名称:EverEconomy,代码行数:26,代码来源:EAccount.java

示例8: setIgnored

import org.spongepowered.api.service.context.Context; //导入依赖的package包/类
public CompletableFuture<Void> setIgnored(Player player, Collection<String> permissions)
{
    SubjectData data = player.getTransientSubjectData();
    Set<Context> contexts = Collections.singleton(this.contextInAction);

    return this.clearPermissions(data, contexts)
            .thenCompose(succeed -> CompletableFuture.allOf(this.setPermissions(permissions, data, contexts)))
            .thenRun(() -> this.addIgnoredPermissionsToLog(permissions, player.getUniqueId(), player.getName()));
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:10,代码来源:VirtualChestPermissionManager.java

示例9: command

import org.spongepowered.api.service.context.Context; //导入依赖的package包/类
private CompletableFuture<Boolean> command(final CommandSource player, final String groupName, final String permission, final String worldName) throws EMessageException {
	String typeGroup = EPCommand.getTypeWorld(player, this.plugin.getService().getGroupSubjects(), worldName);
	EGroupSubject group = EPCommand.getGroup(player, this.plugin.getService(), groupName, typeGroup);
	
	Set<Context> contexts = EPContextCalculator.of(worldName);
	Tristate value = group.getPermissionValue(contexts, permission);
	
	// Permission : True
	if (value.equals(Tristate.TRUE)) {
		EPMessages.GROUP_PERMISSION_CHECK_TRUE.sender()
			.replace("{group}", group.getFriendlyIdentifier().orElse(groupName))
			.replace("{permission}", permission)
			.replace("{type}", typeGroup)
			.sendTo(player);
	// Permission : False
	} else if (value.equals(Tristate.FALSE)) {
		EPMessages.GROUP_PERMISSION_CHECK_FALSE.sender()
			.replace("{group}", group.getFriendlyIdentifier().orElse(groupName))
			.replace("{permission}", permission)
			.replace("{type}", typeGroup)
			.sendTo(player);
	// Permission : Undefined
	} else {
		EPMessages.GROUP_PERMISSION_CHECK_UNDEFINED.sender()
			.replace("{group}", group.getFriendlyIdentifier().orElse(groupName))
			.replace("{permission}", permission)
			.replace("{type}", typeGroup)
			.sendTo(player);
	}
	return CompletableFuture.completedFuture(true);
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:32,代码来源:EPGroupPermissionCheck.java

示例10: getLoadedWithPermission

import org.spongepowered.api.service.context.Context; //导入依赖的package包/类
@Override
public Map<Subject, Boolean> getLoadedWithPermission(Set<Context> contexts, String permission) {
	Preconditions.checkNotNull(contexts, "contexts");
	Preconditions.checkNotNull(permission, "permission");
	
	ImmutableMap.Builder<Subject, Boolean> builder = ImmutableMap.builder();
	for (Subject subject : this.identifierSubjects.values()) {
		Tristate value = subject.getPermissionValue(contexts, permission);
		if (!value.equals(Tristate.UNDEFINED)) {
			builder.put(subject, value.asBoolean());
		}
	}
	return builder.build();
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:15,代码来源:EPSubjectCollection.java

示例11: ETransactionResult

import org.spongepowered.api.service.context.Context; //导入依赖的package包/类
public ETransactionResult(final EPlugin<EverEconomy> plugin, final Account account, final Currency currency, 
		final BigDecimal amount, final Set<Context> contexts, final ResultType result, final TransactionType transaction) {
	this.account = account;
	this.currency = currency;
	this.amount = amount;
	this.contexts = contexts;
	this.result = result;
	this.transaction = transaction;
	
	plugin.getELogger().debug("Event EconomyTransactionEvent : (Account='" + this.account.getIdentifier() +"')");
	EconomyTransactionEvent event = new EEconomyTransactionEvent(Cause.source(plugin).build(), this);
	plugin.getGame().getEventManager().post(event);
}
 
开发者ID:EverCraft,项目名称:EverEconomy,代码行数:14,代码来源:ETransactionResult.java

示例12: getGroup

import org.spongepowered.api.service.context.Context; //导入依赖的package包/类
@Override
public Optional<SubjectReference> getGroup(final Set<Context> contexts) {
	Optional<SubjectReference> group = this.transientData.getGroup(contexts);
	if (group.isPresent()) return group;
	
    return this.data.getGroup(contexts);
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:8,代码来源:EPUserSubject.java

示例13: setPermission

import org.spongepowered.api.service.context.Context; //导入依赖的package包/类
@Nonnull
@Override
public CompletableFuture<Boolean> setPermission(@Nonnull Set<Context> contexts, @Nonnull String permission, @Nonnull Tristate value) {
    return handle().thenCompose(handle -> handle.setPermission(
            CompatibilityUtil.convertContexts(contexts),
            permission,
            CompatibilityUtil.convertTristate(value)
    ));
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:10,代码来源:SubjectDataProxy.java

示例14: getAllOptions

import org.spongepowered.api.service.context.Context; //导入依赖的package包/类
@Override
public Map<Set<Context>, Map<String, String>> getAllOptions() {
	 ImmutableMap.Builder<Set<Context>, Map<String, String>> builder = ImmutableMap.builder();
	 for (Entry<String, Map<String, String>> option : this.options.entrySet()) {
	 	builder.put(EPContextCalculator.of(option.getKey()), ImmutableMap.copyOf(option.getValue()));
	 }
	 return builder.build();
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:9,代码来源:EPSubjectData.java

示例15: getGroup

import org.spongepowered.api.service.context.Context; //导入依赖的package包/类
private Optional<SubjectReference> getGroup(final Subject subject, final Set<Context> contexts) {
Preconditions.checkNotNull(subject, "subject");
Preconditions.checkNotNull(contexts, "contexts");

List<SubjectReference> groups = subject.getSubjectData().getParents(contexts);
if (!groups.isEmpty()) {
	return Optional.of(groups.get(0));
}
return Optional.empty();
  }
 
开发者ID:EverCraft,项目名称:EverChat,代码行数:11,代码来源:EChatService.java


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