Пример #1
0
  public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    byte mode = slea.readByte();
    if (mode == 6) { // whisper
      String recipient = slea.readMapleAsciiString();
      String text = slea.readMapleAsciiString();

      if (!CommandProcessor.getInstance().processCommand(c, text)) {
        MapleCharacter player =
            c.getChannelServer().getPlayerStorage().getCharacterByName(recipient);
        if (player != null) {
          player
              .getClient()
              .getSession()
              .write(MaplePacketCreator.getWhisper(c.getPlayer().getName(), c.getChannel(), text));
          c.getSession().write(MaplePacketCreator.getWhisperReply(recipient, (byte) 1));
        } else { // not found
          try {
            if (ChannelServer.getInstance(c.getChannel())
                .getWorldInterface()
                .isConnected(recipient)) {
              ChannelServer.getInstance(c.getChannel())
                  .getWorldInterface()
                  .whisper(c.getPlayer().getName(), recipient, c.getChannel(), text);
              c.getSession().write(MaplePacketCreator.getWhisperReply(recipient, (byte) 1));
            } else {
              c.getSession().write(MaplePacketCreator.getWhisperReply(recipient, (byte) 0));
            }
          } catch (RemoteException e) {
            c.getSession().write(MaplePacketCreator.getWhisperReply(recipient, (byte) 0));
            c.getChannelServer().reconnectWorld();
          }
        }
      }
    } else if (mode == 5) { // - /find
      String recipient = slea.readMapleAsciiString();
      MapleCharacter player = c.getChannelServer().getPlayerStorage().getCharacterByName(recipient);
      if (player != null && (c.getPlayer().isGM() || !player.isHidden())) {
        if (player.inCS()) {
          c.getSession().write(MaplePacketCreator.getFindReplyWithCS(player.getName()));
        } else {
          c.getSession()
              .write(
                  MaplePacketCreator.getFindReplyWithMap(
                      player.getName(), player.getMap().getId()));
        }
      } else { // not found
        try {
          int channel =
              ChannelServer.getInstance(c.getChannel()).getWorldInterface().find(recipient);
          if (channel > -1) {
            c.getSession().write(MaplePacketCreator.getFindReply(recipient, channel));
          } else {
            c.getSession().write(MaplePacketCreator.getWhisperReply(recipient, (byte) 0));
          }
        } catch (RemoteException e) {
          c.getChannelServer().reconnectWorld();
        }
      }
    }
  }
 @Override
 public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
   int load = 0;
   for (ChannelServer cservs : ChannelServer.getAllInstances()) {
     load += LoginServer.getInstance().getLoad().get(cservs.getChannel());
   }
   if (LoginServer.getInstance().getUserLimit() <= load) {
     c.getSession().write(MaplePacketCreator.getServerStatus(2));
   } else if (LoginServer.getInstance().getUserLimit() * 0.9 <= load) {
     c.getSession().write(MaplePacketCreator.getServerStatus(1));
   } else {
     c.getSession().write(MaplePacketCreator.getServerStatus(0));
   }
 }