mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-08-03 12:11:50 +00:00
Compare commits
6 Commits
72f0c15108
...
d8cf0acf41
Author | SHA1 | Date | |
---|---|---|---|
d8cf0acf41 | |||
25d858890a | |||
c9b1c55982 | |||
3a49892fa3 | |||
5c385476cb | |||
7d79fed076 |
@ -15,7 +15,7 @@ WORKDIR /app
|
||||
|
||||
RUN git clone --branch ${DATA_BRANCH} --depth 1 ${DATA_REPOSITORY}
|
||||
|
||||
FROM bitnami/java:21.0.1-12
|
||||
FROM bitnami/java:17.0.9-11
|
||||
|
||||
RUN apt-get update && apt-get install unzip
|
||||
|
||||
|
@ -111,6 +111,14 @@ public class ConfigContainer {
|
||||
* Retrieves the given from the environment variables and tries to parse it as a Set<String>.
|
||||
* <p>
|
||||
* If the environment variable is not present or the parsing fails then the default value will be returned.
|
||||
* <p>
|
||||
* It expects the following structure:
|
||||
* <p>
|
||||
* hello,world
|
||||
* <p>
|
||||
* | |- second entry
|
||||
* <p>
|
||||
* |- first entry
|
||||
*
|
||||
* @param key The name of the environment variable to parse
|
||||
* @param defaultValue The default value when the environment variable does not exist or is not a valid set
|
||||
@ -130,9 +138,17 @@ public class ConfigContainer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the given key from the environment variables and tries to parse it as a string array.
|
||||
* Retrieves the given key from the environment variables and tries to parse it as a Set<int>.
|
||||
* <p>
|
||||
* If the environment variable is not present or the parsing fails then the default value will be returned.
|
||||
* <p>
|
||||
* It expects the following structure:
|
||||
* <p>
|
||||
* 42,1337
|
||||
* <p>
|
||||
* | |- second entry
|
||||
* <p>
|
||||
* |- first entry
|
||||
*
|
||||
* @param key The name of the environment variable
|
||||
* @param defaultValue The default value when the environment variable does not exist
|
||||
@ -175,6 +191,14 @@ public class ConfigContainer {
|
||||
* Retrieves the given key from the environment variables and tries to parse it as string array.
|
||||
* <p>
|
||||
* If the environment variable is not present or the parsing fails then the default value will be returned.
|
||||
* <p>
|
||||
* It expects the following structure:
|
||||
* <p>
|
||||
* hello,world
|
||||
* <p>
|
||||
* | |- second entry
|
||||
* <p>
|
||||
* |- first entry
|
||||
*
|
||||
* @param key The name of the environment variable to parse
|
||||
* @param defaultValue The default value when the environment variable does not exist
|
||||
@ -191,6 +215,24 @@ public class ConfigContainer {
|
||||
return currentValue.split(separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the given key from the environment variables and tries to parse it as an int array.
|
||||
* <p>
|
||||
* If the environment variable is not present or the parsing fails then the default value will be returned.
|
||||
* <p>
|
||||
* It expects the following structure:
|
||||
* <p>
|
||||
* 1,2
|
||||
* <p>
|
||||
* | |- second entry
|
||||
* <p>
|
||||
* |- first entry
|
||||
*
|
||||
* @param key The name of the environment variable to parse
|
||||
* @param defaultValue The default value when the environment variable does not exist
|
||||
* @param separator The separator which will be used for splitting up the string
|
||||
* @return The parsed int array or the default value
|
||||
*/
|
||||
static int[] getIntArrayFromEnv(String key, int[] defaultValue, String separator) {
|
||||
var currentValue = System.getenv(key);
|
||||
|
||||
@ -201,6 +243,27 @@ public class ConfigContainer {
|
||||
return Arrays.stream(currentValue.split(separator)).mapToInt(Integer::parseInt).toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the given key from the environment variables and tries to parse it as a MailItem array.
|
||||
* <p>
|
||||
* If the environment variable is not present or the parsing fails then the default value will be returned.
|
||||
* <p>
|
||||
* It expects the following structure:
|
||||
* <p>
|
||||
* 1,1,1|2,1,1
|
||||
* <p>
|
||||
* | | |- Item level
|
||||
* <p>
|
||||
* | |- Item count
|
||||
* <p>
|
||||
* |- Item ID
|
||||
*
|
||||
* @param key The name of the environment variable to parse
|
||||
* @param defaultValue The default value when the environment variable does not exist
|
||||
* @param partsSeparator The separator which will be used for splitting up the string into parts
|
||||
* @param valuesSeparator The separator which will be used for splitting up the parts into values
|
||||
* @return The parsed MailItem array or the default value
|
||||
*/
|
||||
static emu.grasscutter.game.mail.Mail.MailItem[] getMailItemsFromEnv(String key, emu.grasscutter.game.mail.Mail.MailItem[] defaultValue, String partsSeparator, String valuesSeparator) {
|
||||
var currentValue = System.getenv(key);
|
||||
|
||||
@ -219,6 +282,26 @@ public class ConfigContainer {
|
||||
}).toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the given key from the environment variables and tries to parse it as a MailItem array.
|
||||
* <p>
|
||||
* If the environment variable is not present or the parsing fails then the default value will be returned.
|
||||
* <p>
|
||||
* It expects the following structure:
|
||||
* VISION_LEVEL_NORMAL,80,20|VISION_LEVEL_LITTLE_REMOTE,16,40
|
||||
* <p>
|
||||
* | | |- Grid width
|
||||
* <p>
|
||||
* | |- Vision range
|
||||
* <p>
|
||||
* |- Name
|
||||
*
|
||||
* @param key The name of the environment variable to parse
|
||||
* @param defaultValue The default value when the environment variable does not exist
|
||||
* @param partsSeparator The separator which will be used for splitting up the string into parts
|
||||
* @param valuesSeparator The separator which will be used for splitting up the parts into values
|
||||
* @return The parsed VisionOptions or the default value
|
||||
*/
|
||||
static VisionOptions[] getVisionOptionsFromEnv(String key, VisionOptions[] defaultValue, String partsSeparator, String valuesSeparator) {
|
||||
var currentValue = System.getenv(key);
|
||||
|
||||
@ -236,6 +319,29 @@ public class ConfigContainer {
|
||||
}).toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the given key from the environment variables and tries to parse it as a Region array.
|
||||
* <p>
|
||||
* If the environment variable is not present or the parsing fails then the default value will be returned.
|
||||
* <p>
|
||||
* It expects the following structure:
|
||||
* <p>
|
||||
* my region,my title,127.0.0.1,1337|my second region, my second title,127.0.0.1,42
|
||||
* <p>
|
||||
* | | | |- port
|
||||
* <p>
|
||||
* | | |- address
|
||||
* <p>
|
||||
* | |- title
|
||||
* <p>
|
||||
* |- name
|
||||
*
|
||||
* @param key The name of the environment variable to parse
|
||||
* @param defaultValue The default value when the environment variable does not exist
|
||||
* @param partsSeparator The separator which will be used for splitting up the string into parts
|
||||
* @param valuesSeparator The separator which will be used for splitting up the parts into values
|
||||
* @return The parsed Region list or the default value
|
||||
*/
|
||||
static List<Region> getRegionsFromEnv(String key, List<Region> defaultValue, String partsSeparator, String valuesSeparator) {
|
||||
var currentValue = System.getenv(key);
|
||||
|
||||
@ -263,12 +369,17 @@ public class ConfigContainer {
|
||||
/* Option containers. */
|
||||
|
||||
public static class Database {
|
||||
public DataStore server = new DataStore();
|
||||
public DataStore game = new DataStore();
|
||||
public DataStore server = new DataStore("SERVER");
|
||||
public DataStore game = new DataStore("GAME");
|
||||
|
||||
public static class DataStore {
|
||||
public String connectionUri = "mongodb://localhost:27017";
|
||||
public String collection = "grasscutter";
|
||||
public String connectionUri;
|
||||
public String collection;
|
||||
|
||||
public DataStore(String key) {
|
||||
this.connectionUri = getStringFromEnv("DATABASE_INFO_" + key + "_CONNECTION_URI", "mongodb://localhost:27017");
|
||||
this.collection = getStringFromEnv("DATABASE_INFO_" + key + "_COLLECTION", "grasscutter");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,7 +403,7 @@ public class ConfigContainer {
|
||||
public boolean logCommands = getBoolFromEnv("SERVER_LOG_COMMANDS", false);
|
||||
|
||||
/**
|
||||
* If enabled, the 'require' Lua function will load the script's compiled varient into the context. (faster; doesn't work as well)
|
||||
* If enabled, the 'require' Lua function will load the script's compiled variant into the context. (faster; doesn't work as well)
|
||||
* If disabled, all 'require' calls will be replaced with the referenced script's source. (slower; works better)
|
||||
*/
|
||||
public boolean fastRequire = getBoolFromEnv("SERVER_FAST_REQUIRE", true);
|
||||
|
Reference in New Issue
Block a user