Example #1
0
  public static void loadData(boolean reload) {
    System.out.println("载入数据(因为数据量大可能比较久而且内存消耗会飙升)");

    System.out.println("加载等级经验数据");
    GameConstants.LoadEXP();

    System.out.println("加载排名信息数据");
    MapleGuildRanking.getInstance().load(reload);

    // System.out.println("加载公会数据并清理不存在公会");
    // MapleGuild.loadAll();

    System.out.println("加载任务数据");
    // 加载任务信息
    MapleLifeFactory.loadQuestCounts(reload);
    // 加载转存到数据库的任务信息
    MapleQuest.initQuests(reload);

    System.out.println("加载爆物数据");
    // 加载爆物数据
    MapleMonsterInformationProvider.getInstance().addExtra();
    // 加载全域爆物数据
    MapleMonsterInformationProvider.getInstance().load();

    System.out.println("加载道具数据");
    // 加载道具信息(从WZ)
    MapleItemInformationProvider.getInstance().runEtc(reload);
    // 加载道具信息(从SQL)
    MapleItemInformationProvider.getInstance().runItems(reload);
    // 加载发型脸型
    MapleItemInformationProvider.getInstance().loadHairFace(reload);

    System.out.println("加载技能数据");
    // 加载技能
    SkillFactory.loadAllSkills(reload);

    MobSkillFactory.getInstance(); // 载入怪物技能

    System.out.println("loadSpeedRuns");
    // ?
    SpeedRunner.loadSpeedRuns(reload);

    System.out.println("加载商城道具数据");
    // 加载商城道具信息
    CashItemFactory.getInstance().initialize(reload);
    System.out.println("数据载入完成!\r\n");
  }
Example #2
0
  @Override
  public void run() {
    Properties p = new Properties();
    try {
      p.load(new FileInputStream("moople.ini"));
    } catch (Exception e) {
      System.out.println("Please start create_server.bat");
      System.exit(0);
    }

    System.out.println("MoopleDEV v" + ServerConstants.VERSION + " starting up.\r\n");

    Runtime.getRuntime().addShutdownHook(new Thread(shutdown(false)));
    DatabaseConnection.getConnection();
    Connection c = DatabaseConnection.getConnection();
    try {
      PreparedStatement ps = c.prepareStatement("UPDATE accounts SET loggedin = 0");
      ps.executeUpdate();
      ps.close();
      ps = c.prepareStatement("UPDATE characters SET HasMerchant = 0");
      ps.executeUpdate();
      ps.close();
    } catch (SQLException sqle) {
    }
    IoBuffer.setUseDirectBuffer(false);
    IoBuffer.setAllocator(new SimpleBufferAllocator());
    acceptor = new NioSocketAcceptor();
    acceptor
        .getFilterChain()
        .addLast("codec", (IoFilter) new ProtocolCodecFilter(new MapleCodecFactory()));
    TimerManager tMan = TimerManager.getInstance();
    tMan.start();
    tMan.register(tMan.purge(), 300000); // Purging ftw...
    tMan.register(new RankingWorker(), ServerConstants.RANKING_INTERVAL);

    long timeToTake = System.currentTimeMillis();
    System.out.println("Loading Skills");
    SkillFactory.loadAllSkills();
    System.out.println(
        "Skills loaded in " + ((System.currentTimeMillis() - timeToTake) / 1000.0) + " seconds");

    timeToTake = System.currentTimeMillis();
    System.out.println("Loading Items");
    MapleItemInformationProvider.getInstance().getAllItems();

    CashItemFactory.getSpecialCashItems();
    System.out.println(
        "Items loaded in " + ((System.currentTimeMillis() - timeToTake) / 1000.0) + " seconds");
    try {
      for (int i = 0; i < Integer.parseInt(p.getProperty("worlds")); i++) {
        System.out.println("Starting world " + i);
        World world =
            new World(
                i,
                Integer.parseInt(p.getProperty("flag" + i)),
                p.getProperty("eventmessage" + i),
                Integer.parseInt(p.getProperty("exprate" + i)),
                Integer.parseInt(p.getProperty("droprate" + i)),
                Integer.parseInt(p.getProperty("mesorate" + i)),
                Integer.parseInt(p.getProperty("bossdroprate" + i))); // ohlol

        worldRecommendedList.add(new Pair<>(i, p.getProperty("whyamirecommended" + i)));
        worlds.add(world);
        channels.add(new LinkedHashMap<Integer, String>());
        for (int j = 0; j < Integer.parseInt(p.getProperty("channels" + i)); j++) {
          int channelid = j + 1;
          Channel channel = new Channel(i, channelid);
          world.addChannel(channel);
          channels.get(i).put(channelid, channel.getIP());
        }
        world.setServerMessage(p.getProperty("servermessage" + i));
        System.out.println("Finished loading world " + i + "\r\n");
      }
    } catch (Exception e) {
      System.out.println("Error in moople.ini, start CreateINI.bat to re-make the file.");
      e.printStackTrace(); // For those who get errors
      System.exit(0);
    }

    acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 30);
    acceptor.setHandler(new MapleServerHandler());
    try {
      acceptor.bind(new InetSocketAddress(8484));
    } catch (IOException ex) {
    }

    System.out.println("Listening on port 8484\r\n\r\n");

    if (Boolean.parseBoolean(p.getProperty("gmserver"))) {
      GMServer.startGMServer();
    }
    System.out.println("Server is now online.");
    online = true;
  }