Пример #1
0
 /**
  * 添加最近用户
  *
  * @param userid
  */
 public void addRecentlyPlayer(int userid) {
   PlayerCharacter pp = World.getInstance().getPlayer(userid);
   if (pp != null) {
     roleMgr.put(userid, pp.getData());
     // rms
     RespModuleSet rms = new RespModuleSet(ProcotolType.FRIEND_RESP);
     rms.addModule(
         MongoServer.getInstance()
             .getLogServer()
             .getPlayerCacheDAO()
             .findPlayerCacheByUserid(pp.getId()));
     AndroidMessageSender.sendMessage(rms, player);
     // rms
   }
 }
Пример #2
0
 /** 用户 0:世界 1:国家 2:州 3:市 4:县 */
 public ArrayList<PlayerCache> getUserOnline(byte type) {
   int nationid = player.getData().getNativeId();
   ArrayList<RoleData> allSimpleLst = getAllOnline(); //
   ArrayList<PlayerCache> simpleLst = new ArrayList<PlayerCache>();
   switch (type) {
     case 0: // 全部
       for (RoleData sr : allSimpleLst) {
         simpleLst.add(
             MongoServer.getInstance()
                 .getLogServer()
                 .getPlayerCacheDAO()
                 .findPlayerCacheByUserid((int) sr.getUserid()));
       }
       break;
     case 1: // 本国
       for (RoleData sr : allSimpleLst) {
         if (sr != null && sr.getNativeId() / 1000 * 1000 == nationid / 1000 * 1000) {
           simpleLst.add(
               MongoServer.getInstance()
                   .getLogServer()
                   .getPlayerCacheDAO()
                   .findPlayerCacheByUserid((int) sr.getUserid()));
         }
       }
       break;
     case 2: // 本州
       for (RoleData sr : allSimpleLst) {
         if (sr != null && sr.getNativeId() / 100 * 100 == nationid / 100 * 100) {
           simpleLst.add(
               MongoServer.getInstance()
                   .getLogServer()
                   .getPlayerCacheDAO()
                   .findPlayerCacheByUserid((int) sr.getUserid()));
         }
       }
       break;
     case 3: // 本市
       for (RoleData sr : allSimpleLst) {
         if (sr != null && sr.getNativeId() / 10 * 10 == nationid / 10 * 10) {
           simpleLst.add(
               MongoServer.getInstance()
                   .getLogServer()
                   .getPlayerCacheDAO()
                   .findPlayerCacheByUserid((int) sr.getUserid()));
         }
       }
       break;
     case 4: // 本县
       for (RoleData sr : allSimpleLst) {
         if (sr != null && sr.getNativeId() == nationid) {
           simpleLst.add(
               MongoServer.getInstance()
                   .getLogServer()
                   .getPlayerCacheDAO()
                   .findPlayerCacheByUserid((int) sr.getUserid()));
         }
       }
       break;
     case 5:
       for (RoleData rd : roleMgr.values()) {
         simpleLst.add(
             MongoServer.getInstance()
                 .getLogServer()
                 .getPlayerCacheDAO()
                 .findPlayerCacheByUserid((int) rd.getUserid()));
       }
   }
   return simpleLst;
 }