Java 类net.minecraft.command.CommandException 实例源码

项目:BaseClient    文件:CommandDeOp.java   
/**
 * 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]);
    }
}
项目:BaseClient    文件:CommandScoreboard.java   
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});
        }
    }
}
项目:Game-Stages    文件:CommandAddStage.java   
@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]);
    }
}
项目:NemesisSystem    文件:NemesisSystemCommand.java   
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);
}
项目:Bewitchment    文件:IncantationSnuff.java   
@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);
}
项目:Backmemed    文件:CommandScoreboard.java   
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});
    }
}
项目:Mods    文件:CommandResetStat.java   
@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]);
    }
}
项目:CustomWorldGen    文件:CommandMessageRaw.java   
/**
 * 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);
        }
    }
}
项目:Game-Stages    文件:CommandStageInfo.java   
@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));
    }
}
项目:BaseClient    文件:CommandDeOp.java   
/**
 * 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]);
    }
}
项目:craftsman    文件:Sphere.java   
@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"));
        }
    });
}
项目:craftsman    文件:AbstractCircle.java   
@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"));
        }
    });
}
项目:BaseClient    文件:CommandScoreboard.java   
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()});
        }
    }
}
项目:CustomWorldGen    文件:CommandDeOp.java   
/**
 * 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]);
    }
}
项目:creativezone    文件:Commands.java   
@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);
    }
}
项目:CustomWorldGen    文件:CommandScoreboard.java   
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()}));
        }
    }
}
项目:CustomWorldGen    文件:CommandScoreboard.java   
protected void enablePlayerTrigger(ICommandSender sender, String[] p_184914_2_, int p_184914_3_, MinecraftServer server) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard(server);
    String s = getPlayerName(server, sender, p_184914_2_[p_184914_3_++]);

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

        if (scoreobjective.getCriteria() != IScoreCriteria.TRIGGER)
        {
            throw new CommandException("commands.scoreboard.players.enable.noTrigger", new Object[] {scoreobjective.getName()});
        }
        else
        {
            Score score = scoreboard.getOrCreateScore(s, scoreobjective);
            score.setLocked(false);
            notifyCommandListener(sender, this, "commands.scoreboard.players.enable.success", new Object[] {scoreobjective.getName(), s});
        }
    }
}
项目:NemesisSystem    文件:NemesisSystemCommand.java   
private void create(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length != 3) {
        throw new WrongUsageException("commands.nemesis_system.usage");
    }

    int x, z, dimension;

    if (sender instanceof EntityPlayer) {
        EntityPlayer player = getCommandSenderAsPlayer(sender);
        x = player.getPosition().getX();
        z = player.getPosition().getZ();
        dimension = player.dimension;
    } else {
        x = 0;
        z = 0;
        dimension = 0;
    }

    NemesisEntry nemesis = NemesisBuilder
            .build(sender.getEntityWorld(), args[1], sender.getEntityWorld().rand.nextBoolean(), dimension, i(args[2]), x, z);
    nemesis.register(server.getWorld(senderDimId(sender)));
    notifyCommandListener(sender, this, "commands.nemesis_system.success.create", nemesis.toString());
}
项目:BaseClient    文件:CommandPardonIp.java   
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length == 1 && args[0].length() > 1)
    {
        Matcher matcher = CommandBanIp.field_147211_a.matcher(args[0]);

        if (matcher.matches())
        {
            MinecraftServer.getServer().getConfigurationManager().getBannedIPs().removeEntry(args[0]);
            notifyOperators(sender, this, "commands.unbanip.success", new Object[] {args[0]});
        }
        else
        {
            throw new SyntaxErrorException("commands.unbanip.invalid", new Object[0]);
        }
    }
    else
    {
        throw new WrongUsageException("commands.unbanip.usage", new Object[0]);
    }
}
项目:PurificatiMagicae    文件:CommandIf.java   
private void setSteps(IIfEntryStore store, ICommandSender sender, String act, String res) throws CommandException
{
    int steps;
    switch (act)
    {
        case "unlock":
            steps = PurMag.INSTANCE.getIfRegistry().getEntry(res).getSteps().size();
            break;
        case "lock":
            steps = 0;
            break;
        default:
            throw new WrongUsageException(getUsage(sender));
    }
    store.setSteps(res, steps);
}
项目:BaseClient    文件:CommandPardonIp.java   
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length == 1 && args[0].length() > 1)
    {
        Matcher matcher = CommandBanIp.field_147211_a.matcher(args[0]);

        if (matcher.matches())
        {
            MinecraftServer.getServer().getConfigurationManager().getBannedIPs().removeEntry(args[0]);
            notifyOperators(sender, this, "commands.unbanip.success", new Object[] {args[0]});
        }
        else
        {
            throw new SyntaxErrorException("commands.unbanip.invalid", new Object[0]);
        }
    }
    else
    {
        throw new WrongUsageException("commands.unbanip.usage", new Object[0]);
    }
}
项目:BaseClient    文件:CommandMessageRaw.java   
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 2)
    {
        throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
    }
    else
    {
        EntityPlayer entityplayer = getPlayer(sender, args[0]);
        String s = buildString(args, 1);

        try
        {
            IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
            entityplayer.addChatMessage(ChatComponentProcessor.processComponent(sender, ichatcomponent, entityplayer));
        }
        catch (JsonParseException jsonparseexception)
        {
            Throwable throwable = ExceptionUtils.getRootCause(jsonparseexception);
            throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {throwable == null ? "" : throwable.getMessage()});
        }
    }
}
项目:NemesisSystem    文件:NemesisSystemCommand.java   
private void spawn(ICommandSender sender, String[] args) throws CommandException {
    if (!(sender instanceof EntityPlayer)) {
        return;
    }

    if (args.length != 2) {
        throw new WrongUsageException("commands.nemesis_system.usage");
    }

    EntityPlayer player = getCommandSenderAsPlayer(sender);
    World world = player.world;

    INemesisRegistry registry = NemesisRegistryProvider.get(world);
    NemesisEntry nemesis = registry.getByName(args[1]);

    SpawnHandler.spawnNemesis(world, player.getPosition(), nemesis);
}
项目:DecompiledMinecraft    文件:CommandScoreboard.java   
protected void listObjectives(ICommandSender p_147196_1_) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard();
    Collection<ScoreObjective> collection = scoreboard.getScoreObjectives();

    if (collection.size() <= 0)
    {
        throw new CommandException("commands.scoreboard.objectives.list.empty", new Object[0]);
    }
    else
    {
        ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.scoreboard.objectives.list.count", new Object[] {Integer.valueOf(collection.size())});
        chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
        p_147196_1_.addChatMessage(chatcomponenttranslation);

        for (ScoreObjective scoreobjective : collection)
        {
            p_147196_1_.addChatMessage(new ChatComponentTranslation("commands.scoreboard.objectives.list.entry", new Object[] {scoreobjective.getName(), scoreobjective.getDisplayName(), scoreobjective.getCriteria().getName()}));
        }
    }
}
项目:DecompiledMinecraft    文件:CommandScoreboard.java   
protected ScoreObjective getObjective(String name, boolean edit) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard();
    ScoreObjective scoreobjective = scoreboard.getObjective(name);

    if (scoreobjective == null)
    {
        throw new CommandException("commands.scoreboard.objectiveNotFound", new Object[] {name});
    }
    else if (edit && scoreobjective.getCriteria().isReadOnly())
    {
        throw new CommandException("commands.scoreboard.objectiveReadOnly", new Object[] {name});
    }
    else
    {
        return scoreobjective;
    }
}
项目:DecompiledMinecraft    文件:CommandOp.java   
/**
 * 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.getPlayerProfileCache().getGameProfileForUsername(args[0]);

        if (gameprofile == null)
        {
            throw new CommandException("commands.op.failed", new Object[] {args[0]});
        }
        else
        {
            minecraftserver.getConfigurationManager().addOp(gameprofile);
            notifyOperators(sender, this, "commands.op.success", new Object[] {args[0]});
        }
    }
    else
    {
        throw new WrongUsageException("commands.op.usage", new Object[0]);
    }
}
项目:Backmemed    文件:CommandPardonIp.java   
/**
 * 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() > 1)
    {
        Matcher matcher = CommandBanIp.IP_PATTERN.matcher(args[0]);

        if (matcher.matches())
        {
            server.getPlayerList().getBannedIPs().removeEntry(args[0]);
            notifyCommandListener(sender, this, "commands.unbanip.success", new Object[] {args[0]});
        }
        else
        {
            throw new SyntaxErrorException("commands.unbanip.invalid", new Object[0]);
        }
    }
    else
    {
        throw new WrongUsageException("commands.unbanip.usage", new Object[0]);
    }
}
项目:DecompiledMinecraft    文件:CommandSetDefaultSpawnpoint.java   
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    BlockPos blockpos;

    if (args.length == 0)
    {
        blockpos = getCommandSenderAsPlayer(sender).getPosition();
    }
    else
    {
        if (args.length != 3 || sender.getEntityWorld() == null)
        {
            throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]);
        }

        blockpos = parseBlockPos(sender, args, 0, true);
    }

    sender.getEntityWorld().setSpawnPoint(blockpos);
    MinecraftServer.getServer().getConfigurationManager().sendPacketToAllPlayers(new S05PacketSpawnPosition(blockpos));
    notifyOperators(sender, this, "commands.setworldspawn.success", new Object[] {Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
}
项目:BaseClient    文件:CommandScoreboard.java   
protected ScoreObjective getObjective(String name, boolean edit) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard();
    ScoreObjective scoreobjective = scoreboard.getObjective(name);

    if (scoreobjective == null)
    {
        throw new CommandException("commands.scoreboard.objectiveNotFound", new Object[] {name});
    }
    else if (edit && scoreobjective.getCriteria().isReadOnly())
    {
        throw new CommandException("commands.scoreboard.objectiveReadOnly", new Object[] {name});
    }
    else
    {
        return scoreobjective;
    }
}
项目:MCOpts    文件:Parameter.java   
protected <L> L get(List<L> list, int idx) throws CommandException
{
    if (!isSet())
        throw NotSetException.create(this, idx);
    if (list.isEmpty())
        throw ArgumentMissingException.create(this, idx);
    return list.get(idx);
}
项目:MCOpts    文件:Parameters.java   
protected void testAdd(String name) throws CommandException
{
    if (!restrictFlags.containsKey(name))
        throw ParameterUnknownException.create(name);

    int restrict = restrictFlags.get(name);
    if (!declaredFlags.contains(name) && (restrict >= 0 && params.get(name).size() >= restrict))
        throw ParameterTooManyArgumentsException.create(name);
}
项目:BaseClient    文件:CommandPublishLocalServer.java   
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    String s = MinecraftServer.getServer().shareToLAN(WorldSettings.GameType.SURVIVAL, false);

    if (s != null)
    {
        notifyOperators(sender, this, "commands.publish.started", new Object[] {s});
    }
    else
    {
        notifyOperators(sender, this, "commands.publish.failed", new Object[0]);
    }
}
项目:DecompiledMinecraft    文件:CommandScoreboard.java   
protected void listPlayers(ICommandSender p_147195_1_, String[] p_147195_2_, int p_147195_3_) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard();

    if (p_147195_2_.length > p_147195_3_)
    {
        String s = getEntityName(p_147195_1_, p_147195_2_[p_147195_3_]);
        Map<ScoreObjective, Score> map = scoreboard.getObjectivesForEntity(s);
        p_147195_1_.setCommandStat(CommandResultStats.Type.QUERY_RESULT, map.size());

        if (map.size() <= 0)
        {
            throw new CommandException("commands.scoreboard.players.list.player.empty", new Object[] {s});
        }

        ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.scoreboard.players.list.player.count", new Object[] {Integer.valueOf(map.size()), s});
        chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
        p_147195_1_.addChatMessage(chatcomponenttranslation);

        for (Score score : map.values())
        {
            p_147195_1_.addChatMessage(new ChatComponentTranslation("commands.scoreboard.players.list.player.entry", new Object[] {Integer.valueOf(score.getScorePoints()), score.getObjective().getDisplayName(), score.getObjective().getName()}));
        }
    }
    else
    {
        Collection<String> collection = scoreboard.getObjectiveNames();
        p_147195_1_.setCommandStat(CommandResultStats.Type.QUERY_RESULT, collection.size());

        if (collection.size() <= 0)
        {
            throw new CommandException("commands.scoreboard.players.list.empty", new Object[0]);
        }

        ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.scoreboard.players.list.count", new Object[] {Integer.valueOf(collection.size())});
        chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
        p_147195_1_.addChatMessage(chatcomponenttranslation1);
        p_147195_1_.addChatMessage(new ChatComponentText(joinNiceString(collection.toArray())));
    }
}
项目:CustomWorldGen    文件:CommandScoreboard.java   
protected void removeTeam(ICommandSender sender, String[] p_184921_2_, int p_184921_3_, MinecraftServer server) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard(server);
    ScorePlayerTeam scoreplayerteam = this.convertToTeam(p_184921_2_[p_184921_3_], server);

    if (scoreplayerteam != null)
    {
        scoreboard.removeTeam(scoreplayerteam);
        notifyCommandListener(sender, this, "commands.scoreboard.teams.remove.success", new Object[] {scoreplayerteam.getRegisteredName()});
    }
}
项目:HardVox    文件:LookPositionCommand.java   
@Override
protected void execute(HVSession session, CommandArgSet args) throws CommandException {
    Entity e = session.owner.getCommandSenderEntity();
    if (e == null) {
        throw new CommandException("There is no entity to look with!");
    }
    RayTraceResult result = RayTraceHelper.rayTraceEntity(e, 128);
    if (result == null || result.typeOfHit != RayTraceResult.Type.BLOCK) {
        throw new CommandException("Not looking at a block!");
    }
    BlockPos position = result.getBlockPos();
    Vector3i vec = new Vector3i(position.getX(), position.getY(), position.getZ());
    positionSetter.accept(session, vec);
}
项目:BaseClient    文件:CommandListPlayers.java   
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    int i = MinecraftServer.getServer().getCurrentPlayerCount();
    sender.addChatMessage(new ChatComponentTranslation("commands.players.list", new Object[] {Integer.valueOf(i), Integer.valueOf(MinecraftServer.getServer().getMaxPlayers())}));
    sender.addChatMessage(new ChatComponentText(MinecraftServer.getServer().getConfigurationManager().func_181058_b(args.length > 0 && "uuids".equalsIgnoreCase(args[0]))));
    sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, i);
}
项目:StructPro    文件:Commands.java   
/**
 * Callback for when the command is executed
 * Primary argument expected as command method
 * Secondary arguments can go in mixed order
 * @param sender The sender who executed the command
 * @param args The arguments that were passed
 * @throws CommandException If execution failed
 */
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    Variables vars = new Variables(Utils.join(args, " "));
    if (args.length <= 0) {
        Evaluator.execHelp(vars, sender);
        return;
    }
    String command = args[0];
    vars.put("command", command);
    if (vars.get(new String[]{"help"}, false)) {
        Evaluator.execHelp(vars, sender);
        return;
    }
    if (command.equalsIgnoreCase("paste")) {
        Evaluator.execPaste(vars, sender);
        return;
    }
    if (command.equalsIgnoreCase("save")) {
        Evaluator.execSave(vars, sender);
        return;
    }
    if (command.equalsIgnoreCase("undo")) {
        Evaluator.execUndo(vars, sender);
        return;
    }
    if (command.equalsIgnoreCase("gen")) {
        Evaluator.execGen(vars, sender);
        return;
    }
    Evaluator.execUnknown(vars, sender);
}
项目:BaseClient    文件:CommandBanPlayer.java   
/**
 * 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.getPlayerProfileCache().getGameProfileForUsername(args[0]);

        if (gameprofile == null)
        {
            throw new CommandException("commands.ban.failed", new Object[] {args[0]});
        }
        else
        {
            String s = null;

            if (args.length >= 2)
            {
                s = getChatComponentFromNthArg(sender, args, 1).getUnformattedText();
            }

            UserListBansEntry userlistbansentry = new UserListBansEntry(gameprofile, (Date)null, sender.getName(), (Date)null, s);
            minecraftserver.getConfigurationManager().getBannedPlayers().addEntry(userlistbansentry);
            EntityPlayerMP entityplayermp = minecraftserver.getConfigurationManager().getPlayerByUsername(args[0]);

            if (entityplayermp != null)
            {
                entityplayermp.playerNetServerHandler.kickPlayerFromServer("You are banned from this server.");
            }

            notifyOperators(sender, this, "commands.ban.success", new Object[] {args[0]});
        }
    }
    else
    {
        throw new WrongUsageException("commands.ban.usage", new Object[0]);
    }
}
项目:BaseClient    文件:CommandTestFor.java   
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 1)
    {
        throw new WrongUsageException("commands.testfor.usage", new Object[0]);
    }
    else
    {
        Entity entity = func_175768_b(sender, args[0]);
        NBTTagCompound nbttagcompound = null;

        if (args.length >= 2)
        {
            try
            {
                nbttagcompound = JsonToNBT.getTagFromJson(buildString(args, 1));
            }
            catch (NBTException nbtexception)
            {
                throw new CommandException("commands.testfor.tagError", new Object[] {nbtexception.getMessage()});
            }
        }

        if (nbttagcompound != null)
        {
            NBTTagCompound nbttagcompound1 = new NBTTagCompound();
            entity.writeToNBT(nbttagcompound1);

            if (!NBTUtil.func_181123_a(nbttagcompound, nbttagcompound1, true))
            {
                throw new CommandException("commands.testfor.failure", new Object[] {entity.getName()});
            }
        }

        notifyOperators(sender, this, "commands.testfor.success", new Object[] {entity.getName()});
    }
}
项目:Bewitchment    文件:IncantationHeal.java   
@SuppressWarnings("ConstantConditions")
@Override
public void cast(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    final EntityLivingBase entity = (EntityLivingBase) sender.getCommandSenderEntity();
    if (entity.isEntityAlive() && entity.getHealth() < entity.getMaxHealth()) {
        entity.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 80, 0));
    }
}