Ejemplo n.º 1
0
 /**
  * Gets a user by there UserID
  *
  * @param line Line containing there UserID
  * @return The User
  */
 public User getByID(Message message) {
   try {
     return getByID(message.getString("userid"));
   } catch (Exception ex) {
   }
   return getByID(message.toString());
 }
Ejemplo n.º 2
0
    public RoomData(Message json, boolean isDGR) {
      // TODO add in sticker placements
      users = new ArrayList<User>();
      if (!isDGR) {
        if (json.getBoolean("success")) {
          Message to;
          for (Message user : json.getMessageList("users")) {
            users.add(new User(user));
          }
          to = new Message(json.get("room"));
          name = to.getString("name");
          name_lower = to.getString("name_lower");
          shortcut = to.getString("shortcut");
          roomid = to.getString("roomid");
          created = to.getDouble("created");
          to = to.getSubObject("metadata");
          creator = new User(to.getSubObject("creator"));
          try {
            song = new Song(to.getSubObject("current_song"), false);
          } catch (Exception ex) {
            song = null;
          }
          djFull = to.getBoolean("dj_full");
          downvotes = to.getInt("downvotes");
          privacy = to.getString("privacy");
          upvotes = to.getInt("upvotes");
          if (to.has("djthreshold")) pointLimit = to.getInt("djthreshold");
          mods = to.getStringList("moderator_id");
          djs = to.getStringList("djs");
          maxDjs = to.getInt("max_djs");
          currentDj = to.getString("current_dj");
          listeners = to.getInt("listeners");
          djCount = to.getInt("djcount");
          maxUsers = to.getInt("max_size");
          // votelog = temp.get("votelog");
          // stickerPlacements = temp.get("sticker_placements");
          // songlog = temp.get("songlog");

        }
      } else {
        Message to = new Message(json.get("room"));
        BasicDBList tl = to.getList("chatserver");
        chatServer = tl.get(0).toString();
        chatPort = Integer.parseInt(tl.get(1).toString());

        name = to.getString("name");
        name_lower = to.getString("name_lower");
        shortcut = to.getString("shortcut");
        roomid = to.getString("roomid");
        created = to.getDouble("created");
        to = to.getSubObject("metadata");
        try {
          song = new Song(to.getSubObject("current_song"), false);
        } catch (Exception ex) {
          song = null;
        }
        djFull = to.getBoolean("dj_full");
        downvotes = to.getInt("downvotes");
        privacy = to.getString("privacy");
        upvotes = to.getInt("upvotes");
        if (to.has("djthreshold")) pointLimit = to.getInt("djthreshold");
        mods = to.getStringList("moderator_id");
        djs = to.getStringList("djs");
        maxDjs = to.getInt("max_djs");
        currentDj = to.getString("current_dj");
        listeners = to.getInt("listeners");
        djCount = to.getInt("djcount");
        maxUsers = to.getInt("max_size");
        // votelog = temp.get("votelog");
        // stickerPlacements = temp.get("sticker_placements");
        // songlog = temp.get("songlog");
        for (Message user : json.getMessageList("users")) {
          User u = new User(user);
          users.add(u);
        }
      }
    }