Пример #1
0
 public void gmChat(String message, String exclude) {
   GMServer.broadcastInGame(MaplePacketCreator.serverNotice(6, message));
   GMServer.broadcastOutGame(GMPacketCreator.chat(message), exclude);
 }
Пример #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;
  }