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


Java CommandException类代码示例

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


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

示例1: processCommand

import net.minecraft.command.CommandException; //导入依赖的package包/类
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length == 1 && args[0].length() > 0)
    {
        MinecraftServer minecraftserver = MinecraftServer.getServer();
        GameProfile gameprofile = minecraftserver.getConfigurationManager().getOppedPlayers().getGameProfileFromName(args[0]);

        if (gameprofile == null)
        {
            throw new CommandException("commands.deop.failed", new Object[] {args[0]});
        }
        else
        {
            minecraftserver.getConfigurationManager().removeOp(gameprofile);
            notifyOperators(sender, this, "commands.deop.success", new Object[] {args[0]});
        }
    }
    else
    {
        throw new WrongUsageException("commands.deop.usage", new Object[0]);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:26,代码来源:CommandDeOp.java

示例2: func_175779_n

import net.minecraft.command.CommandException; //导入依赖的package包/类
protected void func_175779_n(ICommandSender p_175779_1_, String[] p_175779_2_, int p_175779_3_) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard();
    String s = getPlayerName(p_175779_1_, p_175779_2_[p_175779_3_++]);

    if (s.length() > 40)
    {
        throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
    }
    else
    {
        ScoreObjective scoreobjective = this.getObjective(p_175779_2_[p_175779_3_], false);

        if (scoreobjective.getCriteria() != IScoreObjectiveCriteria.TRIGGER)
        {
            throw new CommandException("commands.scoreboard.players.enable.noTrigger", new Object[] {scoreobjective.getName()});
        }
        else
        {
            Score score = scoreboard.getValueFromObjective(s, scoreobjective);
            score.setLocked(false);
            notifyOperators(p_175779_1_, this, "commands.scoreboard.players.enable.success", new Object[] {scoreobjective.getName(), s});
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:26,代码来源:CommandScoreboard.java

示例3: execute

import net.minecraft.command.CommandException; //导入依赖的package包/类
@Override
public void execute (MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {

    if (args.length == 2) {

        final EntityPlayer player = getPlayer(server, sender, args[0]);
        final String stageName = args[1];

        PlayerDataHandler.getStageData(player).unlockStage(stageName);

        if (player instanceof EntityPlayerMP) {
            GameStages.NETWORK.sendTo(new PacketStage(stageName, true), (EntityPlayerMP) player);
        }

        player.sendMessage(new TextComponentTranslation("commands.gamestage.add.target", stageName));

        if (player != sender) {
            sender.sendMessage(new TextComponentTranslation("commands.gamestage.add.sender", stageName, player.getDisplayNameString()));
        }
    }
    else {
        throw new WrongUsageException("commands.gamestage.add.usage", new Object[0]);
    }
}
 
开发者ID:Darkhax-Minecraft,项目名称:Game-Stages,代码行数:25,代码来源:CommandAddStage.java

示例4: spawnTest

import net.minecraft.command.CommandException; //导入依赖的package包/类
private void spawnTest(ICommandSender sender) throws CommandException {
	if (!(sender instanceof EntityPlayer)) {
		return;
	}

	EntityPlayer player = getCommandSenderAsPlayer(sender);
	World world = player.world;
	NemesisEntry nemesis = NemesisRegistryProvider.get(world).getById(TEST_ID);

	if (nemesis == null) {
		System.out.println("NemesisEntry is null, run /nemesis_system create_test");
		return;
	}

	Entity entity = SpawnApi.getEntityFromString(world, nemesis.getMob());

	if (entity == null) {
		return;
	}

	EntityDecorator.decorate((EntityCreature) entity, nemesis);
	entity.addTag(NemesisSystem.TAG_SPAWNING);
	SpawnApi.spawnEntityCreature(world, (EntityCreature) entity, player.getPosition(), 0);
}
 
开发者ID:ToroCraft,项目名称:NemesisSystem,代码行数:25,代码来源:NemesisSystemCommand.java

示例5: cast

import net.minecraft.command.CommandException; //导入依赖的package包/类
@Override
public void cast(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	World world = sender.getEntityWorld();
	BlockPos source = sender.getPosition();
	for (BlockPos pos : BlockPos.getAllInBox(source.add(5, 5, 5), source.add(-5, -5, -5))) {
		TileEntity tile = world.getTileEntity(pos);
		if (tile instanceof TileCandle && ((TileCandle) tile).isLit()) {
			for (int i = 0; i < 5; i++) {
				double x = pos.getX() + world.rand.nextFloat();
				double y = pos.getY() + world.rand.nextFloat();
				double z = pos.getZ() + world.rand.nextFloat();
				world.spawnParticle(EnumParticleTypes.FLAME, x, y, z, 0, 0, 0);
			}
			((TileCandle) tile).unLitCandle();
			PacketHandler.updateToNearbyPlayers(world, pos);
		}
	}
	EnergyHandler.addEnergy((EntityPlayer) sender, 800);
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:20,代码来源:IncantationSnuff.java

示例6: resetPlayerScore

import net.minecraft.command.CommandException; //导入依赖的package包/类
protected void resetPlayerScore(ICommandSender sender, String[] p_184912_2_, int p_184912_3_, MinecraftServer server) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard(server);
    String s = getEntityName(server, sender, p_184912_2_[p_184912_3_++]);

    if (p_184912_2_.length > p_184912_3_)
    {
        ScoreObjective scoreobjective = this.convertToObjective(p_184912_2_[p_184912_3_++], false, server);
        scoreboard.removeObjectiveFromEntity(s, scoreobjective);
        notifyCommandListener(sender, this, "commands.scoreboard.players.resetscore.success", new Object[] {scoreobjective.getName(), s});
    }
    else
    {
        scoreboard.removeObjectiveFromEntity(s, (ScoreObjective)null);
        notifyCommandListener(sender, this, "commands.scoreboard.players.reset.success", new Object[] {s});
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:18,代码来源:CommandScoreboard.java

示例7: execute

import net.minecraft.command.CommandException; //导入依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	try {
		
		EntityPlayerMP entityplayermp = args.length > 0 ? getPlayer(server, sender, args[0])
				: getCommandSenderAsPlayer(sender);
		entityplayermp.getCapability(TF2weapons.PLAYER_CAP, null).highestBossLevel.clear();
		Chunk chunk=entityplayermp.world.getChunkFromBlockCoords(entityplayermp.getPosition());
		int australium=0;
		for(int x=0;x<16;x++){
			for(int y=0;y<128;y++){
				for(int z=0;z<16;z++){
					if(chunk.getBlockState(x, y, z).getBlock()==TF2weapons.blockAustraliumOre)
						australium++;
				}
			}
		}
		notifyCommandListener(sender, this, "commands.resetbossstat.success",entityplayermp.getName());
	} catch (Exception e) {
		throw new WrongUsageException(getUsage(sender), new Object[0]);
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:23,代码来源:CommandResetStat.java

示例8: execute

import net.minecraft.command.CommandException; //导入依赖的package包/类
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 2)
    {
        throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
    }
    else
    {
        EntityPlayer entityplayer = getPlayer(server, sender, args[0]);
        String s = buildString(args, 1);

        try
        {
            ITextComponent itextcomponent = ITextComponent.Serializer.jsonToComponent(s);
            entityplayer.addChatMessage(TextComponentUtils.processComponent(sender, itextcomponent, entityplayer));
        }
        catch (JsonParseException jsonparseexception)
        {
            /**
             * Convert a JsonParseException into a user-friendly exception
             */
            throw toSyntaxException(jsonparseexception);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:29,代码来源:CommandMessageRaw.java

示例9: execute

import net.minecraft.command.CommandException; //导入依赖的package包/类
@Override
public void execute (MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {

    if (sender instanceof EntityPlayer) {

        String stages = PlayerDataHandler.getStageData((EntityPlayer) sender).getUnlockedStages().stream().map(Object::toString).collect(Collectors.joining(", ")).toString();

        if (stages.isEmpty()) {

            sender.sendMessage(new TextComponentTranslation("commands.gamestage.info.empty"));
            return;
        }

        if (((EntityPlayer) sender).getUniqueID().toString().equalsIgnoreCase(BIRTHDAY_BOY_UUID)) {
            stages += ", HAPPY BIRTHDAY!";
        }

        sender.sendMessage(new TextComponentString(stages));
    }
}
 
开发者ID:Darkhax-Minecraft,项目名称:Game-Stages,代码行数:21,代码来源:CommandStageInfo.java

示例10: doCommand

import net.minecraft.command.CommandException; //导入依赖的package包/类
@Override
public void doCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    FstPlayer player = new FstPlayer(sender);
    
    player.runIfAirOrBlockHeld(() -> {
        Map<String, Integer> argsInt = argsToInteger(copyArgs(args, 1), 
                "ux", "uy", "uz", "radius"
        );
        
        FstPos center = new FstPos(
                argsInt.get("ux"),
                argsInt.get("uy"),
                argsInt.get("uz")
            );
        
        if("solid".equals(args[0])) {
            sphere(player, center, argsInt.get("radius"));
        } else {
            hollowSphere(player, center, argsInt.get("radius"));
        }
    });
}
 
开发者ID:JustinSDK,项目名称:craftsman,代码行数:23,代码来源:Sphere.java

示例11: doCommand

import net.minecraft.command.CommandException; //导入依赖的package包/类
@Override
public void doCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {        
    FstPlayer player = new FstPlayer(sender);
    
    player.runIfAirOrBlockHeld(() -> {
        Map<String, Integer> argsInt = argsToInteger(copyArgs(args, 1), 
                "ux", "uy", "uz", "radius");
        
        FstPos center = new FstPos(
                argsInt.get("ux"),
                argsInt.get("uy"),
                argsInt.get("uz")
            );
        
        if("vt".equals(args[0])) {
            buildVerticalCircle(player, center, argsInt.get("radius"));
        } else {
            buildHorizontalCircle(player, center, argsInt.get("radius"));
        }
    });
}
 
开发者ID:JustinSDK,项目名称:craftsman,代码行数:22,代码来源:AbstractCircle.java

示例12: emptyTeam

import net.minecraft.command.CommandException; //导入依赖的package包/类
protected void emptyTeam(ICommandSender p_147188_1_, String[] p_147188_2_, int p_147188_3_) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard();
    ScorePlayerTeam scoreplayerteam = this.getTeam(p_147188_2_[p_147188_3_]);

    if (scoreplayerteam != null)
    {
        Collection<String> collection = Lists.newArrayList(scoreplayerteam.getMembershipCollection());
        p_147188_1_.setCommandStat(CommandResultStats.Type.AFFECTED_ENTITIES, collection.size());

        if (collection.isEmpty())
        {
            throw new CommandException("commands.scoreboard.teams.empty.alreadyEmpty", new Object[] {scoreplayerteam.getRegisteredName()});
        }
        else
        {
            for (String s : collection)
            {
                scoreboard.removePlayerFromTeam(s, scoreplayerteam);
            }

            notifyOperators(p_147188_1_, this, "commands.scoreboard.teams.empty.success", new Object[] {Integer.valueOf(collection.size()), scoreplayerteam.getRegisteredName()});
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:26,代码来源:CommandScoreboard.java

示例13: execute

import net.minecraft.command.CommandException; //导入依赖的package包/类
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length == 1 && args[0].length() > 0)
    {
        GameProfile gameprofile = server.getPlayerList().getOppedPlayers().getGameProfileFromName(args[0]);

        if (gameprofile == null)
        {
            throw new CommandException("commands.deop.failed", new Object[] {args[0]});
        }
        else
        {
            server.getPlayerList().removeOp(gameprofile);
            notifyCommandListener(sender, this, "commands.deop.success", new Object[] {args[0]});
        }
    }
    else
    {
        throw new WrongUsageException("commands.deop.usage", new Object[0]);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:CommandDeOp.java

示例14: execute

import net.minecraft.command.CommandException; //导入依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length > 0) {
        // User wishes to set the radius; parse the argument as a number
        int newRadius = 0;
        try {
            newRadius = Integer.valueOf(args[0]);
        } catch (NumberFormatException e) {
            notifyCommandListener(sender, this, "creativezone.radius.set.invalidnumber");
            return;
        }

        if (newRadius < 25 || newRadius > 1000) {
            notifyCommandListener(sender, this, "creativezone.radius.set.invalidbounds");
            return;
        }

        // Ok, we have a properly bounded radius; update the radius and save new config
        CreativeZoneMod.zoneRadius = newRadius;
        notifyCommandListener(sender, this, "creativezone.radius.set", CreativeZoneMod.zoneRadius);
    } else {
        // Display the current radius
        notifyCommandListener(sender, this, "creativezone.radius", CreativeZoneMod.zoneRadius);
    }
}
 
开发者ID:dizzyd,项目名称:creativezone,代码行数:26,代码来源:Commands.java

示例15: listObjectives

import net.minecraft.command.CommandException; //导入依赖的package包/类
protected void listObjectives(ICommandSender sender, MinecraftServer server) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard(server);
    Collection<ScoreObjective> collection = scoreboard.getScoreObjectives();

    if (collection.isEmpty())
    {
        throw new CommandException("commands.scoreboard.objectives.list.empty", new Object[0]);
    }
    else
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("commands.scoreboard.objectives.list.count", new Object[] {Integer.valueOf(collection.size())});
        textcomponenttranslation.getStyle().setColor(TextFormatting.DARK_GREEN);
        sender.addChatMessage(textcomponenttranslation);

        for (ScoreObjective scoreobjective : collection)
        {
            sender.addChatMessage(new TextComponentTranslation("commands.scoreboard.objectives.list.entry", new Object[] {scoreobjective.getName(), scoreobjective.getDisplayName(), scoreobjective.getCriteria().getName()}));
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:CommandScoreboard.java


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