Package net.bnubot.db

Examples of net.bnubot.db.Command


      throw new IllegalArgumentException("The command " + name + " is already registered");

    if(Command.get(name) == null) {
      Rank max = Rank.getMax();

      Command c = DatabaseContext.getContext().newObject(Command.class);
      c.setRank(max);
      c.setCmdgroup(null);
      c.setDescription(null);
      c.setName(name);
      try {
        c.updateRow();
      } catch (Exception e) {
        throw new IllegalStateException(e);
      }

      String message = "Created command " + name + " with access " + max.getAccess() + "; to change, use %trigger%setauth " + name + " <access>";
View Full Code Here


      if(paramHelper.length > 1)
        param = paramHelper[1];
    }

    // Check if the command exists
    Command rsCommand = Command.get(command);
    if(rsCommand == null)
      throw new CommandDoesNotExistException(command);

    //Reset the command to the case in the database
    command = rsCommand.getName();

    Account commanderAccount = Account.get(user);
    if(!superUser) {
      int commanderAccess = 0;
      if(commanderAccount != null)
        commanderAccess = commanderAccount.getAccess();

      int requiredAccess = rsCommand.getAccess();
      if(commanderAccess < requiredAccess)
        throw new InsufficientAccessException("(" + commanderAccess + "/" + requiredAccess + ")", commanderAccess > 0);
    }

    CommandRunnable cr = Profile.getCommand(command);
View Full Code Here

      if(params == null)
        throw new InvalidUseException();
      if(params.length != 1)
        throw new InvalidUseException();

      Command rsSubjectCommand = Command.get(params[0]);
      if(rsSubjectCommand == null)
        throw new CommandFailedWithDetailsException("The command [" + params[0] + "] does not exist!");

      params[0] = rsSubjectCommand.getName();
      int access = rsSubjectCommand.getAccess();

      user.sendChat("Authorization required for " + params[0] + " is " + access, whisperBack);
    } catch(InvalidUseException e) {
      user.sendChat("Use: %trigger%auth <command>", whisperBack);
    }
View Full Code Here

  throws Exception {
    try {
      if((params == null) || (params.length != 2))
        throw new InvalidUseException();

      Command rsCommand = Command.get(params[0]);
      if(rsCommand == null)
        throw new CommandFailedWithDetailsException("That command does not exist!");

      try {
        int oldAccess = rsCommand.getAccess();
        int access = Integer.parseInt(params[1]);
        Rank rank = Rank.get(access);
        if(rank == null)
          throw new CommandFailedWithDetailsException("That access level does not exist!");
        rsCommand.setRank(rank);
        rsCommand.updateRow();

        user.sendChat("Successfully changed the authorization required for command [" + rsCommand.getName() + "] from [" + oldAccess + "] to [" + access + "]", whisperBack);
      } catch(NumberFormatException e) {
        throw new InvalidUseException();
      }
    } catch(InvalidUseException e) {
      user.sendChat("Use: %trigger%setauth <command> <access>", whisperBack);
View Full Code Here

      if(params == null)
        throw new InvalidUseException();
      if(params.length < 2)
        throw new InvalidUseException();

      Command rsSubjectCommand = Command.get(params[0]);
      if(rsSubjectCommand == null)
        throw new CommandFailedWithDetailsException("The command [" + params[0] + "] does not exist!");

      for(int i = 1; i < params.length; i++) {
        if(Command.get(params[i]) != null)
View Full Code Here

TOP

Related Classes of net.bnubot.db.Command

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.