Skip to content
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
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,19 @@ build/
### Mac OS ###
.DS_Store

### Islands ###

### Worlds ###
/configuration/skyblock/islands/hypixel_skyblock_island_template/
/configuration/skyblock/islands/hypixel_skyblock_hub/
/configuration/skyblock/islands/hypixel_skyblock_gold_mine/
/configuration/skyblock/islands/*
/configuration/logs/configuration/murdermystery/*
/configuration/hypixel_prototype_lobby/
.gradle/
/configuration/bedwars/*.polar

.gradle/
/server/proxy/logs/
/server/proxy/lang/
/server/forwarding.secret
/configuration/logs/configuration/murdermystery/aquarium.polar
/configuration/config.yml
/server/proxy/configuration/config.yml
4 changes: 2 additions & 2 deletions DockerFiles/Dockerfile.game_server
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ COPY ./configuration /app/configuration_files
# Create configuration folder
RUN mkdir -p configuration

# Copy resources.json
RUN cp configuration_files/resources.json ./configuration/resources.json
# Copy config.yml
RUN cp configuration_files/config.yml ./configuration/config.yml

# Make required folders
RUN mkdir -p ./configuration/skyblock/islands
Expand Down
9 changes: 4 additions & 5 deletions DockerFiles/Dockerfile.proxy
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@ RUN rm velocity.toml
# Add back our velocity.toml
RUN cp configuration_files/velocity.toml velocity.toml

# Download resources.json
# Download config.yml
RUN mkdir -p configuration

RUN cp configuration_files/resources.json ./configuration/resources.json
RUN cp configuration_files/config.example.yml ./configuration/config.yml


# Get Contents of the forwarding secret and add it to resources.json
# Get Contents of the forwarding secret and add it to config.yml
RUN secret=$(cat forwarding.secret) && \
jq --arg secret "$secret" '.["velocity-secret"] = $secret' ./configuration/resources.json > ./configuration/resources.json.tmp && \
mv ./configuration/resources.json.tmp ./configuration/resources.json
sed -i "s/velocity-secret: .*/velocity-secret: '$secret'/" ./configuration/config.yml

# Expose the required port
EXPOSE 25565
Expand Down
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
base
java
id("io.freefair.lombok") version "9.1.0"
id("io.sentry.jvm.gradle") version "5.12.2"
}

group = "net.swofty"
Expand Down Expand Up @@ -31,6 +32,7 @@ subprojects {

implementation("org.reflections:reflections:0.10.2")
implementation("org.json:json:20240303")
implementation("io.sentry:sentry-async-profiler:8.29.0")

compileOnly("org.projectlombok:lombok:1.18.42")

Expand Down
2 changes: 2 additions & 0 deletions commons/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ dependencies {
compileOnly("net.minestom:minestom:2025.12.20c-1.21.11") {
exclude(group = "org.jboss.shrinkwrap.resolver", module = "shrinkwrap-resolver-depchain")
}

implementation("org.spongepowered:configurate-yaml:4.2.0")
}
62 changes: 0 additions & 62 deletions commons/src/main/java/net/swofty/commons/Configuration.java

This file was deleted.

93 changes: 93 additions & 0 deletions commons/src/main/java/net/swofty/commons/SentryWriter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package net.swofty.commons;

import java.util.Collection;
import java.util.Collections;
import java.util.Map;

import io.sentry.Sentry;
import io.sentry.SentryLogLevel;
import org.tinylog.Level;
import org.tinylog.core.ConfigurationParser;
import org.tinylog.core.LogEntry;
import org.tinylog.core.LogEntryValue;
import org.tinylog.provider.InternalLogger;
import org.tinylog.writers.AbstractFormatPatternWriter;


public final class SentryWriter extends AbstractFormatPatternWriter {

private final Level errorLevel;

public SentryWriter() {
this(Collections.<String, String>emptyMap());
}

/**
* @param properties
* Configuration for writer
*/
public SentryWriter(final Map<String, String> properties) {
super(properties);

// Set the default level for stderr logging
Level levelStream = Level.WARN;

// Check stream property
String stream = getStringValue("stream");
if (stream != null) {
// Check whether we have the err@LEVEL syntax
String[] streams = stream.split("@", 2);
if (streams.length == 2) {
levelStream = ConfigurationParser.parse(streams[1], levelStream);
if (!streams[0].equals("err")) {
InternalLogger.log(Level.ERROR, "Stream with level must be \"err\", \"" + streams[0] + "\" is an invalid name");
}
stream = null;
}
}

if (stream == null) {
errorLevel = levelStream;
} else if ("err".equalsIgnoreCase(stream)) {
errorLevel = Level.TRACE;
} else if ("out".equalsIgnoreCase(stream)) {
errorLevel = Level.OFF;
} else {
InternalLogger.log(Level.ERROR, "Stream must be \"out\" or \"err\", \"" + stream + "\" is an invalid stream name");
errorLevel = levelStream;
}
}

@Override
public Collection<LogEntryValue> getRequiredLogEntryValues() {
Collection<LogEntryValue> logEntryValues = super.getRequiredLogEntryValues();
logEntryValues.add(LogEntryValue.LEVEL);
return logEntryValues;
}

@Override
public void write(final LogEntry logEntry) {
SentryLogLevel sentryLevel;
try {
sentryLevel = SentryLogLevel.valueOf(logEntry.getLevel().name());
} catch (IllegalArgumentException e) {
sentryLevel = SentryLogLevel.INFO;
}

Sentry.logger().log(sentryLevel, render(logEntry));
if (logEntry.getLevel().ordinal() < errorLevel.ordinal()) {
System.out.print(render(logEntry));
} else {
System.err.print(render(logEntry));
}
}

@Override
public void flush() {
}

@Override
public void close() {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package net.swofty.commons.config;

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.tinylog.Logger;

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

public class ConfigProvider {

@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 node = loader.load();
Settings existingSettings = node.get(Settings.class);
if (existingSettings == null) {
existingSettings = new Settings();
}
Settings config = existingSettings;
node.set(Settings.class, config);
loader.save(node);

settings(config);
} catch (IOException e) {
throw new RuntimeException("Failed to load configuration", e);
}
}
}
61 changes: 61 additions & 0 deletions commons/src/main/java/net/swofty/commons/config/Settings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package net.swofty.commons.config;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;

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

private String hostName = "0.0.0.0";
private long transferTimeout = 800;

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

@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";

private boolean requireAuth = 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("Settings related to configuration of Limbo server connections")
private LimboSettings limbo = new LimboSettings();

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

@Getter
@ConfigSerializable
@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 ViaVersion for supporting multiple Minecraft versions. This may cause issues of any kind")
private boolean viaVersion = false;

private String sentryDsn = "";
}

}
13 changes: 13 additions & 0 deletions configuration/config.docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
host-name: 0.0.0.0
transfer-timeout: 800
mongodb: mongodb://localhost
redis-url: redis://localhost:6379
velocity-secret: ixmSUgWOgvs7
require-auth: false
sandbox: false
spark: false
anticheat: false
redis-uri: redis://localhost:6379
limbo:
host-name: 127.0.0.1
port: 65535
13 changes: 13 additions & 0 deletions configuration/config.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
host-name: 0.0.0.0
transfer-timeout: 800
mongodb: mongodb://localhost
redis-url: redis://localhost:6379
velocity-secret: ixmSUgWOgvs7
require-auth: false
sandbox: false
spark: false
anticheat: false
redis-uri: redis://localhost:6379
limbo:
host-name: 127.0.0.1
port: 65535
10 changes: 7 additions & 3 deletions configuration/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
# Copy the Forwarding Secret
cp configuration_files/forwarding.secret ./forwarding.secret

# Update resources.json with the forwarding secret
# Copy the example config.yml if it doesn't exist
if [ ! -f ./config.yml ]; then
cp configuration_files/config.example.yml ./config.yml
fi

# Update config.yml with the forwarding secret (velocity-secret)
secret=$(cat ./forwarding.secret)
jq --arg secret "$secret" '.["velocity-secret"] = $secret' ./configuration/resources.json > ./configuration/resources.json.tmp
mv ./configuration/resources.json.tmp ./configuration/resources.json
sed -i "s/velocity-secret: .*/velocity-secret: '$secret'/" ./config.yml

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