public static final void ServerStatusRequest(MapleClient c) {
   int numPlayer = LoginServer.getUsersOn();
   int userLimit = LoginServer.getUserLimit();
   if (numPlayer >= userLimit) {
     c.getSession().write(LoginPacket.getServerStatus(2));
   } else if (numPlayer * 2 >= userLimit) {
     c.getSession().write(LoginPacket.getServerStatus(1));
   } else {
     c.getSession().write(LoginPacket.getServerStatus(0));
   }
 }
Beispiel #2
0
 public static final void ServerListRequest(final MapleClient c) {
   // c.getSession().write(LoginPacket.getLoginWelcome());
   c.getSession().write(LoginPacket.getServerList(0, LoginServer.getLoad()));
   // c.getSession().write(CField.getServerList(1, "Scania",
   // LoginServer.getInstance().getChannels(), 1200));
   // c.getSession().write(CField.getServerList(2, "Scania",
   // LoginServer.getInstance().getChannels(), 1200));
   // c.getSession().write(CField.getServerList(3, "Scania",
   // LoginServer.getInstance().getChannels(), 1200));
   c.getSession().write(LoginPacket.getEndOfServerList());
   c.getSession().write(LoginPacket.enableRecommended());
   c.getSession().write(LoginPacket.sendRecommended(0, LoginServer.getEventMessage()));
 }
Beispiel #3
0
 public static final void ServerStatusRequest(final MapleClient c) {
   // 0 = Select world normally
   // 1 = "Since there are many users, you may encounter some..."
   // 2 = "The concurrent users in this world have reached the max"
   final int numPlayer = LoginServer.getUsersOn();
   final int userLimit = LoginServer.getUserLimit();
   if (numPlayer >= userLimit) {
     c.getSession().write(LoginPacket.getServerStatus(2));
   } else if (numPlayer * 2 >= userLimit) {
     c.getSession().write(LoginPacket.getServerStatus(1));
   } else {
     c.getSession().write(LoginPacket.getServerStatus(0));
   }
 }
Beispiel #4
0
  public static final void Character_WithoutSecondPassword(
      final LittleEndianAccessor slea,
      final MapleClient c,
      final boolean haspic,
      final boolean view) {
    slea.readByte(); // 1?
    slea.readByte(); // 1?
    final int charId = slea.readInt();
    if (view) {
      c.setChannel(1);
      c.setWorld(slea.readInt());
    }
    final String currentpw = c.getSecondPassword();
    if (!c.isLoggedIn()
        || loginFailCount(c)
        || (currentpw != null && (!currentpw.equals("") || haspic))
        || !c.login_Auth(charId)
        || ChannelServer.getInstance(c.getChannel()) == null
        || c.getWorld() != 0) { // TODOO: MULTI WORLDS
      c.getSession().close();
      return;
    }
    c.updateMacs(slea.readMapleAsciiString());
    slea.readMapleAsciiString();
    if (slea.available() != 0) {
      final String setpassword = slea.readMapleAsciiString();

      if (setpassword.length() >= 6 && setpassword.length() <= 16) {
        c.setSecondPassword(setpassword);
        c.updateSecondPassword();
      } else {
        c.getSession().write(LoginPacket.secondPwError((byte) 0x14));
        return;
      }
    } else if (GameConstants.GMS && haspic) {
      return;
    }
    if (c.getIdleTask() != null) {
      c.getIdleTask().cancel(true);
    }
    final String s = c.getSessionIPAddress();
    LoginServer.putLoginAuth(
        charId, s.substring(s.indexOf('/') + 1, s.length()), c.getTempIP(), c.getChannel());
    c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION, s);
    c.getSession()
        .write(
            CField.getServerIP(
                c,
                Integer.parseInt(ChannelServer.getInstance(c.getChannel()).getIP().split(":")[1]),
                charId));
  }
 public static void LeaveFarm(
     final LittleEndianAccessor slea, final MapleClient c, final MapleCharacter chr) {
   FarmServer.getPlayerStorage().deregisterPlayer(chr);
   c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION, c.getSessionIPAddress());
   try {
     World.ChannelChange_Data(new CharacterTransfer(chr), chr.getId(), c.getChannel());
     c.getSession()
         .write(
             CField.getChannelChange(
                 c,
                 Integer.parseInt(
                     ChannelServer.getInstance(c.getChannel()).getIP().split(":")[1])));
   } finally {
     final String s = c.getSessionIPAddress();
     LoginServer.addIPAuth(s.substring(s.indexOf('/') + 1, s.length()));
     chr.saveToDB(false, true);
     c.setPlayer(null);
     c.setReceiving(false);
     c.getSession().close(true);
   }
 }
 public static final void Character_WithSecondPassword(
     LittleEndianAccessor slea, MapleClient c, boolean view) {
   String password = slea.readMapleAsciiString();
   int charId = slea.readInt();
   if (view) {
     c.setChannel(1);
     c.setWorld(slea.readInt());
   }
   if ((!c.isLoggedIn())
       || (loginFailCount(c))
       || (c.getSecondPassword() == null)
       || (!c.login_Auth(charId))
       || (ChannelServer.getInstance(c.getChannel()) == null)
       || (c.getWorld() != 0)) {
     c.getSession().close(true);
     return;
   }
   if (GameConstants.GMS) {
     c.updateMacs(slea.readMapleAsciiString());
   }
   if ((c.CheckSecondPassword(password))
       && (password.length() >= 6)
       && (password.length() <= 16)) {
     if (c.getIdleTask() != null) {
       c.getIdleTask().cancel(true);
     }
     String s = c.getSessionIPAddress();
     LoginServer.putLoginAuth(charId, s.substring(s.indexOf('/') + 1, s.length()), c.getTempIP());
     c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION, s);
     c.getSession()
         .write(
             CField.getServerIP(
                 c,
                 Integer.parseInt(ChannelServer.getInstance(c.getChannel()).getIP().split(":")[1]),
                 charId));
     System.out.println("Sent serverIp");
   } else {
     c.getSession().write(LoginPacket.secondPwError((byte) 0x14));
   }
 }
  public static void ServerListRequest(MapleClient c) {
    c.getSession().write(LoginPacket.getServerList(0, LoginServer.getLoad()));

    c.getSession().write(LoginPacket.getEndOfServerList());
  }
Beispiel #8
0
  public void run() throws InterruptedException {
    long start = System.currentTimeMillis();
    //        LoggingService.init();
    //        MapleInfos.printAllInfos();
    this.rankTime = Integer.parseInt(ServerProperties.getProperty("rankTime", "120"));
    this.ivCheck = Boolean.parseBoolean(ServerProperties.getProperty("ivCheck", "false"));
    if ((ServerProperties.getProperty("admin", false)) || (ServerConstants.USE_LOCALHOST)) {
      ServerConstants.USE_FIXED_IV = false;
      System.out.println("[!!! 已开启只能管理员登录模式 !!!]");
    }
    try (PreparedStatement ps =
        DatabaseConnection.getConnection()
            .prepareStatement("UPDATE `accounts` SET `loggedin` = 0")) {
      ps.executeUpdate();
      ps.close();
    } catch (SQLException ex) {
      throw new RuntimeException("运行时错误: 无法连接到MySQL数据库伺服器");
    }

    System.out.println("正在加载服务端...");
    System.out.println("当前操作系统: " + System.getProperty("sun.desktop"));
    World.init();
    System.out.println(
        "服务器地址: "
            + ServerProperties.getProperty("channel.interface", ServerConstants.IP)
            + ":"
            + LoginServer.DEFAULT_PORT);
    System.out.println(
        "游戏版本: "
            + ServerConstants.MAPLE_TYPE
            + " v."
            + ServerConstants.MAPLE_VERSION
            + "."
            + ServerConstants.MAPLE_PATCH);
    System.out.println("主服务器: " + WorldConstants.getMainWorld().name());
    System.out.println("");
    runThread();
    loadData(false);

    System.out.print("加载\"登入\"服务...");
    LoginServer.run_startup_configurations();
    System.out.println("正在加载频道...");
    ChannelServer.startChannel_Main();
    System.out.println("频道加载完成!\r\n");
    System.out.print("正在加载商城...");
    CashShopServer.run_startup_configurations();
    Runtime.getRuntime().addShutdownHook(new Thread(new Shutdown()));
    printSection("刷怪线程");
    WorldRespawnService.getInstance();
    if (ServerProperties.getProperty("RandDrop", false)) {
      ChannelServer.getInstance(1).getMapFactory().getMap(910000000).spawnRandDrop();
    }
    ShutdownServer.registerMBean();
    ServerConstants.registerMBean();
    PlayerNPC.loadAll();
    //        printSection("定时活动");
    //        MessengerRankingWorker.getInstance();
    LoginServer.setOn();
    //        Server.run_startup_configurations();
    //        Server.setGameRunning(true);
    //
    //        if (this.rankTime > 0) {
    //            printSection("刷新排名");
    //            RankingWorker.start();
    //        }
    //
    //          if (Boolean.parseBoolean(ServerProperties.getProperty("world.AccCheck", "false"))) {
    //              printSection("启动检测");
    //              startCheck();
    //        }
    //          printSection("在线统计");
    //          在线统计(Integer.parseInt(ServerProperties.getProperty("world.showUserCountTime",
    // "30")));
    //          MessengerRankingWorker.getInstance();
    //
    //          if (Boolean.parseBoolean(ServerProperties.getProperty("world.checkCopyItem",
    // "false")))   {
    //            checkCopyItemFromSql();
    //        }
    long now = System.currentTimeMillis() - start;
    long seconds = now / 1000;
    long ms = now % 1000;
    if (ServerProperties.getProperty("aotoSave", false)) {
      DatabaseBackup.getInstance().startTasking();
      System.out.println("启动数据库自动备份!");
    }
    //        ManagerSin.main(ServerConstants.GUI);
    System.out.println("加载完成, 耗时: " + seconds + "秒" + ms + "毫秒\r\n");
  }