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


Java TranslatedParserException类代码示例

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


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

示例1: provide

import org.cubeengine.libcube.service.command.TranslatedParserException; //导入依赖的package包/类
@Override
public BaseAccount.Virtual provide(CommandInvocation invocation)
{
    if (invocation.getCommandSource() instanceof User)
    {
        User user = (User) invocation.getCommandSource();
        List<BaseAccount.Virtual> banks = service.getBanks(user, AccessLevel.SEE);
        if (banks.isEmpty())
        {
            throw new TranslatedParserException(i18n.translate(invocation.getContext(Locale.class), NEGATIVE,
                    "You have no banks available!"));
        }
        return banks.get(0);
    }
    throw new TranslatedParserException(i18n.translate(invocation.getContext(Locale.class), NEGATIVE,
            "You have to specify a bank!"));
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:18,代码来源:VirtualAccountParser.java

示例2: parse

import org.cubeengine.libcube.service.command.TranslatedParserException; //导入依赖的package包/类
@Override
public BaseAccount.Unique parse(Class type, CommandInvocation invocation) throws ParserException
{
    String arg = invocation.currentToken();
    User user = (User)invocation.providers().read(User.class, User.class, invocation);
    Optional<BaseAccount.Unique> target = getAccount(user).filter(a -> {
            Object cmdSource = invocation.getCommandSource();
            return !(cmdSource instanceof Subject && a.isHidden()
                    && !((Subject) cmdSource).hasPermission(module.perms().ACCESS_SEE.getId()));
        });
    if (!target.isPresent())
    {
        throw new TranslatedParserException(i18n.translate(invocation.getContext(Locale.class), NEGATIVE,
                "No account found for {user}!", arg));
    }
    return target.get();
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:18,代码来源:UniqueAccountParser.java

示例3: provide

import org.cubeengine.libcube.service.command.TranslatedParserException; //导入依赖的package包/类
@Override
public BaseAccount.Unique provide(CommandInvocation invocation)
{
    if (!(invocation.getCommandSource() instanceof User))
    {
        throw new TranslatedParserException(i18n.translate(invocation.getContext(Locale.class), NEGATIVE,
                "You have to specify a user!"));
    }
    User user = (User) invocation.getCommandSource();
    Optional<BaseAccount.Unique> account = getAccount(user);
    if (!account.isPresent())
    {
        throw new TranslatedParserException(i18n.translate(invocation.getContext(Locale.class), NEGATIVE,
                "You have no account!"));
    }
    return account.get();
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:18,代码来源:UniqueAccountParser.java

示例4: provide

import org.cubeengine.libcube.service.command.TranslatedParserException; //导入依赖的package包/类
@Override
public Region provide(CommandInvocation invocation)
{
    if (invocation.getCommandSource() instanceof CommandSource)
    {
        Region activeRegion = manager.getActiveRegion(((CommandSource) invocation.getCommandSource()));
        if (activeRegion != null)
        {
            return activeRegion;
        }
    }
    throw new TranslatedParserException(
            i18n.translate(invocation.getContext(Locale.class), MessageType.NEGATIVE,
                                "You need to provide a region"));

}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:17,代码来源:RegionParser.java

示例5: parse

import org.cubeengine.libcube.service.command.TranslatedParserException; //导入依赖的package包/类
@Override
public BaseAccount.Virtual parse(Class type, CommandInvocation invocation) throws ParserException
{
    String arg = invocation.consume(1);
    Optional<BaseAccount.Virtual> target = Optional.empty();
    if (service.hasAccount(arg))
    {
        target = service.getOrCreateAccount(arg).filter(a -> a instanceof BaseAccount.Virtual).map(BaseAccount.Virtual.class::cast);
    }
    if (!target.isPresent())
    {
        throw new TranslatedParserException(i18n.translate(invocation.getContext(Locale.class), NEGATIVE, "There is no bank account named {input#name}!", arg));
    }
    return target.get();
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:16,代码来源:VirtualAccountParser.java

示例6: parse

import org.cubeengine.libcube.service.command.TranslatedParserException; //导入依赖的package包/类
@Override
public Announcement parse(Class clazz, CommandInvocation invocation) throws ParserException
{
    String name = invocation.consume(1);
    Announcement announcement = manager.getAnnouncement(name);
    if (announcement == null)
    {
        Text trans = i18n.translate(invocation.getContext(Locale.class), NEGATIVE, "{input#announcement} was not found!", name);
        throw new TranslatedParserException(trans);
    }
    return announcement;
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:13,代码来源:AnnouncementParser.java

示例7: parse

import org.cubeengine.libcube.service.command.TranslatedParserException; //导入依赖的package包/类
@Override
public LookupData parse(Class clazz, CommandInvocation ci) throws ParserException
{
    String token = ci.consume(1);
    if (!types.keySet().contains(token.toLowerCase()))
    {
        throw new TranslatedParserException(i18n.translate(ci.getContext(Locale.class), NEGATIVE, "{input} is not a valid log-type. Use chest, container, player, block or kills instead!", token));
    }
    LookupData data = types.get(token.toLowerCase()).copy();
    return data.withCreator(((Player) ci.getCommandSource()).getUniqueId());
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:12,代码来源:LookupDataParser.java

示例8: parse

import org.cubeengine.libcube.service.command.TranslatedParserException; //导入依赖的package包/类
@Override
public Region parse(Class aClass, CommandInvocation invocation) throws ParserException
{
    String token = invocation.consume(1).toLowerCase();
    if (invocation.getCommandSource() instanceof Locatable)
    {
        World world = ((Locatable) invocation.getCommandSource()).getWorld();
        Region region = manager.getRegions(world.getUniqueId()).get(token);
        if (region != null)
        {
            return region;
        }
        if ("world".equals(token))
        {
            region = manager.getWorldRegion(world.getUniqueId());
            if (region != null)
            {
                return region;
            }
        }
    }
    for (Map.Entry<UUID, Map<String, Region>> perWorld : manager.getRegions().entrySet())
    {
        for (Map.Entry<String, Region> entry : perWorld.getValue().entrySet())
        {
            if (entry.getValue().getContext().getValue().equalsIgnoreCase(token))
            {
                return entry.getValue();
            }
        }
    }
    if (token.endsWith(".world"))
    {
        String worldName = token.replaceAll(".world$", "");
        Optional<WorldProperties> worldProp = Sponge.getServer().getWorldProperties(worldName);
        if (worldProp.isPresent())
        {
            return manager.getWorldRegion(worldProp.get().getUniqueId());
        }
        else
        {
            throw new TranslatedParserException(
                    i18n.translate(invocation.getContext(Locale.class), MessageType.NEGATIVE,
                            "Unknown World {name} for world-region", token, worldName));
        }
    }
    if ("global".equals(token))
    {
        return manager.getGlobalRegion();
    }

    throw new TranslatedParserException(
            i18n.translate(invocation.getContext(Locale.class), MessageType.NEGATIVE,
                                "There is no such Region as {name}", token));
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:56,代码来源:RegionParser.java


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