Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command args #37

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/net/cytonic/cytosis/Cytosis.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public static void main(String[] args) {
} else {
Logger.info("File manager initialized!");
CytosisSettings.loadEnvironmentVariables();
CytosisSettings.loadCommandArgs();
if (CytosisSettings.SERVER_PROXY_MODE) {
Logger.info("Enabling velocity!");
VelocityProxy.enable(CytosisSettings.SERVER_SECRET);
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/net/cytonic/cytosis/config/CytosisSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,31 @@ public static void loadEnvironmentVariables() {
if (!(System.getenv("RABBITMQ_USERNAME") == null)) CytosisSettings.RABBITMQ_USERNAME = System.getenv("RABBITMQ_USERNAME");
if (!(System.getenv("RABBITMQ_PORT") == null)) CytosisSettings.RABBITMQ_PORT = Integer.parseInt(System.getenv("RABBITMQ_PORT"));
}

public static void loadCommandArgs() {
Logger.info("Loading command args!");
// logging
if (!(System.getProperty("LOG_PLAYER_IPS") == null)) CytosisSettings.LOG_PLAYER_IPS = Boolean.parseBoolean(System.getProperty("LOG_PLAYER_IPS"));
if (!(System.getProperty("LOG_PLAYER_JOINS") == null)) CytosisSettings.LOG_PLAYER_JOINS = Boolean.parseBoolean(System.getProperty("LOG_PLAYER_JOINS"));
if (!(System.getProperty("LOG_PLAYER_QUITS") == null)) CytosisSettings.LOG_PLAYER_QUITS = Boolean.parseBoolean(System.getProperty("LOG_PLAYER_QUITS"));
if (!(System.getProperty("LOG_PLAYER_COMMANDS") == null)) CytosisSettings.LOG_PLAYER_COMMANDS = Boolean.parseBoolean(System.getProperty("LOG_PLAYER_COMMANDS"));
if (!(System.getProperty("LOG_PLAYER_CHAT") == null)) CytosisSettings.LOG_PLAYER_CHAT = Boolean.parseBoolean(System.getProperty("LOG_PLAYER_CHAT"));
// database
if (!(System.getProperty("DATABASE_USER") == null)) CytosisSettings.DATABASE_USER = System.getProperty("DATABASE_USER");
if (!(System.getProperty("DATABASE_PASSWORD") == null)) CytosisSettings.DATABASE_PASSWORD = System.getProperty("DATABASE_PASSWORD");
if (!(System.getProperty("DATABASE_HOST") == null)) CytosisSettings.DATABASE_HOST = System.getProperty("DATABASE_HOST");
if (!(System.getProperty("DATABASE_PORT") == null)) CytosisSettings.DATABASE_PORT = Integer.parseInt((System.getProperty("DATABASE_PORT")));
if (!(System.getProperty("DATABASE_NAME") == null)) CytosisSettings.DATABASE_NAME = System.getProperty("DATABASE_NAME");
if (!(System.getProperty("DATABASE_USE_SSL") == null)) CytosisSettings.DATABASE_USE_SSL = Boolean.parseBoolean(System.getProperty("DATABASE_USE_SSL"));
//server
if (!(System.getProperty("SERVER_PROXY_MODE") == null)) CytosisSettings.SERVER_PROXY_MODE = Boolean.parseBoolean(System.getProperty("SERVER_PROXY_MODE"));
if (!(System.getProperty("SERVER_SECRET") == null)) CytosisSettings.SERVER_SECRET = System.getProperty("SERVER_SECRET");
if (!(System.getProperty("SERVER_PORT") == null)) CytosisSettings.SERVER_PORT = Integer.parseInt(System.getProperty("SERVER_PORT"));
// RabbitMQ
if (!(System.getProperty("RABBITMQ_ENABLED") == null)) CytosisSettings.RABBITMQ_ENABLED = Boolean.parseBoolean(System.getProperty("RABBITMQ_ENABLED"));
if (!(System.getProperty("RABBITMQ_HOST") == null)) CytosisSettings.RABBITMQ_HOST = System.getProperty("RABBITMQ_HOST");
if (!(System.getProperty("RABBITMQ_PASSWORD") == null)) CytosisSettings.RABBITMQ_PASSWORD = System.getProperty("RABBITMQ_PASSWORD");
if (!(System.getProperty("RABBITMQ_USERNAME") == null)) CytosisSettings.RABBITMQ_USERNAME = System.getProperty("RABBITMQ_USERNAME");
if (!(System.getProperty("RABBITMQ_PORT") == null)) CytosisSettings.RABBITMQ_PORT = Integer.parseInt(System.getProperty("RABBITMQ_PORT"));
}
}