• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CommandException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: execute

import org.spongepowered.api.util.command.CommandException; //导入依赖的package包/类
@Override
public CommandResult execute(Optional<Claim> claimOptional, Tenant tenant, CommandContext args, Player player) throws CommandException {
    if (claimOptional.isPresent()){
        Claim claim = claimOptional.get();
        try {
            if (claim.getOwner().getId().equals(player.getUniqueId()) || player.hasPermission(Permissions.ADMINUNCLAIM))
            {
                plugin.getClaimManager().removeClaim(player.getLocation());
                plugin.getLanguageManager().sendMessage(player, Messages.LAND_UNCLAIMED, TextColors.GREEN);
            }
            else
                plugin.getLanguageManager().sendMessage(player, Messages.NO_ACCES_TO_UNCLAIM, TextColors.RED);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }else {
        plugin.getLanguageManager().sendMessage(player, Messages.NO_CLAIM_TO_UNCLAIM, TextColors.YELLOW);
    }
    return CommandResult.success();
}
 
开发者ID:thomas15v,项目名称:ChunkLord,代码行数:22,代码来源:UnclaimCommand.java


示例2: execute

import org.spongepowered.api.util.command.CommandException; //导入依赖的package包/类
@Override
public CommandResult execute(Optional<Claim> claimOptional, Tenant tenant, CommandContext args, Player player) throws CommandException {
    if (claimOptional.isPresent()){
        Claim claim = claimOptional.get();
        languageManager.sendMessage(player, Messages.CLAIM_INFO, TextColors.AQUA,
                player.getWorld().getName(),
                String.valueOf(claim.getX()),
                String.valueOf(claim.getZ()),
                claim.getOwner().getName(),
                "",
                "");
    }else {
        languageManager.sendMessage(player, Messages.NO_CLAIM_FOUND, TextColors.YELLOW);
    }
    return CommandResult.success();
}
 
开发者ID:thomas15v,项目名称:ChunkLord,代码行数:17,代码来源:ClaimInfoCommand.java


示例3: onGameInitialization

import org.spongepowered.api.util.command.CommandException; //导入依赖的package包/类
@Listener
public final void onGameInitialization(GameInitializationEvent event) {
	CommandSpec commandSpec = CommandSpec.builder()
			.description(Texts.of("Hello World Command"))
			.permission("myplugin.command.helloworld")
			.executor(new CommandExecutor() {
				@Override
				public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
					throw new InvocationCommandException(Texts.of("bad boy command failure"), new IllegalStateException("root cause IllegalStateException"));
				}
			})
			.build();

	commandMapping = game.getCommandDispatcher().register(plugin, commandSpec, TEST_BAD_COMMAND).get();
}
 
开发者ID:vorburger,项目名称:SwissKnightMinecraft,代码行数:16,代码来源:TestPlugin.java


示例4: execute

import org.spongepowered.api.util.command.CommandException; //导入依赖的package包/类
@Override
public CommandResult execute(Optional<Claim> claimOptional, Tenant tenant, CommandContext args, Player player) throws CommandException {;
    if (claimOptional.isPresent()){
        languageManager.sendMessage(player, Messages.ALREADY_CLAIMED_BY, TextColors.RED,
                claimOptional.get().getOwner().getName());
    }else {
        plugin.getClaimManager().addClaim(player.getWorld(), new Claim(tenant, player.getLocation().getBlockPosition().div(16)));
        languageManager.sendMessage(player, Messages.LAND_CLAIMED, TextColors.GREEN);
    }
    return CommandResult.success();
}
 
开发者ID:thomas15v,项目名称:ChunkLord,代码行数:12,代码来源:ClaimCommand.java


示例5: execute

import org.spongepowered.api.util.command.CommandException; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    if (src instanceof Player) {
        Player player = (Player) src;
        return execute(plugin.getClaimManager().getClaimFor(player.getLocation()),
                plugin.getTenantManager().getTentant(player).get(), args, player);
    }
    src.sendMessage(Texts.of("Only a player can execute this command!"));
    return CommandResult.empty();
}
 
开发者ID:thomas15v,项目名称:ChunkLord,代码行数:11,代码来源:AbstractClaimCommand.java


示例6: execute

import org.spongepowered.api.util.command.CommandException; //导入依赖的package包/类
@Override
public final CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    try {
        if (args.hasAny("username")) {
            String username = args.<String>getOne("username").get();
            Profile profile = profileResolver.findByName(username);
            if (profile == null) {
                src.sendMessage(Texts.of(TextColors.RED,"Sorry failed to find a profile for that username."));
                return CommandResult.empty();
            }
            src.sendMessage(Texts.of(TextColors.GREEN, "Found a profile for the provided username."));
            ClickAction.SuggestCommand clickAction = new ClickAction.SuggestCommand(profile.getUniqueId().toString());
            Text clickableUUID = Texts.builder()
                    .append(Texts.of(TextColors.GREEN, profile.getUniqueId().toString()))
                    .onClick(clickAction).build();
            src.sendMessage(Texts.of(TextColors.BLUE, profile.getName(), TextColors.GRAY, ": ", clickableUUID));

            MinecraftSkin skin = game.getServiceManager().provideUnchecked(SkinResolverService.class).getSkin(profile.getUniqueId());
            if (skin == null) {
                src.sendMessage(Texts.of(TextColors.RED, "Failed to resolve skin for the profile."));
            } else {
                src.sendMessage(Texts.of(TextColors.GREEN, "Skin type: ", skin.type));
                ColorMapping mapping = ColorMapping.matchColor(new Color(skin.texture.getRGB(12, 12)));
                String message = String.format("The matching block was %s and the color was %s", mapping.equivalentBlock.toString(), mapping.dyeColor.orNull() == null ? "null" : mapping.dyeColor.toString());

                if (src instanceof Player) {
                    Player player = (Player) src;
                    Vector3d rot = player.getRotation();
                    int value = floor_double((double)(rot.getX() * 4.0F / 360.0F) + 0.5D) & 3;
                    System.out.println(value);
                    player.sendMessage(Texts.of((rot.getX() * 4.0F / 360.0F) + 0.5D));
                    player.sendMessage(Texts.of(rot.getX() * 4.0F / 360.0F));
                    player.sendMessage(Texts.of(value));
                    int pos = ((value < 0 ? -value : value) % 4);
                    Direction buildDirection = null;
                    switch (pos) {
                        case 0:
                            // South
                            System.out.println("SOUTH");
                            player.sendMessage(Texts.of("SOUTH"));
                            buildDirection = Direction.SOUTH;
                            break;
                        case 1:
                            // WEST
                            System.out.println("WEST");
                            player.sendMessage(Texts.of("WEST"));
                            buildDirection = Direction.WEST;
                            break;
                        case 2:
                            // NORTH
                            System.out.println("NORTH");
                            player.sendMessage(Texts.of("NORTH"));
                            buildDirection = Direction.NORTH;
                            break;
                        case 3:
                            // EAST
                            System.out.println("EAST");
                            player.sendMessage(Texts.of("EAST"));
                            buildDirection = Direction.EAST;
                            break;
                    }

                }
            }
            return CommandResult.success();
        }
        return CommandResult.empty();
    } catch (Throwable th) {
        th.printStackTrace();
        return CommandResult.empty();
    }
}
 
开发者ID:modwizcode,项目名称:Statue,代码行数:73,代码来源:TestResolveCommand.java


示例7: getSuggestions

import org.spongepowered.api.util.command.CommandException; //导入依赖的package包/类
@Override
public List<String> getSuggestions(CommandSource source, String arguments) throws CommandException {
    return new ArrayList<String>();
}
 
开发者ID:Aaron1011,项目名称:WhoWas,代码行数:5,代码来源:SpongeCommandHandler.java


示例8: execute

import org.spongepowered.api.util.command.CommandException; //导入依赖的package包/类
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    return CommandResult.success();
}
 
开发者ID:thomas15v,项目名称:ChunkLord,代码行数:4,代码来源:ChunkLordCommand.java


示例9: execute

import org.spongepowered.api.util.command.CommandException; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    ChunkLordPlugin.getInstance().getLanguageManager().sendMessage(src, Messages.HELP_MESSAGE, TextColors.AQUA);
    return CommandResult.success();
}
 
开发者ID:thomas15v,项目名称:ChunkLord,代码行数:6,代码来源:HelpCommand.java


示例10: call

import org.spongepowered.api.util.command.CommandException; //导入依赖的package包/类
@Override
public boolean call(CommandSource source, String arguments, List<String> parents) throws CommandException {
    // TODO: include the parents perhaps?
    return dispatcher.dispatch(source, arguments);
}
 
开发者ID:DSH105,项目名称:Influx,代码行数:6,代码来源:InfluxSpongeCallable.java


示例11: getSuggestions

import org.spongepowered.api.util.command.CommandException; //导入依赖的package包/类
@Override
public List<String> getSuggestions(CommandSource source, String arguments) throws CommandException {
    // TODO: implement this?
    return new ArrayList<>();
}
 
开发者ID:DSH105,项目名称:Influx,代码行数:6,代码来源:InfluxSpongeCallable.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LexerErrorInterface类代码示例发布时间:2022-05-23
下一篇:
Java Session类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap