Custom Config support / Corrupt crux
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 479 B After Width: | Height: | Size: 511 B |
@@ -133,7 +133,7 @@ public class SectorPresets{
|
||||
new ShapeTextMarker("To [accent]power[] the plasma bore, research and place a [accent]beam node[].\nConnect the turbine condenser to the plasma bore.", 254f * 8f, 267f * 8f)
|
||||
),
|
||||
new CoreItemObjective(Items.beryllium, 5).withMarkers(
|
||||
new TextMarker("Once the plasma bore is powered, the next step is to route the resources to the core.\nUnlock and place [accent]ducts[] to move the mined resources to the core", 236f * 8f, 278f * 8f)
|
||||
new TextMarker("Once the plasma bore is powered, the next step is to route the resources to the core.\nResearch and place [accent]ducts[] to move the mined resources to the core.", 236f * 8f, 278f * 8f)
|
||||
),
|
||||
new CoreItemObjective(Items.beryllium, 200).withMarkers(
|
||||
new TextMarker("Expand your mining operation!\nPlace more plasma bores and use beam nodes and ducts to support them.", 253f * 8f, 282f * 8f),
|
||||
|
||||
@@ -453,59 +453,67 @@ public class Administration{
|
||||
subnetBans = Core.settings.getJson("banned-subnets", Seq.class, Seq::new);
|
||||
}
|
||||
|
||||
/** Server configuration definition. Each config value can be a string, boolean or number. */
|
||||
public enum Config{
|
||||
name("The server name as displayed on clients.", "Server", "servername"),
|
||||
desc("The server description, displayed under the name. Max 100 characters.", "off"),
|
||||
port("The port to host on.", Vars.port),
|
||||
autoUpdate("Whether to auto-update and exit when a new bleeding-edge update arrives.", false),
|
||||
showConnectMessages("Whether to display connect/disconnect messages.", true),
|
||||
enableVotekick("Whether votekick is enabled.", true),
|
||||
startCommands("Commands run at startup. This should be a comma-separated list.", ""),
|
||||
crashReport("Whether to send crash reports.", false, "crashreport"),
|
||||
logging("Whether to log everything to files.", true),
|
||||
strict("Whether strict mode is on - corrects positions and prevents duplicate UUIDs.", true),
|
||||
antiSpam("Whether spammers are automatically kicked and rate-limited.", headless),
|
||||
interactRateWindow("Block interaction rate limit window, in seconds.", 6),
|
||||
interactRateLimit("Block interaction rate limit.", 25),
|
||||
interactRateKick("How many times a player must interact inside the window to get kicked.", 60),
|
||||
messageRateLimit("Message rate limit in seconds. 0 to disable.", 0),
|
||||
messageSpamKick("How many times a player must send a message before the cooldown to get kicked. 0 to disable.", 3),
|
||||
socketInput("Allows a local application to control this server through a local TCP socket.", false, "socket", () -> Events.fire(Trigger.socketConfigChanged)),
|
||||
socketInputPort("The port for socket input.", 6859, () -> Events.fire(Trigger.socketConfigChanged)),
|
||||
socketInputAddress("The bind address for socket input.", "localhost", () -> Events.fire(Trigger.socketConfigChanged)),
|
||||
allowCustomClients("Whether custom clients are allowed to connect.", !headless, "allow-custom"),
|
||||
whitelist("Whether the whitelist is used.", false),
|
||||
motd("The message displayed to people on connection.", "off"),
|
||||
autosave("Whether the periodically save the map when playing.", false),
|
||||
autosaveAmount("The maximum amount of autosaves. Older ones get replaced.", 10),
|
||||
autosaveSpacing("Spacing between autosaves in seconds.", 60 * 5),
|
||||
debug("Enable debug logging", false, () -> Log.level = debug() ? LogLevel.debug : LogLevel.info),
|
||||
snapshotInterval("Client entity snapshot interval in ms.", 200);
|
||||
/**
|
||||
* Server configuration definition. Each config value can be a string, boolean or number.
|
||||
* Creating a new Config instance implicitly adds it to the list of server configs. This can be used for custom plugin configuration.
|
||||
* */
|
||||
public static class Config{
|
||||
public static final Seq<Config> all = new Seq<>();
|
||||
|
||||
public static final Config[] all = values();
|
||||
public static final Config
|
||||
|
||||
serverName = new Config("name", "The server name as displayed on clients.", "Server", "servername"),
|
||||
desc = new Config("desc", "The server description, displayed under the name. Max 100 characters.", "off"),
|
||||
port = new Config("port", "The port to host on.", Vars.port),
|
||||
autoUpdate = new Config("autoUpdate", "Whether to auto-update and exit when a new bleeding-edge update arrives.", false),
|
||||
showConnectMessages = new Config("showConnectMessages", "Whether to display connect/disconnect messages.", true),
|
||||
enableVotekick = new Config("enableVotekick", "Whether votekick is enabled.", true),
|
||||
startCommands = new Config("startCommands", "Commands run at startup. This should be a comma-separated list.", ""),
|
||||
logging = new Config("logging", "Whether to log everything to files.", true),
|
||||
strict = new Config("strict", "Whether strict mode is on - corrects positions and prevents duplicate UUIDs.", true),
|
||||
antiSpam = new Config("antiSpam", "Whether spammers are automatically kicked and rate-limited.", headless),
|
||||
interactRateWindow = new Config("interactRateWindow", "Block interaction rate limit window, in seconds.", 6),
|
||||
interactRateLimit = new Config("interactRateLimit", "Block interaction rate limit.", 25),
|
||||
interactRateKick = new Config("interactRateKick", "How many times a player must interact inside the window to get kicked.", 60),
|
||||
messageRateLimit = new Config("messageRateLimit", "Message rate limit in seconds. 0 to disable.", 0),
|
||||
messageSpamKick = new Config("messageSpamKick", "How many times a player must send a message before the cooldown to get kicked. 0 to disable.", 3),
|
||||
socketInput = new Config("socketInput", "Allows a local application to control this server through a local TCP socket.", false, "socket", () -> Events.fire(Trigger.socketConfigChanged)),
|
||||
socketInputPort = new Config("socketInputPort", "The port for socket input.", 6859, () -> Events.fire(Trigger.socketConfigChanged)),
|
||||
socketInputAddress = new Config("socketInputAddress", "The bind address for socket input.", "localhost", () -> Events.fire(Trigger.socketConfigChanged)),
|
||||
allowCustomClients = new Config("allowCustomClients", "Whether custom clients are allowed to connect.", !headless, "allow-custom"),
|
||||
whitelist = new Config("whitelist", "Whether the whitelist is used.", false),
|
||||
motd = new Config("motd", "The message displayed to people on connection.", "off"),
|
||||
autosave = new Config("autosave", "Whether the periodically save the map when playing.", false),
|
||||
autosaveAmount = new Config("autosaveAmount", "The maximum amount of autosaves. Older ones get replaced.", 10),
|
||||
autosaveSpacing = new Config("autosaveSpacing", "Spacing between autosaves in seconds.", 60 * 5),
|
||||
debug = new Config("debug", "Enable debug logging", false, () -> Log.level = debug() ? LogLevel.debug : LogLevel.info),
|
||||
snapshotInterval = new Config("snapshotInterval", "Client entity snapshot interval in ms.", 200);
|
||||
|
||||
public final Object defaultValue;
|
||||
public final String key, description;
|
||||
public final String name, key, description;
|
||||
|
||||
final Runnable changed;
|
||||
|
||||
Config(String description, Object def){
|
||||
this(description, def, null, null);
|
||||
public Config(String name, String description, Object def){
|
||||
this(name, description, def, null, null);
|
||||
}
|
||||
|
||||
Config(String description, Object def, String key){
|
||||
this(description, def, key, null);
|
||||
public Config(String name, String description, Object def, String key){
|
||||
this(name, description, def, key, null);
|
||||
}
|
||||
|
||||
Config(String description, Object def, Runnable changed){
|
||||
this(description, def, null, changed);
|
||||
public Config(String name, String description, Object def, Runnable changed){
|
||||
this(name, description, def, null, changed);
|
||||
}
|
||||
|
||||
Config(String description, Object def, String key, Runnable changed){
|
||||
public Config(String name, String description, Object def, String key, Runnable changed){
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.key = key == null ? name() : key;
|
||||
this.key = key == null ? name : key;
|
||||
this.defaultValue = def;
|
||||
this.changed = changed == null ? () -> {} : changed;
|
||||
|
||||
all.add(this);
|
||||
}
|
||||
|
||||
public boolean isNum(){
|
||||
|
||||
@@ -111,7 +111,7 @@ public class NetworkIO{
|
||||
}
|
||||
|
||||
public static ByteBuffer writeServerData(){
|
||||
String name = (headless ? Config.name.string() : player.name);
|
||||
String name = (headless ? Config.serverName.string() : player.name);
|
||||
String description = headless && !Config.desc.string().equals("off") ? Config.desc.string() : "";
|
||||
String map = state.map.name();
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ public class MissileUnitType extends UnitType{
|
||||
range = 6f;
|
||||
targetPriority = -1f;
|
||||
outlineColor = Pal.darkOutline;
|
||||
fogRadius = 2f;
|
||||
//TODO weapon configs, etc?
|
||||
}
|
||||
}
|
||||
|
||||
@@ -572,17 +572,18 @@ public class ServerControl implements ApplicationListener{
|
||||
if(arg.length == 0){
|
||||
info("All config values:");
|
||||
for(Config c : Config.all){
|
||||
info("&lk| @: @", c.name(), "&lc&fi" + c.get());
|
||||
info("&lk| @: @", c.name, "&lc&fi" + c.get());
|
||||
info("&lk| | &lw" + c.description);
|
||||
info("&lk|");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
Config c = Config.valueOf(arg[0]);
|
||||
Config c = Config.all.find(conf -> conf.name.equalsIgnoreCase(arg[0]));
|
||||
|
||||
if(c != null){
|
||||
if(arg.length == 1){
|
||||
info("'@' is currently @.", c.name(), c.get());
|
||||
info("'@' is currently @.", c.name, c.get());
|
||||
}else{
|
||||
if(arg[1].equals("default")){
|
||||
c.set(c.defaultValue);
|
||||
@@ -599,10 +600,10 @@ public class ServerControl implements ApplicationListener{
|
||||
c.set(arg[1].replace("\\n", "\n"));
|
||||
}
|
||||
|
||||
info("@ set to @.", c.name(), c.get());
|
||||
info("@ set to @.", c.name, c.get());
|
||||
Core.settings.forceSave();
|
||||
}
|
||||
}catch(IllegalArgumentException e){
|
||||
}else{
|
||||
err("Unknown config: '@'. Run the command with no arguments to get a list of valid configs.", arg[0]);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user