Package net.bnubot.util

Examples of net.bnubot.util.BNetUser


   * @param user "User[#N][@Realm]"
   * @param perspective The BNetUser whose realm to use if none is specified
   * @return A BNetUser representing the user
   */
  public BNetUser getCreateBNetUser(String user, BNetUser perspective) {
    BNetUser x = findUser(user, perspective);
    if(x != null)
      return x;
    return new BNetUser(this, user, perspective);
  }
View Full Code Here


    Account subjectAccount = Account.get(accountName);
    if(subjectAccount != null)
      return subjectAccount;

    // They don't have an account by that name, check if it's a user
    BNetUser bnSubject = source.getCreateBNetUser(accountName, commander);

    subjectAccount = Account.get(bnSubject);
    if(subjectAccount != null)
      return subjectAccount;
View Full Code Here

    String reason = params[0];
    if(params.length > 1)
      reason = params[1];

    if(isBan && (params[0].indexOf('*') == -1)) {
      BNetUser bnSubject = source.findUser(params[0], user);
      if(!canKickBan(user, bnSubject))
        throw new CommandFailedWithDetailsException("You may not kick or ban users who outrank you.");

      // Regular ban
      String out = (isBan) ? "/ban " : "/kick ";
      if(bnSubject != null)
        out += bnSubject.getFullLogonName();
      else
        out += params[0];
      out += " " + reason;

      // Send the command
View Full Code Here

    if(votes.get(source) != null) {
      user.sendChat("There is already a vote in progress!", whisperBack);
      return;
    }

    BNetUser bnSubject = source.findUser(target, user);
    if(bnSubject == null) {
      user.sendChat("User not found", whisperBack);
      return;
    }
View Full Code Here

    }
  }

  @Override
  public void friendsAdd(BNCSConnection source, FriendEntry friend) {
    BNetUser target = new BNetUser(source, friend.getAccount(), source.getMyUser());
    target.sendChat("You are logged in. You must add me to your friends list.", true);
  }
View Full Code Here

  /**
   * Command initiated by the user via sendChat()
   */
  protected static boolean internalParseCommand(Connection source, String command, boolean whisperBack) throws InternalError {
    try {
      BNetUser myUser = source.getMyUser();
      if(myUser == null)
        myUser = new BNetUser(source, source.cs.username, source.cs.getMyRealm());
      workCommand(source, myUser, command, whisperBack, true);
    } catch(CommandDoesNotExistException e) {
      return false;
    } catch(AccountDoesNotExistException e) {
      source.dispatchRecieveError("The account [" + e.getMessage() + "] does not exist!");
View Full Code Here

    if(!isConnected()) {
      connect();
      return;
    }

    BNetUser user = master.getMyUser();
    String channel = master.getChannel();
    int ip = -1;
    if(channel == null)
      channel = "<Not Logged On>";
    else
      ip = master.getIp();

    if((myUser != null) && (myUser instanceof BotNetUser)) {
      BotNetUser me = (BotNetUser)myUser;
      me.name = GlobalSettings.botNetUsername;
      if((me.name == null) || (me.name.length() == 0))
        me.name = "BNUBot2";
      if(user != null)
        me.name = user.getShortLogonName();
      me.channel = channel;
      me.server = ip;
      me.database = GlobalSettings.botNetDatabase;
      dispatchBotnetUserStatus(me);
    }

    sendStatusUpdate(
        (user == null) ? "BNUBot2" : user.getShortLogonName(),
        channel,
        ip,
        GlobalSettings.botNetDatabase + " " + GlobalSettings.botNetDatabasePassword,
        false);
  }
View Full Code Here

    for(BNLogin login : BNLogin.getLastSeen(10)) {
      if(!first)
        response += ", ";
      first = false;

      response += new BNetUser(login.getLogin()).getShortLogonName(user);
      response += " [";
      long time = System.currentTimeMillis() - login.getLastSeen().getTime();
      response += TimeFormatter.formatTime(time, false);
      response += "]";
    }
View Full Code Here

      case SID_ENTERCHAT: {
        String uniqueUserName = is.readNTString();
        StatString myStatString = new StatString(is.readNTString());
        /* String accountName = */is.readNTString();

        myUser = new BNetUser(this, uniqueUserName, cs.myRealm);
        myUser.setStatString(myStatString);
        dispatchEnterChat(myUser);
        dispatchTitleChanged();

        // We are officially logged in!
View Full Code Here

        default:
          data = new ByteArray(is.readNTBytes());
          break;
        }

        BNetUser user = null;
        switch(eid) {
        case EID_SHOWUSER:
        case EID_USERFLAGS:
        case EID_JOIN:
        case EID_LEAVE:
        case EID_TALK:
        case EID_EMOTE:
        case EID_WHISPERSENT:
        case EID_WHISPER:
          switch(productID) {
          case D2DV:
          case D2XP:
            int asterisk = username.indexOf('*');
            if(asterisk >= 0)
              username = username.substring(asterisk+1);
            break;
          }

          // Get a BNetUser object for the user
          if(myUser.equals(username))
            user = myUser;
          else
            user = getCreateBNetUser(username, myUser);

          // Set the flags, ping, statstr
          user.setFlags(flags);
          user.setPing(ping);
          if(statstr != null)
            user.setStatString(statstr);
          break;
        }

        switch(eid) {
        case EID_SHOWUSER:
View Full Code Here

TOP

Related Classes of net.bnubot.util.BNetUser

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.