Package net.minecraft.command

Examples of net.minecraft.command.WrongUsageException


            TaskRegistry.registerTask(new TickTaskPulseHelper(var11, new Point(var3, var4, var5), var6));
            OutputHandler.chatConfirmation(var1, "Redstone Pulsed for " + var6 + " Ticks");
        }
        else
        {
            throw new WrongUsageException("/pulse <X> <Y> <Z> [PulseLength]", new Object[0]);
        }
    }
View Full Code Here


    @Override
    public void processCommand(ICommandSender sender, String[] args)
    {
        if (args.length == 0)
        {
            throw new WrongUsageException("commands.forge.usage");
        }
        else if ("help".equals(args[0]))
        {
            throw new WrongUsageException("commands.forge.usage");
        }
        else if ("tps".equals(args[0]))
        {
            displayTPS(sender,args);
        }
        else if ("tpslog".equals(args[0]))
        {
            doTPSLog(sender,args);
        }
        else if ("track".equals(args[0]))
        {
            handleTracking(sender, args);
        }
        else
        {
            throw new WrongUsageException("commands.forge.usage");
        }
    }
View Full Code Here

    private void handleTracking(ICommandSender sender, String[] args)
    {
        if (args.length != 3)
        {
            throw new WrongUsageException("commands.forge.usage.tracking");
        }
        String type = args[1];
        int duration = parseIntBounded(sender, args[2], 1, 60);

        if ("te".equals(type))
        {
            doTurnOnTileEntityTracking(sender, duration);
        }
        else
        {
            throw new WrongUsageException("commands.forge.usage.tracking");
        }
    }
View Full Code Here

    @Override
    public void processCommandPlayer(EntityPlayer sender, String[] args)
    {
        if (args.length == 0)
        {
            throw new WrongUsageException("command.auth.usage");
        }

        boolean hasAdmin = PermissionsManager.checkPermission(sender, getPermissionNode() + ".admin");

        // one arg? must be help.
        if (args.length == 1)
        {
            if (args[0].equalsIgnoreCase("help"))
            {
                OutputHandler.chatConfirmation(sender, " - /auth register <password>");
                OutputHandler.chatConfirmation(sender, " - /auth login <password>");
                OutputHandler.chatConfirmation(sender, " - /auth changepass <oldpass> <newpass>  - changes your password");

                if (!hasAdmin)
                {
                    return;
                }

                OutputHandler.chatConfirmation(sender, " - /auth kick <player>  - forces the player to login again");
                OutputHandler.chatConfirmation(sender, " - /auth setpass <player> <password>  - sets the players password");
                OutputHandler.chatConfirmation(sender, " - /auth unregister <player>  - forces the player to register again");
                return;
            }
            else
            {
                throw new WrongUsageException("/auth help");
            }
        }

        // 2 args? seconds needs to be the player.
        if (args.length == 2)
        {
            // parse login
            if (args[0].equalsIgnoreCase("login"))
            {
                PlayerPassData data = PlayerPassData.getData(sender.getPersistentID());
                if (data == null)
                {
                    OutputHandler.chatError(sender, String.format("Player %s is not registered!", sender.getPersistentID()));
                    return;
                }

                String pass = ModuleAuth.encrypt(args[1]);

                // login worked
                if (data.password.equals(pass))
                {
                    ModuleAuth.hasSession.add(sender.getPersistentID());
                    OutputHandler.chatConfirmation(sender, "Login successful.");
                }
                else
                {
                    OutputHandler.chatError(sender, "Login failed.");
                }

                return;

            }
            // parse register
            else if (args[0].equalsIgnoreCase("register"))
            {
                if (PlayerPassData.getData(sender.getPersistentID()) != null)
                {
                    OutputHandler.chatError(sender, String.format("Player %s is already registered!", sender.getPersistentID()));
                    return;
                }

                if (ModuleAuth.isEnabled() && !ModuleAuth.allowOfflineReg)
                {
                    OutputHandler.chatError(sender, "Registrations have been disabled.");
                    return;
                }

                String pass = ModuleAuth.encrypt(args[1]);
                PlayerPassData.registerData(sender.getPersistentID(), pass);
                OutputHandler.chatConfirmation(sender, "Registration successful.");
                return;
            }

            // stop if unlogged.
            if (!ModuleAuth.hasSession.contains(sender.getPersistentID()))
            {
                OutputHandler.chatError(sender, "Login required. Try /auth help.");
                return;
            }

            // check for players.. all the rest of these should be greated than 1.
            UUID name = UserIdent.getUuidByUsername(args[1]);
            boolean isLogged = true;

            // check if the player is logged.
            EntityPlayerMP player = UserIdent.getPlayerByMatchOrUsername(sender, args[1]);
            if (player == null)
            {
                OutputHandler.chatWarning(sender, "A player of that name is not on the server. Doing the action anyways.");
                isLogged = false;
            }

            // parse ./auth kick
            if (args[0].equalsIgnoreCase("kick"))
            {
                if (!hasAdmin)
                {
                    throw new PermissionDeniedException();
                }
                else if (!isLogged)
                {
                    throw new PlayerNotFoundException();
                }
                else
                {
                    ModuleAuth.hasSession.remove(name);
                    OutputHandler.chatConfirmation(sender, String.format("Player %s was logged out from the authentication service.", name));
                    OutputHandler.chatWarning(player, "You have been logged out from the authentication service. Please login again.");
                    return;
                }
            }
            // parse ./auth setpass
            else if (args[0].equalsIgnoreCase("setPass"))
            {
                if (!hasAdmin)
                {
                    throw new PermissionDeniedException();
                }

                throw new WrongUsageException("/auth setpass <player> <password>");
            }

            // parse ./auth unregister
            else if (args[0].equalsIgnoreCase("unregister"))
            {
                if (!hasAdmin)
                {
                    throw new PermissionDeniedException();
                }

                if (PlayerPassData.getData(name) == null)
                {
                    throw new WrongUsageException(String.format("Player %s is not registered!", name));
                }

                PlayerPassData.deleteData(name);
                OutputHandler.chatConfirmation(sender, String.format("Player %s has been removed from the authentication service.", name));
                return;
            }

            // ERROR! :D
            else
            {
                throw new WrongUsageException("/auth help");
            }
        }
        // 3 args? must be a comtmand - player - pass
        else if (args.length == 3)
        {
            if (!ModuleAuth.hasSession.contains(sender.getPersistentID()))
            {
                OutputHandler.chatError(sender, "Login required. Try /auth help.");
                return;
            }

            // parse changePass
            if (args[0].equalsIgnoreCase("changepass"))
            {
                UUID name = sender.getPersistentID();
                PlayerPassData data = PlayerPassData.getData(name);

                if (data == null)
                {
                    throw new WrongUsageException(String.format("Player %s is not registered!", name));
                }
                String oldpass = ModuleAuth.encrypt(args[1]);
                String newPass = ModuleAuth.encrypt(args[2]);

                if (args[1].equals(args[2]))
View Full Code Here

    @Override
    public void processCommandConsole(ICommandSender sender, String[] args)
    {
        if (args.length == 0)
        {
            throw new WrongUsageException("/auth help");
        }

        // one arg? must be help.
        if (args.length == 1)
        {
            if (args[0].equalsIgnoreCase("help"))
            {
                OutputHandler.chatNotification(sender, " - /auth kick <player>  - forces the player to login again");
                OutputHandler.chatNotification(sender, " - /auth setpass <player> <password>  - sets the players password to the specified");
                OutputHandler.chatNotification(sender, " - /auth unregister <player>  - forces the player to register again");
                return;
            }
            else
            {
                throw new WrongUsageException("/auth help");
            }
        }

        // check for players.. all the rest of these should be greated than 1.
        UUID name = UserIdent.getUuidByUsername(args[1]);
        boolean isLogged = true;

        // check if the player is logged.
        EntityPlayerMP player = UserIdent.getPlayerByMatchOrUsername(sender, args[1]);
        if (player == null)
        {
            OutputHandler.chatWarning(sender, "A player of that name is not on the server. Doing the action anyways.");
            isLogged = false;
        }

        // 2 args? seconds needs to be the player.
        if (args.length == 2)
        {
            // parse ./auth kick
            if (args[0].equalsIgnoreCase("kick"))
            {
                if (!isLogged)
                {
                    throw new WrongUsageException("/auth kick <player");
                }
                else
                {
                    ModuleAuth.hasSession.remove(name);
                    OutputHandler.chatConfirmation(sender, String.format("Player %s was logged out from the authentication service.", name));
                    OutputHandler.chatWarning(player, "You have been logged out from the authentication service. Please login again.");
                    return;
                }
            }
            // parse ./auth setpass
            else if (args[0].equalsIgnoreCase("setPass"))
            {
                throw new WrongUsageException("/auth setpass <player> <password>");
            }
            else if (args[0].equalsIgnoreCase("unregister"))
            {
                if (PlayerPassData.getData(name) == null)
                {
                    throw new WrongUsageException("message.auth.error.notregisterred", "name");
                }

                PlayerPassData.deleteData(name);
                return;
            }

            // ERROR! :D
            else
            {
                throw new WrongUsageException("command.auth.usage");
            }
        }
        // 3 args? must be a command - player - pass
        else if (args.length == 3)
        {
View Full Code Here

     
      ItemStack beestack = PluginApiculture.beeInterface.getMemberStack(bee, type.ordinal());
      player.dropPlayerItemWithRandomChoice(beestack, true);
      func_152373_a(sender, this, "Player %s was given a %s bee.", player.getCommandSenderName(), ((IAlleleSpecies) template[0]).getName());
    } else
      throw new WrongUsageException("/" + getCommandName() + " <player-name> <species-name>");
  }
View Full Code Here

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

    if (arguments.length <= 0)
      throw new WrongUsageException(StringUtil.localizeAndFormat("chat.help", this.getCommandUsage(sender)));

    if (arguments[0].matches("list"))
      listModes(sender, arguments);
    else if (arguments[0].matches("info"))
      listModeInfo(sender, arguments);
    else if (arguments[0].matches("set")) {
      if (arguments.length <= 1)
        throw new WrongUsageException("/" + this.getCommandName() + " set [<world-#>] <mode-name>");

      World world = getWorld(sender, arguments);
      String desired = arguments[arguments.length - 1];

      ITreekeepingMode mode = PluginArboriculture.treeInterface.getTreekeepingMode(desired);
      if (mode == null)
        throw new CommandException(StringUtil.localize("chat.trees.command.treekeeping.error"), desired);

      PluginArboriculture.treeInterface.setTreekeepingMode(world, mode.getName());
      func_152373_a(sender, this, StringUtil.localize("chat.trees.command.treekeeping.set"), mode.getName());

    } else if (arguments[0].matches("save")) {
      if (arguments.length <= 1)
        throw new WrongUsageException("/" + this.getCommandName() + " save <player-name>");

      saveStatistics(sender, arguments);
    } else if (arguments[0].matches("help")) {
      sendChatMessage(sender, StringUtil.localizeAndFormat("chat.trees.command.help.0", this.getCommandName()));
      sendChatMessage(sender, StringUtil.localize("chat.trees.command.help.1"));
View Full Code Here

    return;
  }

  private void listModeInfo(ICommandSender sender, String[] arguments) {
    if (arguments.length <= 1)
      throw new WrongUsageException("/" + this.getCommandName() + " info <mode-name>");

    ITreekeepingMode found = null;
    for (ITreekeepingMode mode : PluginArboriculture.treeInterface.getTreekeepingModes())
      if (mode.getName().equalsIgnoreCase(arguments[1])) {
        found = mode;
View Full Code Here

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

    if (arguments.length <= 0)
      throw new WrongUsageException(StringUtil.localizeAndFormat("chat.help", this.getCommandUsage(sender)));

    if (arguments[0].matches("version")) {
      commandVersion(sender, arguments);
      return;
    } else if (arguments[0].matches("plugins")) {
      commandPlugins(sender, arguments);
      return;
    } else if (arguments[0].matches("help")) {
      sendChatMessage(sender, StringUtil.localizeAndFormat("chat.command.help.0", this.getCommandName()));
      sendChatMessage(sender, StringUtil.localize("chat.command.help.1"));
      sendChatMessage(sender, StringUtil.localize("chat.command.help.2"));
      sendChatMessage(sender, StringUtil.localize("chat.command.help.3"));
      sendChatMessage(sender, StringUtil.localize("chat.command.help.4"));
      return;
    }

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

  }

  private void listPluginInfoForSender(ICommandSender sender, String[] arguments) {

    if (arguments.length < 3)
      throw new WrongUsageException("/" + getCommandName() + " plugins info <plugin-name>");

    ForestryPlugin found = null;
    for (PluginManager.Module pluginModule : PluginManager.getLoadedModules()) {
      Plugin info = pluginModule.instance().getClass().getAnnotation(Plugin.class);
      if (info == null)
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.