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

项目:PixelCamMod    文件:CamCommand.java   
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if(sender != mc.player) throw new CommandException("commands.generic.permission");
    if(!mc.player.isCreative() && !mc.player.isSpectator()) throw new CommandException("pixelcam.commands.error.gamemode");

    if(args.length <= 0) throw new CommandException(getUsage(sender));

    String base = args[0];

    args = ArrayUtils.remove(args, 0);

    if(base.equalsIgnoreCase("clear")) clear(args);
    else if(base.equalsIgnoreCase("goto")) goTo(args);
    else if(base.equalsIgnoreCase("p")) p(args);
    else if(base.equalsIgnoreCase("start")) start(args);
    else if(base.equalsIgnoreCase("stop")) stop(args);
    else if(base.equalsIgnoreCase("focus")) focus(args);
    else if(base.equalsIgnoreCase("save")) save(args);
    else if(base.equalsIgnoreCase("load")) load(args);
    else if(base.equalsIgnoreCase("list")) list(args);
    else if(base.equalsIgnoreCase("help")) help(args);
    else throw new CommandNotFoundException("pixelcam.commands.cam.notFound");
}
项目:morecommands    文件:CommandMacro.java   
@Override
public String execute(CommandSender sender, String[] params) throws CommandException {
    ServerPlayerSettings settings = getPlayerSettings(getSenderAsEntity(sender.getMinecraftISender(), EntityPlayerMP.class));
    AppliedPatches playerInfo = PatchManager.instance().getAppliedPatchesForPlayer(getSenderAsEntity(sender.getMinecraftISender(), EntityPlayerMP.class));
    if (playerInfo != null && playerInfo.wasPatchSuccessfullyApplied(PatchList.CLIENT_MODDED)) throw new CommandException(new CommandNotFoundException());

    if (params.length > 0) {
        if ((params[0].equalsIgnoreCase("delete") || params[0].equalsIgnoreCase("del") || params[0].equalsIgnoreCase("remove") || params[0].equalsIgnoreCase("rem")) && params.length > 1) {
            if (!settings.macros.containsKey(params[1])) throw new CommandException("command.macro.notFound", sender, params[1]);
            else {
                settings.macros.remove(params[1]);
            }
        }
        else if ((params[0].equalsIgnoreCase("exec") || params[0].equalsIgnoreCase("execute")) && params.length > 1) {
            List<String> commands = settings.macros.get(params[1]);

            if (commands != null) {
                for (String command : commands)
                    sender.getServer().getCommandManager().executeCommand(sender.getMinecraftISender(), command);
            }
            else throw new CommandException("command.macro.notFound", sender, params[1]);
        }
        else if ((params[0].equalsIgnoreCase("add") || params[0].equalsIgnoreCase("new") || params[0].equalsIgnoreCase("create") || params[0].equalsIgnoreCase("edit")) && params.length > 2) {
            if (settings.macros.containsKey(params[1])) {
                if (params[0].equalsIgnoreCase("add") || params[0].equalsIgnoreCase("new") || params[0].equalsIgnoreCase("create"))
                    throw new CommandException("command.macro.exists", sender, params[1]);
                settings.macros.remove(params[1]);
            }

            settings.macros.put(params[1], Lists.newArrayList(rejoinParams(Arrays.copyOfRange(params, 2, params.length)).split(";")));
            sender.sendLangfileMessage("command.macro.createSuccess", params[1]);
        }
        else throw new CommandException("command.generic.invalidUsage", sender, this.getCommandName());
    }
    else throw new CommandException("command.generic.invalidUsage", sender, this.getCommandName());

    return null;
}
项目:morecommands    文件:CommandAlias.java   
@Override
public void onEvent(CommandEvent event) {
    if (event.getCommand() instanceof DummyCommand && !((DummyCommand) event.getCommand()).isClient()) {
        String command = null;

        if (isSenderOfEntityType(event.getSender(), EntityPlayerMP.class)) {
            AppliedPatches playerInfo = PatchManager.instance().getAppliedPatchesForPlayer(getSenderAsEntity(event.getSender(), EntityPlayerMP.class));
            command = playerInfo != null && playerInfo.wasPatchSuccessfullyApplied(PatchList.CLIENT_MODDED) ? null :
            getPlayerSettings(getSenderAsEntity(event.getSender(), EntityPlayerMP.class)).aliases.get(event.getCommand().getName());

            if (command == null && MoreCommandsConfig.enableGlobalAliases)
                command = GlobalSettings.getInstance().aliases.get(ImmutablePair.of(event.getSender().getEntityWorld().getSaveHandler().getWorldDirectory().getName(), event.getSender().getEntityWorld().provider.getDimensionType().getName())).get(event.getCommand().getName());
            else if (!MoreCommandsConfig.enablePlayerAliases)
                command = null;
        }
        else if (MoreCommandsConfig.enableGlobalAliases)
            command = GlobalSettings.getInstance().aliases.get(ImmutablePair.of(event.getSender().getEntityWorld().getSaveHandler().getWorldDirectory().getName(), event.getSender().getEntityWorld().provider.getDimensionType().getName())).get(event.getCommand().getName());

        if (command != null) {
            event.setException(null);
            event.setCanceled(true);

            command += " " + rejoinParams(event.getParameters());
            MinecraftServer server = event.getSender().getServer() == null ? FMLCommonHandler.instance().getMinecraftServerInstance() : event.getSender().getServer();
            server.getCommandManager().executeCommand(event.getSender(), command);
        }
        else {
            event.setException(new CommandNotFoundException());
            event.setCanceled(true);
        }
    }
}
项目:Progression    文件:CommandHelp.java   
@Override
public boolean processCommand(ICommandSender sender, String[] parameters) throws CommandException {
    List list = this.getSortedPossibleCommands(sender);
    byte b0 = 7;
    int i = (list.size() - 1) / b0;
    boolean flag = false;
    int k;

    try {
        k = parameters.length == 0 ? 0 : net.minecraft.command.CommandBase.parseInt(parameters[0], 1, i + 1) - 1;
    } catch (NumberInvalidException numberinvalidexception) {
        Map map = this.getCommands();
        AbstractCommand icommand = (AbstractCommand) map.get(parameters[0]);

        if (icommand != null) {
            CommandManager.throwError(sender, icommand);
            return true;
        }

        if (MathHelper.parseIntWithDefault(parameters[0], -1) != -1) {
            throw numberinvalidexception;
        }

        throw new CommandNotFoundException();
    }

    int j = Math.min((k + 1) * b0, list.size());
    TextComponentTranslation chatcomponenttranslation1 = new TextComponentTranslation("crafting.commands.help.header", new Object[] { Integer.valueOf(k + 1), Integer.valueOf(i + 1) });
    chatcomponenttranslation1.getStyle().setColor(TextFormatting.DARK_GREEN);
    sender.addChatMessage(chatcomponenttranslation1);

    for (int l = k * b0; l < j; ++l) {
        AbstractCommand icommand1 = (AbstractCommand) list.get(l);
        TextComponentTranslation chatcomponenttranslation = new TextComponentTranslation(CommandManager.getUsage(icommand1), new Object[0]);
        chatcomponenttranslation.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + icommand1.getCommandName() + " "));
        sender.addChatMessage(chatcomponenttranslation);
    }

    return true;
}
项目:Whodunit    文件:CommandDump.java   
@Override
public void processCommand(ICommandSender sender, String[] command) {
    if (command.length < 1)
        throw new CommandSyntaxException();

    String subCommand = command[0];

    if (COMMAND_RESET.equalsIgnoreCase(subCommand)) {
        CallCollector.resetData();
        return;
    }

    if (command.length < 2)
        throw new CommandSyntaxException();

    String location = command[1];

    Integer locationId = locations.getIdForLocation(location);
    if (locationId == null)
        throw new CommandSyntaxException();

    if (COMMAND_DUMP.equalsIgnoreCase(subCommand)) {
        if (command.length != 3)
            throw new CommandSyntaxException();
        if (Setup.mcLocation == null)
            return;

        String format = command[2];

        GraphVisitorFactory formatFactory = outputs.get(format);
        if (formatFactory == null)
            throw new CommandSyntaxException();

        File outputFolder = Setup.getDumpDir();

        File outputFile = createFile(outputFolder, location, formatFactory.getExtension());
        GraphVisitor visitor = formatFactory.create(outputFile);

        CallCollector.visitData(visitor, ImmutableSet.of(locationId));
        Log.info("Stored data to file %s", outputFile);
    } else
        throw new CommandNotFoundException();

}
项目:RuneCraftery    文件:CommandHandler.java   
public int func_71556_a(ICommandSender p_71556_1_, String p_71556_2_) {
   p_71556_2_ = p_71556_2_.trim();
   if(p_71556_2_.startsWith("/")) {
      p_71556_2_ = p_71556_2_.substring(1);
   }

   String[] var3 = p_71556_2_.split(" ");
   String var4 = var3[0];
   var3 = func_71559_a(var3);
   ICommand var5 = (ICommand)this.field_71562_a.get(var4);
   int var6 = this.func_82370_a(var5, var3);
   int var7 = 0;

   try {
      if(var5 == null) {
         throw new CommandNotFoundException();
      }

      if(var5.func_71519_b(p_71556_1_)) {
         if(var6 > -1) {
            EntityPlayerMP[] var8 = PlayerSelector.func_82380_c(p_71556_1_, var3[var6]);
            String var9 = var3[var6];
            EntityPlayerMP[] var10 = var8;
            int var11 = var8.length;

            for(int var12 = 0; var12 < var11; ++var12) {
               EntityPlayerMP var13 = var10[var12];
               var3[var6] = var13.func_70023_ak();

               try {
                  var5.func_71515_b(p_71556_1_, var3);
                  ++var7;
               } catch (CommandException var15) {
                  p_71556_1_.func_70006_a(ChatMessageComponent.func_111082_b(var15.getMessage(), var15.func_74844_a()).func_111059_a(EnumChatFormatting.RED));
               }
            }

            var3[var6] = var9;
         } else {
            var5.func_71515_b(p_71556_1_, var3);
            ++var7;
         }
      } else {
         p_71556_1_.func_70006_a(ChatMessageComponent.func_111077_e("commands.generic.permission").func_111059_a(EnumChatFormatting.RED));
      }
   } catch (WrongUsageException var16) {
      p_71556_1_.func_70006_a(ChatMessageComponent.func_111082_b("commands.generic.usage", new Object[]{ChatMessageComponent.func_111082_b(var16.getMessage(), var16.func_74844_a())}).func_111059_a(EnumChatFormatting.RED));
   } catch (CommandException var17) {
      p_71556_1_.func_70006_a(ChatMessageComponent.func_111082_b(var17.getMessage(), var17.func_74844_a()).func_111059_a(EnumChatFormatting.RED));
   } catch (Throwable var18) {
      p_71556_1_.func_70006_a(ChatMessageComponent.func_111077_e("commands.generic.exception").func_111059_a(EnumChatFormatting.RED));
      var18.printStackTrace();
   }

   return var7;
}
项目:morecommands    文件:DummyCommand.java   
public final void execute(MinecraftServer server, ICommandSender sender, String[] msg) throws CommandException {throw new CommandNotFoundException();}