Package net.minecraft.command

Examples of net.minecraft.command.WrongUsageException


  @Override
  public void processCommand(ICommandSender sender, String[] args)
  {
    if ( args.length == 0 )
    {
      throw new WrongUsageException( "commands.ae2.usage" );
    }
    else if ( "help".equals( args[0] ) )
    {
      try
      {
        if ( args.length > 1 )
        {
          Commands c = Commands.valueOf( args[1] );
          throw new WrongUsageException( c.command.getHelp( srv ) );
        }
      }
      catch (Throwable er)
      {
        if ( er instanceof WrongUsageException )
          throw (WrongUsageException) er;
        throw new WrongUsageException( "commands.ae2.usage" );
      }
    }
    else if ( "list".equals( args[0] ) )
    {
      throw new WrongUsageException( Joiner.on( ", " ).join( Commands.values() ) );
    }
    else
    {
      try
      {
        Commands c = Commands.valueOf( args[0] );
        if ( sender.canCommandSenderUseCommand( c.level, getCommandName() ) )
          c.command.call( srv, args, sender );
        else
          throw new WrongUsageException( "commands.ae2.permissions" );
      }
      catch (Throwable er)
      {
        if ( er instanceof WrongUsageException )
          throw (WrongUsageException) er;
        throw new WrongUsageException( "commands.ae2.usage" );
      }
    }
  }
View Full Code Here


                    PacketHandler.INSTANCE.sendTo(new MessageSyncEnergyValues(EnergyValueRegistry.getInstance()), (EntityPlayerMP) commandSender);
                    commandSender.addChatMessage(new ChatComponentTranslation("command.ee3.sync-values.self.success"));
                }
                else
                {
                    throw new WrongUsageException("command.ee3.sync-values.self.denied", new Object[]{coolDown / 1000f});
                }
            }
            else if (args[0].equalsIgnoreCase("all"))
            {
                if (PlayerHelper.isPlayerOp((EntityPlayer) commandSender))
                {
                    LogHelper.info(String.format("Syncing EnergyValues with all players at %s's request", commandSender.getCommandSenderName()));
                    PacketHandler.INSTANCE.sendToAll(new MessageSyncEnergyValues(EnergyValueRegistry.getInstance()));
                    func_152373_a(commandSender, this, "command.ee3.sync-values.all.success", new Object[]{commandSender.getCommandSenderName()});
                }
                else
                {
                    throw new WrongUsageException("command.ee3.sync-values.all.denied");
                }
            }
            else
            {
                throw new WrongUsageException("command.ee3.sync-values.usage");
            }
        }
        else
        {
            throw new WrongUsageException("command.ee3.sync-values.usage");
        }
    }
View Full Code Here

    @Override
    public void processCommand(ICommandSender commandSender, String[] args)
    {
        if (args.length < 3)
        {
            throw new WrongUsageException("command.ee3.set-value.usage");
        }
        else
        {
            Item item = getItemByText(commandSender, args[1]);
            double energyValue = 0;
            int metaData = 0;

            if (args.length >= 3)
            {
                energyValue = parseDoubleWithMin(commandSender, args[2], 0);
            }
            else if (args.length >= 4)
            {
                metaData = parseInt(commandSender, args[3]);
            }

            ItemStack itemStack = new ItemStack(item, 1, metaData);

            if (args.length >= 5)
            {
                String stringNBTData = func_147178_a(commandSender, args, 4).getUnformattedText();

                try
                {
                    NBTBase nbtBase = JsonToNBT.func_150315_a(stringNBTData);

                    if (!(nbtBase instanceof NBTTagCompound))
                    {
                        func_152373_a(commandSender, this, "command.ee3.set-value.tagError", new Object[]{"Not a valid tag"});
                        return;
                    }

                    itemStack.setTagCompound((NBTTagCompound) nbtBase);
                }
                catch (Exception exception)
                {
                    func_152373_a(commandSender, this, "command.ee3.set-value.tagError", new Object[]{exception.getMessage()});
                    return;
                }
            }

            WrappedStack wrappedStack = new WrappedStack(itemStack);
            EnergyValue newEnergyValue = new EnergyValue(energyValue);

            if (wrappedStack != null && newEnergyValue != null && Float.compare(newEnergyValue.getEnergyValue(), 0) > 0)
            {
                if (args[0].equalsIgnoreCase("pre"))
                {
                    Map<WrappedStack, EnergyValue> preAssignedValues = SerializationHelper.readEnergyValueStackMapFromJsonFile(Files.PRE_ASSIGNED_ENERGY_VALUES);
                    preAssignedValues.put(wrappedStack, newEnergyValue);
                    SerializationHelper.writeEnergyValueStackMapToJsonFile(Files.PRE_ASSIGNED_ENERGY_VALUES, preAssignedValues);
                    EnergyValueRegistry.getInstance().setShouldRegenNextRestart(true);
                }
                else if (args[0].equalsIgnoreCase("post"))
                {
                    EnergyValueRegistry.getInstance().setEnergyValue(wrappedStack, newEnergyValue);
                    Map<WrappedStack, EnergyValue> postAssignedValues = SerializationHelper.readEnergyValueStackMapFromJsonFile(Files.POST_ASSIGNED_ENERGY_VALUES);
                    postAssignedValues.put(wrappedStack, newEnergyValue);
                    SerializationHelper.writeEnergyValueStackMapToJsonFile(Files.POST_ASSIGNED_ENERGY_VALUES, postAssignedValues);
                    PacketHandler.INSTANCE.sendToAll(new MessageSetEnergyValue(wrappedStack, newEnergyValue));
                }

                // Notify admins and log the value change
                func_152373_a(commandSender, this, "command.ee3.set-value.success", new Object[]{commandSender.getCommandSenderName(), args[0], wrappedStack.toString(), newEnergyValue.toString()});
                LogHelper.info(String.format("%s set the EnergyValue of %s to %s", commandSender.getCommandSenderName(), wrappedStack, newEnergyValue));
            }
            else
            {
                throw new WrongUsageException("command.ee3.set-value.usage");
            }
        }
    }
View Full Code Here

            LogHelper.info(String.format("args[%s]: %s", i, args[i]));
        }

        if (args.length < 2)
        {
            throw new WrongUsageException("command.ee3.set-current-item-value.usage");
        }
        else
        {
            ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem().copy();
            double energyValue = 0;

            if (args.length >= 2)
            {
                energyValue = parseDoubleWithMin(commandSender, args[1], 0);
            }

            if (itemStack != null && Double.compare(energyValue, 0) > 0)
            {
                WrappedStack wrappedStack = new WrappedStack(itemStack);
                EnergyValue newEnergyValue = new EnergyValue(energyValue);

                if (args[0].equalsIgnoreCase("pre"))
                {
                    Map<WrappedStack, EnergyValue> preAssignedValues = SerializationHelper.readEnergyValueStackMapFromJsonFile(Files.PRE_ASSIGNED_ENERGY_VALUES);
                    preAssignedValues.put(wrappedStack, newEnergyValue);
                    SerializationHelper.writeEnergyValueStackMapToJsonFile(Files.PRE_ASSIGNED_ENERGY_VALUES, preAssignedValues);
                    EnergyValueRegistry.getInstance().setShouldRegenNextRestart(true);
                }
                else if (args[0].equalsIgnoreCase("post"))
                {
                    EnergyValueRegistry.getInstance().setEnergyValue(wrappedStack, newEnergyValue);
                    Map<WrappedStack, EnergyValue> postAssignedValues = SerializationHelper.readEnergyValueStackMapFromJsonFile(Files.POST_ASSIGNED_ENERGY_VALUES);
                    postAssignedValues.put(wrappedStack, newEnergyValue);
                    SerializationHelper.writeEnergyValueStackMapToJsonFile(Files.POST_ASSIGNED_ENERGY_VALUES, postAssignedValues);
                    PacketHandler.INSTANCE.sendToAll(new MessageSetEnergyValue(wrappedStack, newEnergyValue));
                }

                // Notify admins and log the value change
                func_152373_a(commandSender, this, "command.ee3.set-current-item-value.success", new Object[]{commandSender.getCommandSenderName(), args[0], wrappedStack.toString(), newEnergyValue.toString()});
                LogHelper.info(String.format("%s set the EnergyValue of %s to %s", commandSender.getCommandSenderName(), wrappedStack, newEnergyValue));
            }
            else
            {
                throw new WrongUsageException("command.ee3.set-current-item-value.usage");
            }
        }
    }
View Full Code Here

  @Override
  public void processCommand(ICommandSender sender, String[] arguments) {

    if (arguments.length <= 0) {
      throw new WrongUsageException("Type '" + this.getCommandUsage(sender) + "' for help.");
    }

    if (arguments[0].matches("version")) {
      commandVersion(sender, arguments);
      return;
    } else if (arguments[0].matches("help")) {
      sender.addChatMessage(new ChatComponentText("Format: '" + this.getCommandName() + " <command> <arguments>'"));
      sender.addChatMessage(new ChatComponentText("Available commands:"));
      sender.addChatMessage(new ChatComponentText("- version : Version information."));
      return;
    }

    throw new WrongUsageException(this.getCommandUsage(sender));
  }
View Full Code Here

                        Config.config.get(Configuration.CATEGORY_GENERAL, "Enable Update Checker", true).set(false);
                        Config.config.save();
                        //   if(Config.enableUpdateChecker) FMLCommonHandler.instance().bus().unregister(instance());//save cpu time by unsubscribing to the tickevent.  //causes NPE for some reason.
                        Config.enableUpdateChecker = false;
                    } else {
                        throw new WrongUsageException(getCommandUsage(icommandsender));
                    }
                } else {
                    if(instance().additions.size() > 0) {
                        sendMessage(icommandsender, "-----Additions-----");
                        sendMessage(icommandsender, instance().additions);
                    }
                    if(instance().apiChanges.size() > 0) {
                        sendMessage(icommandsender, "-----API Changes-----");
                        sendMessage(icommandsender, instance().apiChanges);
                    }
                    if(instance().bugfixes.size() > 0) {
                        sendMessage(icommandsender, "-----Bugfixes-----");
                        sendMessage(icommandsender, instance().bugfixes);
                    }
                }
            } else {
                throw new WrongUsageException(getCommandUsage(icommandsender));
            }
        }
View Full Code Here

TOP

Related Classes of net.minecraft.command.WrongUsageException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.