Skip to content
Merged

Limbo #729

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
6 changes: 2 additions & 4 deletions DockerFiles/Dockerfile.game_server
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ RUN curl -fSL -o /tmp/worlds.tar.gz "https://files.catbox.moe/9uas8z.gz" && \

EXPOSE 25565 65535 8080 20000

RUN cp configuration_files/NanoLimbo-1.10.2.jar ./NanoLimbo-1.10.2.jar && \
cp configuration_files/settings.yml ./settings.yml && \
RUN cp configuration_files/server.toml ./server.toml && \
cp -a configuration_files/skyblock/. configuration/skyblock/ && \
cp configuration_files/entrypoint.sh ./entrypoint.sh && \
chmod +x entrypoint.sh && \
sed -i "s/ip: 'localhost'/ip: '0.0.0.0'/" ./settings.yml
chmod +x entrypoint.sh

CMD ["sh", "entrypoint.sh"]
16 changes: 4 additions & 12 deletions DockerFiles/Dockerfile.proxy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM eclipse-temurin:25-jdk

WORKDIR /app

RUN apt-get update && apt-get install -y jq expect netcat-traditional curl && apt-get clean
RUN apt-get update && apt-get install -y jq netcat-traditional curl && apt-get clean

# Download Velocity proxy JAR
RUN curl -fSL -o velocity.jar "https://fill-data.papermc.io/v1/objects/ef1a852bfae7397e84907837925e7ad21c6312066290edaae401b77f6f423ac3/velocity-3.4.0-SNAPSHOT-558.jar"
Expand All @@ -14,22 +14,14 @@ RUN mkdir -p plugins && \
# Copy configuration data
COPY ./configuration /app/configuration_files

# Run Velocity to generate forwarding.secret, then shut it down
RUN printf '#!/usr/bin/expect -f\nset timeout 120\nspawn java -jar velocity.jar\nexpect ">"\nsend "shutdown\\r"\nexpect eof\n' > /tmp/run_velocity.exp && \
chmod +x /tmp/run_velocity.exp && \
/tmp/run_velocity.exp && \
rm /tmp/run_velocity.exp

# Replace generated velocity.toml with our own
RUN rm -f velocity.toml && \
cp configuration_files/velocity.toml velocity.toml

# Set up config.yml with the generated forwarding secret
# Set up config.yml template
RUN mkdir -p configuration && \
cp configuration_files/config.example.yml ./configuration/config.yml && \
secret=$(cat forwarding.secret) && \
sed -i "s/velocity-secret: .*/velocity-secret: '$secret'/" ./configuration/config.yml
cp configuration_files/config.example.yml ./configuration/config.yml

EXPOSE 25565

CMD ["sh", "-c", "cp forwarding.secret /app/configuration_files/forwarding.secret && java -jar velocity.jar"]
CMD ["sh", "-c", "[ -n \"$FORWARDING_SECRET\" ] || { echo 'FORWARDING_SECRET is required' >&2; exit 1; }; printf '%s' \"$FORWARDING_SECRET\" > /app/forwarding.secret; sed -i \"s/velocity-secret: .*/velocity-secret: '$FORWARDING_SECRET'/\" /app/configuration/config.yml; java -jar velocity.jar"]
4 changes: 2 additions & 2 deletions commons/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {
}

// Must match AtlasRedisAPI's Jedis version to avoid conflicts
implementation("redis.clients:jedis:4.2.3")
implementation("redis.clients:jedis:7.2.0")

implementation("org.spongepowered:configurate-yaml:4.2.0")
implementation("de.exlll:configlib-yaml:4.8.1")
}
51 changes: 24 additions & 27 deletions commons/src/main/java/net/swofty/commons/config/ConfigProvider.java
Original file line number Diff line number Diff line change
@@ -1,47 +1,44 @@
package net.swofty.commons.config;

import de.exlll.configlib.ConfigurationProperties;
import de.exlll.configlib.NameFormatters;
import de.exlll.configlib.YamlConfigurationProperties;
import de.exlll.configlib.YamlConfigurations;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.yaml.NodeStyle;
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
import org.jetbrains.annotations.NotNull;
import org.tinylog.Logger;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;

public class ConfigProvider {

final static ConfigurationProperties.EnvVarResolutionConfiguration envResolution = ConfigurationProperties.EnvVarResolutionConfiguration
.resolveEnvVarsWithPrefix("HYPIXEL_", false);

@NotNull
static final YamlConfigurationProperties properties = YamlConfigurationProperties.newBuilder()
.setNameFormatter(NameFormatters.LOWER_KEBAB_CASE)
.charset(StandardCharsets.UTF_8)
.setEnvVarResolutionConfiguration(envResolution)
.build();

@Getter
@Setter
@Accessors(fluent = true)
private static Settings settings;

static {
try {
Logger.info("Loading config...");

YamlConfigurationLoader loader = YamlConfigurationLoader.builder()
.path(Path.of("./configuration/config.yml"))
.nodeStyle(NodeStyle.BLOCK)
.build();

CommentedConfigurationNode root = loader.load();
CommentedConfigurationNode defaults = loader.createNode();
defaults.set(Settings.class, new Settings());
root.mergeFrom(defaults);

Settings loaded = root.get(Settings.class);
if (loaded == null) {
loaded = new Settings();
}

loader.save(root);
settings(loaded);
} catch (IOException e) {
throw new RuntimeException("Failed to load configuration", e);
}
Logger.info("Loading config...");
settings(
YamlConfigurations.update(
Path.of("./configuration/config.yml"),
Settings.class,
properties
)
);
}

}
96 changes: 50 additions & 46 deletions commons/src/main/java/net/swofty/commons/config/Settings.java
Original file line number Diff line number Diff line change
@@ -1,72 +1,76 @@
package net.swofty.commons.config;

import de.exlll.configlib.Comment;
import de.exlll.configlib.Configuration;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;

import java.util.HashMap;
import java.util.Map;

@Getter
@ConfigSerializable
@Configuration
@SuppressWarnings({"unused", "FieldMayBeFinal"})
public class Settings {

private String hostName = "0.0.0.0";
private long transferTimeout = 800;
@Comment("The host name or IP address to bind the server to")
private String hostName = "0.0.0.0";

@Comment("The MongoDB connection URI")
private String mongodb = "mongodb://localhost";
@Comment("The MongoDB connection URI")
private String mongodb = "mongodb://localhost";

@Comment("The Redis connection URI")
private String redisUri = "redis://localhost:6379";
@Comment("The Redis connection URI")
private String redisUri = "redis://localhost:6379";

@Comment("The secret key used to authenticate with Velocity proxy")
private String velocitySecret = "ixmSUgWOgvs7";
@Comment("The secret key used to authenticate with Velocity proxy")
private String velocitySecret = "ixmSUgWOgvs7";

private boolean requireAuth = false;
private boolean requireAuth = false;

@Comment("Whether to enable sandbox features (such as editing items)")
private boolean sandbox = false;
@Comment("Whether to enable sandbox features (such as editing items)")
private boolean sandbox = false;

@Comment("Integrations with services")
private IntegrationSettings integrations = new IntegrationSettings();
@Comment("Integrations with services")
private IntegrationSettings integrations = new IntegrationSettings();

@Comment("Settings related to configuration of Limbo server connections")
private LimboSettings limbo = new LimboSettings();
@Comment("Settings related to configuration of Limbo server connections")
private LimboSettings limbo = new LimboSettings();

@Comment("Resource pack settings keyed by pack name (e.g. testingpack, bedwarspack)")
private java.util.Map<String, ResourcePackSettings> resourcePacks = new java.util.HashMap<>();
@Comment("Resource pack settings keyed by pack name (e.g. testingpack, bedwarspack)")
private Map<String, ResourcePackSettings> resourcePacks = new HashMap<>();

@Getter
@ConfigSerializable
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public static class LimboSettings {
private String hostName = "127.0.0.1";
private int port = 65535;
}
@Getter
@Configuration
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public static class LimboSettings {
private String hostName = "127.0.0.1";
private int port = 65535;
}

@Getter
@ConfigSerializable
@NoArgsConstructor
public static class ResourcePackSettings {
@Comment("Base URL of the pack server (e.g. http://0.0.0.0:7270)")
private String serverUrl = "http://127.0.0.1:7270";
}
@Getter
@Configuration
@NoArgsConstructor
public static class ResourcePackSettings {
@Comment("Base URL of the pack server (e.g. http://0.0.0.0:7270)")
private String serverUrl = "http://127.0.0.1:7270";
}

@Getter
@ConfigSerializable
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public static class IntegrationSettings {
@Comment("Whether to enable Spark for performance monitoring")
private boolean spark = false;
@Getter
@Configuration
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public static class IntegrationSettings {
@Comment("Whether to enable Spark for performance monitoring")
private boolean spark = false;

@Comment("Whether to enable anti-cheat measures")
private boolean anticheat = false;
@Comment("Whether to enable anti-cheat measures")
private boolean anticheat = false;

@Comment("Whether to enable ViaVersion for supporting multiple Minecraft versions. This may cause issues of any kind")
private boolean viaVersion = false;
@Comment("Whether to enable ViaVersion for supporting multiple Minecraft versions. This may cause issues of any kind")
private boolean viaVersion = false;

private String sentryDsn = "";
}
@Comment("The DSN to use for Sentry error tracking. If empty, Sentry will be disabled")
private String sentryDsn = "";
}

}
Binary file removed configuration/NanoLimbo-1.10.2.jar
Binary file not shown.
Binary file added configuration/PicoLimbo.jar
Binary file not shown.
19 changes: 10 additions & 9 deletions configuration/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#!/bin/bash

# Copy the Forwarding Secret
cp configuration_files/forwarding.secret ./forwarding.secret
if [ -n "$FORWARDING_SECRET" ]; then
secret="$FORWARDING_SECRET"
elif [ -f ./configuration_files/forwarding.secret ]; then
secret=$(cat ./configuration_files/forwarding.secret)
else
echo "FORWARDING_SECRET is required (env var or configuration_files/forwarding.secret)" >&2
exit 1
fi

printf '%s' "$secret" > ./forwarding.secret

# Ensure configuration/config.yml exists
mkdir -p ./configuration
Expand All @@ -10,14 +18,7 @@ if [ ! -f ./configuration/config.yml ]; then
fi

# Update config.yml with the forwarding secret (velocity-secret)
secret=$(cat ./forwarding.secret)
sed -i "s/velocity-secret: .*/velocity-secret: '$secret'/" ./configuration/config.yml

# Replace the secret in settings.yml
sed -i "s/secret: '.*'/secret: '$secret'/" ./settings.yml

# Set the settings.yml bind: ip: 'localhost' to bind: ip: '0.0.0.0'
sed -i "s/ip: 'localhost'/ip: '0.0.0.0'/" ./settings.yml

echo "$SERVICE_CMD"
exec $SERVICE_CMD
77 changes: 77 additions & 0 deletions configuration/server.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# configuration for PicoLimbo
bind = "0.0.0.0:65535"
welcome_message = ""
action_bar = ""
default_game_mode = "survival"
hardcore = true
fetch_player_skins = false
reduced_debug_info = false
allow_unsupported_versions = false
allow_flight = false
accept_transfers = false

[forwarding]
method = "MODERN"
secret = "${FORWARDING_SECRET}"

[world]
spawn_position = [
-22.5,
31.06250,
21.5,
]
spawn_rotation = [
-90.0,
0.0,
]
dimension = "end"
time = "day"

[world.experimental]
view_distance = 4
schematic_file = ""
polar_file = "limbo.polar"
lock_time = false

[world.boundaries]
enabled = false
min_y = -64
teleport_message = ""

[server_list]
reply_to_status = false
max_players = 20
message_of_the_day = "Limbo"
show_online_player_count = false
server_icon = "server-icon.png"

[compression]
threshold = -1
level = 6

[tab_list]
enabled = false
header = ""
footer = ""
player_listed = false

[boss_bar]
enabled = false
title = ""
health = 1.0
color = "pink"
division = 0

[title]
enabled = false
title = ""
subtitle = ""
fade_in = 10
stay = 70
fade_out = 20

[commands]
spawn = ""
fly = ""
fly_speed = ""
transfer = ""
Loading