Config.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.communityserver;
  16. import java.io.File;
  17. import java.io.FileInputStream;
  18. import java.io.InputStream;
  19. import java.util.Properties;
  20. import java.util.logging.Logger;
  21. /**
  22. * @author Forsaiken
  23. */
  24. public final class Config
  25. {
  26. protected static final Logger _log = Logger.getLogger(Config.class.getName());
  27. /** Properties file for community server configurations */
  28. public static final String CONFIGURATION_FILE = "./config/communityserver.properties";
  29. /** Properties file for server function configurations */
  30. public static final String GENERAL_FILE = "./config/General.properties";
  31. /** ************************************************** **/
  32. /** Server Settings -Begin **/
  33. /** ************************************************** **/
  34. /** Driver to access to database */
  35. public static String DATABASE_DRIVER;
  36. /** Path to access to database */
  37. public static String DATABASE_URL;
  38. /** Database login */
  39. public static String DATABASE_LOGIN;
  40. /** Database password */
  41. public static String DATABASE_PASSWORD;
  42. /** Maximum number of connections to the database */
  43. public static int DATABASE_MAX_CONNECTIONS;
  44. /** Datapack root directory */
  45. public static File DATAPACK_ROOT;
  46. /** Accept alternate ID for server ? */
  47. public static boolean ACCEPT_ALTERNATE_ID;
  48. /** ID for request to the server */
  49. public static int REQUEST_ID;
  50. /** ************************************************** **/
  51. /** Server Settings -End **/
  52. /** ************************************************** **/
  53. /** Game Server login port */
  54. public static int GAME_SERVER_LOGIN_PORT;
  55. /** Game Server login Host */
  56. public static String GAME_SERVER_LOGIN_HOST;
  57. /** Accept new game server ? */
  58. public static boolean ACCEPT_NEW_GAMESERVER;
  59. public static boolean FLOOD_PROTECTION;
  60. public static int FAST_CONNECTION_LIMIT;
  61. public static int NORMAL_CONNECTION_TIME;
  62. public static int FAST_CONNECTION_TIME;
  63. public static int MAX_CONNECTION_PER_IP;
  64. /** General settings */
  65. public static int MIN_PLAYER_LVL_FOR_FORUM;
  66. public static int MIN_CLAN_LVL_FOR_FORUM;
  67. public static long MAIL_AUTO_DELETION_TIME;
  68. public static int GENERAL_THREAD_CORE_SIZE;
  69. public static final void load()
  70. {
  71. try
  72. {
  73. Properties serverSettings = new Properties();
  74. InputStream is = new FileInputStream(new File(CONFIGURATION_FILE));
  75. serverSettings.load(is);
  76. is.close();
  77. GAME_SERVER_LOGIN_HOST = serverSettings.getProperty("CSHostname","*");
  78. GAME_SERVER_LOGIN_PORT = Integer.parseInt(serverSettings.getProperty("CSPort","9013"));
  79. ACCEPT_NEW_GAMESERVER = Boolean.parseBoolean(serverSettings.getProperty("AcceptNewGameServer", "True"));
  80. REQUEST_ID = Integer.parseInt(serverSettings.getProperty("RequestServerID", "0"));
  81. ACCEPT_ALTERNATE_ID = Boolean.parseBoolean(serverSettings.getProperty("AcceptAlternateID", "True"));
  82. DATAPACK_ROOT = new File(serverSettings.getProperty("DatapackRoot", ".")).getCanonicalFile();
  83. DATABASE_DRIVER = serverSettings.getProperty("Driver", "com.mysql.jdbc.Driver");
  84. DATABASE_URL = serverSettings.getProperty("URL", "jdbc:mysql://localhost/l2jcb");
  85. DATABASE_LOGIN = serverSettings.getProperty("Login", "root");
  86. DATABASE_PASSWORD = serverSettings.getProperty("Password", "");
  87. DATABASE_MAX_CONNECTIONS = Integer.parseInt(serverSettings.getProperty("MaximumDbConnections", "10"));
  88. GENERAL_THREAD_CORE_SIZE = Integer.parseInt(serverSettings.getProperty("ThreadPoolSize", "1"));
  89. Properties generalSettings = new Properties();
  90. is = new FileInputStream(new File(GENERAL_FILE));
  91. generalSettings.load(is);
  92. is.close();
  93. MIN_PLAYER_LVL_FOR_FORUM = Integer.parseInt(generalSettings.getProperty("MinPlayerLvLForForum", "1"));
  94. MIN_CLAN_LVL_FOR_FORUM = Integer.parseInt(generalSettings.getProperty("MinClanLvLForForum", "2"));
  95. MAIL_AUTO_DELETION_TIME = Long.parseLong(generalSettings.getProperty("MailAutoDeletionTime", "90")) * 86400000;
  96. }
  97. catch (Exception e)
  98. {
  99. }
  100. }
  101. }