Addition of ServerMode enum.
This commit is contained in:
@ -56,6 +56,7 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.enums.IdFactoryType;
|
||||
import org.l2jmobius.commons.enums.ServerMode;
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.commons.util.PropertiesParser;
|
||||
import org.l2jmobius.commons.util.StringUtil;
|
||||
@ -144,6 +145,8 @@ public class Config
|
||||
// --------------------------------------------------
|
||||
// Variable Definitions
|
||||
// --------------------------------------------------
|
||||
public static ServerMode SERVER_MODE = ServerMode.NONE;
|
||||
|
||||
public static boolean ENABLE_ATTENDANCE_REWARDS;
|
||||
public static boolean PREMIUM_ONLY_ATTENDANCE_REWARDS;
|
||||
public static boolean ATTENDANCE_REWARDS_SHARE_ACCOUNT;
|
||||
@ -1282,10 +1285,12 @@ public class Config
|
||||
/**
|
||||
* This class initializes all global variables for configuration.<br>
|
||||
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server.
|
||||
* @param serverMode
|
||||
*/
|
||||
public static void load()
|
||||
public static void load(ServerMode serverMode)
|
||||
{
|
||||
if (Server.serverMode == Server.MODE_GAMESERVER)
|
||||
SERVER_MODE = serverMode;
|
||||
if (SERVER_MODE == ServerMode.GAME)
|
||||
{
|
||||
FLOOD_PROTECTOR_USE_ITEM = new FloodProtectorConfig("UseItemFloodProtector");
|
||||
FLOOD_PROTECTOR_ROLL_DICE = new FloodProtectorConfig("RollDiceFloodProtector");
|
||||
@ -3354,7 +3359,7 @@ public class Config
|
||||
|
||||
L2WALKER_PROTECTION = WalkerBotProtection.getBoolean("L2WalkerProtection", false);
|
||||
}
|
||||
else if (Server.serverMode == Server.MODE_LOGINSERVER)
|
||||
else if (SERVER_MODE == ServerMode.LOGIN)
|
||||
{
|
||||
final PropertiesParser ServerSettings = new PropertiesParser(LOGIN_CONFIG_FILE);
|
||||
|
||||
|
@ -26,7 +26,7 @@ import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.Server;
|
||||
import org.l2jmobius.commons.enums.ServerMode;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
@ -72,7 +72,7 @@ public class DatabaseBackup
|
||||
final String mysqldumpPath = System.getProperty("os.name").toLowerCase().contains("win") ? Config.MYSQL_BIN_PATH : "";
|
||||
try
|
||||
{
|
||||
final Process process = Runtime.getRuntime().exec(mysqldumpPath + "mysqldump -u " + Config.DATABASE_LOGIN + (Config.DATABASE_PASSWORD.trim().isEmpty() ? "" : " -p" + Config.DATABASE_PASSWORD) + " " + Config.DATABASE_URL.replace("jdbc:mariadb://", "").replaceAll(".*\\/|\\?.*", "") + " -r " + Config.BACKUP_PATH + (Server.serverMode == Server.MODE_GAMESERVER ? "game" : "login") + new SimpleDateFormat("_yyyy_MM_dd_HH_mm'.sql'").format(new Date()));
|
||||
final Process process = Runtime.getRuntime().exec(mysqldumpPath + "mysqldump -u " + Config.DATABASE_LOGIN + (Config.DATABASE_PASSWORD.trim().isEmpty() ? "" : " -p" + Config.DATABASE_PASSWORD) + " " + Config.DATABASE_URL.replace("jdbc:mariadb://", "").replaceAll(".*\\/|\\?.*", "") + " -r " + Config.BACKUP_PATH + (Config.SERVER_MODE == ServerMode.GAME ? "game" : "login") + new SimpleDateFormat("_yyyy_MM_dd_HH_mm'.sql'").format(new Date()));
|
||||
process.waitFor();
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -14,17 +14,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius;
|
||||
package org.l2jmobius.commons.enums;
|
||||
|
||||
/**
|
||||
* This class used to be the starter class, since LS/GS split, it only retains server mode
|
||||
* @author Mobius
|
||||
*/
|
||||
public class Server
|
||||
public enum ServerMode
|
||||
{
|
||||
// constants for the server mode
|
||||
private static final int MODE_NONE = 0;
|
||||
public static final int MODE_GAMESERVER = 1;
|
||||
public static final int MODE_LOGINSERVER = 2;
|
||||
|
||||
public static int serverMode = MODE_NONE;
|
||||
NONE,
|
||||
GAME,
|
||||
LOGIN;
|
||||
}
|
@ -29,9 +29,9 @@ import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.Server;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.enums.ServerMode;
|
||||
import org.l2jmobius.commons.util.DeadLockDetector;
|
||||
import org.l2jmobius.gameserver.cache.HtmCache;
|
||||
import org.l2jmobius.gameserver.data.sql.impl.AnnouncementsTable;
|
||||
@ -180,7 +180,6 @@ public class GameServer
|
||||
public GameServer() throws Exception
|
||||
{
|
||||
final long serverLoadStart = System.currentTimeMillis();
|
||||
Server.serverMode = Server.MODE_GAMESERVER;
|
||||
|
||||
// GUI
|
||||
if (!GraphicsEnvironment.isHeadless())
|
||||
@ -189,6 +188,9 @@ public class GameServer
|
||||
new Gui();
|
||||
}
|
||||
|
||||
// Initialize config
|
||||
Config.load(ServerMode.GAME);
|
||||
|
||||
// Create log folder
|
||||
final File logFolder = new File(Config.DATAPACK_ROOT, "log");
|
||||
logFolder.mkdir();
|
||||
@ -199,8 +201,6 @@ public class GameServer
|
||||
LogManager.getLogManager().readConfiguration(is);
|
||||
}
|
||||
|
||||
// Initialize config
|
||||
Config.load();
|
||||
printSection("Database");
|
||||
DatabaseFactory.init();
|
||||
|
||||
|
@ -169,7 +169,7 @@ public class Gui
|
||||
{
|
||||
if (JOptionPane.showOptionDialog(null, "Reload configs?", "Select an option", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, confirmOptions, confirmOptions[1]) == 0)
|
||||
{
|
||||
Config.load();
|
||||
Config.load(Config.SERVER_MODE);
|
||||
}
|
||||
});
|
||||
mnReload.add(mntmConfigs);
|
||||
|
@ -30,9 +30,9 @@ import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.Server;
|
||||
import org.l2jmobius.commons.database.DatabaseBackup;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.enums.ServerMode;
|
||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||
import org.l2jmobius.loginserver.network.ClientNetworkManager;
|
||||
import org.l2jmobius.loginserver.ui.Gui;
|
||||
@ -62,8 +62,6 @@ public class LoginServer
|
||||
|
||||
private LoginServer() throws Exception
|
||||
{
|
||||
Server.serverMode = Server.MODE_LOGINSERVER;
|
||||
|
||||
// GUI
|
||||
if (!GraphicsEnvironment.isHeadless())
|
||||
{
|
||||
@ -71,6 +69,9 @@ public class LoginServer
|
||||
new Gui();
|
||||
}
|
||||
|
||||
// Load Config
|
||||
Config.load(ServerMode.LOGIN);
|
||||
|
||||
// Create log folder
|
||||
final File logFolder = new File(".", "log");
|
||||
logFolder.mkdir();
|
||||
@ -86,9 +87,6 @@ public class LoginServer
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
// Load Config
|
||||
Config.load();
|
||||
|
||||
// Prepare Database
|
||||
DatabaseFactory.init();
|
||||
|
||||
|
@ -25,8 +25,8 @@ import java.util.Base64;
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.Server;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.enums.ServerMode;
|
||||
|
||||
/**
|
||||
* This class SQL Account Manager
|
||||
@ -41,8 +41,7 @@ public class SQLAccountManager
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Server.serverMode = Server.MODE_LOGINSERVER;
|
||||
Config.load();
|
||||
Config.load(ServerMode.LOGIN);
|
||||
DatabaseFactory.init();
|
||||
|
||||
try (Scanner _scn = new Scanner(System.in))
|
||||
|
@ -31,8 +31,8 @@ import java.util.Properties;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.Server;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.enums.ServerMode;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.loginserver.GameServerTable;
|
||||
|
||||
@ -184,9 +184,7 @@ public abstract class BaseGameServerRegister
|
||||
*/
|
||||
public void load()
|
||||
{
|
||||
Server.serverMode = Server.MODE_LOGINSERVER;
|
||||
|
||||
Config.load();
|
||||
Config.load(ServerMode.LOGIN);
|
||||
DatabaseFactory.init();
|
||||
GameServerTable.getInstance();
|
||||
|
||||
|
Reference in New Issue
Block a user