diff --git a/.gitignore b/.gitignore index cbc223fdc..05ed755a0 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/DockerFiles/Dockerfile.game_server b/DockerFiles/Dockerfile.game_server index 5ad91fdc6..471652084 100644 --- a/DockerFiles/Dockerfile.game_server +++ b/DockerFiles/Dockerfile.game_server @@ -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 diff --git a/DockerFiles/Dockerfile.proxy b/DockerFiles/Dockerfile.proxy index 3e901f0b5..7f74643d1 100644 --- a/DockerFiles/Dockerfile.proxy +++ b/DockerFiles/Dockerfile.proxy @@ -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 diff --git a/build.gradle.kts b/build.gradle.kts index b92fabaa4..96201a056 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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" @@ -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") diff --git a/commons/build.gradle.kts b/commons/build.gradle.kts index 1080f82f6..0097897dc 100644 --- a/commons/build.gradle.kts +++ b/commons/build.gradle.kts @@ -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") } \ No newline at end of file diff --git a/commons/src/main/java/net/swofty/commons/Configuration.java b/commons/src/main/java/net/swofty/commons/Configuration.java deleted file mode 100644 index 540f58441..000000000 --- a/commons/src/main/java/net/swofty/commons/Configuration.java +++ /dev/null @@ -1,62 +0,0 @@ -package net.swofty.commons; - -import org.json.JSONObject; -import org.tinylog.Logger; - -import java.io.File; -import java.nio.file.Files; -import java.nio.file.Paths; - -public class Configuration { - - public static String get(String key) { - File file = new File("./configuration/resources.json"); - if (!file.exists()) { - System.out.println("File does not exist, returning null for key " + key + " in Configuration.get()"); - return "null"; - } - - try { - String s = new String(Files.readAllBytes(Paths.get(file.toURI()))); - JSONObject object = new JSONObject(s); - return object.get(key).toString(); - } catch (Exception ex) { - Logger.error(ex, "Failed to read configuration key: {}", key); - } - - return "null"; - } - - public static T getOrDefault(String key, T def) { - File file = new File("./configuration/resources.json"); - if (!file.exists()) { - return def; - } - - try { - String s = new String(Files.readAllBytes(Paths.get(file.toURI()))); - JSONObject object = new JSONObject(s); - return (T) object.get(key); - } catch (Exception ex) {} - - return def; - } - - public static JSONObject getObject(String key) { - File file = new File("./configuration/resources.json"); - if (!file.exists()) { - return null; - } - - try { - String s = new String(Files.readAllBytes(Paths.get(file.toURI()))); - JSONObject object = new JSONObject(s); - return (JSONObject) object.get(key); - } catch (Exception ex) { - Logger.error(ex, "Failed to read configuration object for key: {}", key); - } - - return null; - } - -} \ No newline at end of file diff --git a/commons/src/main/java/net/swofty/commons/SentryWriter.java b/commons/src/main/java/net/swofty/commons/SentryWriter.java new file mode 100644 index 000000000..7a3e07459 --- /dev/null +++ b/commons/src/main/java/net/swofty/commons/SentryWriter.java @@ -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.emptyMap()); + } + + /** + * @param properties + * Configuration for writer + */ + public SentryWriter(final Map 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 getRequiredLogEntryValues() { + Collection 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() { + } + +} \ No newline at end of file diff --git a/commons/src/main/java/net/swofty/commons/config/ConfigProvider.java b/commons/src/main/java/net/swofty/commons/config/ConfigProvider.java new file mode 100644 index 000000000..fca54b42f --- /dev/null +++ b/commons/src/main/java/net/swofty/commons/config/ConfigProvider.java @@ -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); + } + } +} \ No newline at end of file diff --git a/commons/src/main/java/net/swofty/commons/config/Settings.java b/commons/src/main/java/net/swofty/commons/config/Settings.java new file mode 100644 index 000000000..978e222a1 --- /dev/null +++ b/commons/src/main/java/net/swofty/commons/config/Settings.java @@ -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 = ""; + } + +} diff --git a/configuration/config.docker.yml b/configuration/config.docker.yml new file mode 100644 index 000000000..3342a30bd --- /dev/null +++ b/configuration/config.docker.yml @@ -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 diff --git a/configuration/config.example.yml b/configuration/config.example.yml new file mode 100644 index 000000000..3342a30bd --- /dev/null +++ b/configuration/config.example.yml @@ -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 diff --git a/configuration/entrypoint.sh b/configuration/entrypoint.sh index 1afb4e2fe..53eaa4a50 100644 --- a/configuration/entrypoint.sh +++ b/configuration/entrypoint.sh @@ -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 diff --git a/configuration/resources.json b/configuration/resources.json deleted file mode 100644 index 6221b347a..000000000 --- a/configuration/resources.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "mongodb": "mongodb://localhost", - "redis-uri": "redis://localhost:6379", - "velocity-secret": "ixmSUgWOgvs7", - "limbo-host-name": "127.0.0.1", - "limbo-port": "65535", - "pterodactyl-mode": false, - "spark": false, - "require-authentication": false, - "cross-version-support": false, - "host-name": "0.0.0.0", - "transfer-timeout": "800", - "sandbox-mode": true, - "anticheat": false -} \ No newline at end of file diff --git a/configuration/resources.json.docker b/configuration/resources.json.docker deleted file mode 100644 index 8d17b0c76..000000000 --- a/configuration/resources.json.docker +++ /dev/null @@ -1,15 +0,0 @@ -{ - "mongodb": "mongodb://hypixel_mongo:27017", - "redis-uri": "redis://hypixel_redis:6379", - "velocity-secret": "ixmSUgWOgvs7", - "limbo-host-name": "nanolimbo", - "limbo-port": "65535", - "pterodactyl-mode": false, - "spark": false, - "require-authentication": false, - "cross-version-support": false, - "host-name": "0.0.0.0", - "transfer-timeout": "800", - "sandbox-mode": true, - "anticheat": true -} diff --git a/loader/src/main/java/net/swofty/loader/Hypixel.java b/loader/src/main/java/net/swofty/loader/Hypixel.java index d50ae3762..334ad8ec5 100644 --- a/loader/src/main/java/net/swofty/loader/Hypixel.java +++ b/loader/src/main/java/net/swofty/loader/Hypixel.java @@ -1,5 +1,7 @@ package net.swofty.loader; +import io.sentry.ProfileLifecycle; +import io.sentry.Sentry; import lombok.Getter; import lombok.Setter; import lombok.SneakyThrows; @@ -13,9 +15,9 @@ import net.swofty.anticheat.loader.SwoftyAnticheat; import net.swofty.anticheat.loader.SwoftyValues; import net.swofty.anticheat.loader.minestom.MinestomLoader; -import net.swofty.commons.Configuration; import net.swofty.commons.ServerType; import net.swofty.commons.TestFlow; +import net.swofty.commons.config.ConfigProvider; import net.swofty.commons.protocol.ProtocolObject; import net.swofty.commons.proxy.ToProxyChannels; import net.swofty.proxyapi.ProxyAPI; @@ -48,10 +50,10 @@ public class Hypixel { @Setter private static UUID serverUUID; - private static final boolean ENABLE_SPARK = Configuration.getOrDefault("spark", false); + private static final boolean ENABLE_SPARK = ConfigProvider.settings().getIntegrations().isSpark(); @SneakyThrows - public static void main(String[] args) { + static void main(String[] args) { if (args.length == 0 || !ServerType.isServerType(args[0])) { Logger.error("Please specify a server type."); Arrays.stream(ServerType.values()).forEach(serverType -> Logger.error(serverType.name())); @@ -59,6 +61,17 @@ public static void main(String[] args) { return; } + if (ConfigProvider.settings().getIntegrations().getSentryDsn().isBlank()) { + Sentry.init(options -> { + options.setDsn(ConfigProvider.settings().getIntegrations().getSentryDsn()); + options.setSendDefaultPii(true); + options.setTracesSampleRate(1.0); + options.setProfileSessionSampleRate(1.0); + options.setProfileLifecycle(ProfileLifecycle.TRACE); + options.getLogs().setEnabled(true); + }); + } + ServerType serverType = ServerType.valueOf(args[0].toUpperCase()); long startTime = System.currentTimeMillis(); @@ -84,17 +97,13 @@ public static void main(String[] args) { Logger.info("Server index: " + testFlowIndex + " of " + testFlowTotal); } - /** - * Initialize the server - */ - MinecraftServer minecraftServer = MinecraftServer.init( - new Auth.Velocity(Configuration.get("velocity-secret")) + // Initialize Minecraft server + MinecraftServer minecraftServer = MinecraftServer.init( + new Auth.Velocity(ConfigProvider.settings().getVelocitySecret()) ); serverUUID = UUID.randomUUID(); - /** - * Initialize GenericLoader - */ + // Initialize GenericLoader Reflections reflections = new Reflections("net.swofty.type"); Set> subTypes = reflections.getSubTypesOf(HypixelTypeLoader.class); if (subTypes.isEmpty()) { @@ -116,24 +125,16 @@ public static void main(String[] args) { new HypixelGenericLoader(typeLoader).initialize(minecraftServer); - /** - * Initialize TypeLoader - */ + // Initialize TypeLoader if (typeLoader instanceof SkyBlockTypeLoader) { new SkyBlockGenericLoader(typeLoader).initialize(minecraftServer); } - /** - * Initialize the server - */ + // Initialize the server typeLoader.onInitialize(minecraftServer); - /** - * Initialize Proxy support - */ - Logger.info("Initializing proxy support..."); - - ProxyAPI proxyAPI = new ProxyAPI(Configuration.get("redis-uri"), serverUUID); + // Initialize proxy support + ProxyAPI proxyAPI = new ProxyAPI(ConfigProvider.settings().getRedisUri(), serverUUID); SkyBlockGenericLoader.loopThroughPackage("net.swofty.type.generic.redis", ProxyToClient.class) .forEach(proxyAPI::registerFromProxyHandler); SkyBlockGenericLoader.loopThroughPackage("net.swofty.type.generic.redis.service", ServiceToClient.class) @@ -154,16 +155,12 @@ public static void main(String[] args) { protocolObjects.forEach(ServerOutboundMessage::registerFromProtocolObject); proxyAPI.start(); - /** - * Start spark if enabled - */ + // Start spark if enabled if (ENABLE_SPARK) { Spark.enable(Files.createTempDirectory("spark")); } - /** - * Ensure all services are running - */ + // Ensure all services are running typeLoader.getRequiredServices().forEach(serviceType -> { new ProxyService(serviceType).isOnline().thenAccept(online -> { if (!online) { @@ -173,13 +170,11 @@ public static void main(String[] args) { }); typeLoader.afterInitialize(minecraftServer); - /** - * Start the server - */ + // Start the server MinecraftServer.setBrandName("Hypixel"); CompletableFuture startServer = new CompletableFuture<>(); startServer.whenComplete((port, throwable) -> { - minecraftServer.start(Configuration.get("host-name"), port); + minecraftServer.start(ConfigProvider.settings().getHostName(), port); long endTime = System.currentTimeMillis(); Logger.info("Started server on port " + port + " in " + (endTime - startTime) + "ms"); @@ -212,10 +207,8 @@ ToProxyChannels.REQUEST_SERVERS_NAME, new JSONObject(), }); checkProxyConnected(MinecraftServer.getSchedulerManager()); - /** - * Initialize the anticheat - */ - if (Configuration.getOrDefault("anticheat", true)) { + // Initialize anticheat + if (ConfigProvider.settings().getIntegrations().isAnticheat()) { Thread.startVirtualThread(() -> { Logger.info("Initializing anticheat..."); diff --git a/loader/src/main/resources/META-INF/services/org.tinylog.writers.Writer b/loader/src/main/resources/META-INF/services/org.tinylog.writers.Writer new file mode 100644 index 000000000..53b1b7df5 --- /dev/null +++ b/loader/src/main/resources/META-INF/services/org.tinylog.writers.Writer @@ -0,0 +1 @@ +net.swofty.commons.SentryWriter \ No newline at end of file diff --git a/loader/src/main/resources/tinylog.properties b/loader/src/main/resources/tinylog.properties index 817d3fe3e..5eda4693f 100644 --- a/loader/src/main/resources/tinylog.properties +++ b/loader/src/main/resources/tinylog.properties @@ -1,5 +1,5 @@ # Set the global log level -writer = console +writer = sentry writer.level = info writer.format = {date:yyyy-MM-dd HH:mm:ss} [{thread}] {class}.{method}() {level}: {message} diff --git a/pvp/src/main/java/net/swofty/pvp/utils/EntityUtil.java b/pvp/src/main/java/net/swofty/pvp/utils/EntityUtil.java index 55bba98de..fccaebb5b 100644 --- a/pvp/src/main/java/net/swofty/pvp/utils/EntityUtil.java +++ b/pvp/src/main/java/net/swofty/pvp/utils/EntityUtil.java @@ -1,5 +1,6 @@ package net.swofty.pvp.utils; +import io.sentry.Sentry; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.HoverEvent; import net.minestom.server.component.DataComponents; @@ -46,6 +47,7 @@ public static void setLastDamage(LivingEntity livingEntity, Damage lastDamage) { field.set(livingEntity, lastDamage); } catch (NoSuchFieldException | IllegalAccessException e) { e.printStackTrace(); + Sentry.captureException(e); } } } diff --git a/script/install.py b/script/install.py index 23fb6e18d..4b7b3cbc5 100644 --- a/script/install.py +++ b/script/install.py @@ -22,16 +22,17 @@ import json from rich.markdown import Markdown from rich.syntax import Syntax +import yaml # this is from pyyaml console = Console() SPLASH_ART = """[bold cyan] - __ __ _ __ _____ __ ____ __ __ + __ __ _ __ _____ __ ____ __ __ / / / /_ ______ (_) _____ / / / ___// /____ _/ / / / /__ ____/ /__ / /_/ / / / / __ \/ / |/_/ _ \/ / \__ \/ //_/ / / / / / / _ \/ __ / _ \\ / __ / /_/ / /_/ / /> { + Sentry.captureException(throwable); throwable.printStackTrace(); player.sendMessage("Β§cFailed to load maps: " + throwable.getMessage()); player.closeInventory(); diff --git a/type.generic/src/main/java/net/swofty/type/generic/HypixelGenericLoader.java b/type.generic/src/main/java/net/swofty/type/generic/HypixelGenericLoader.java index cf51cedf9..ecaf22577 100644 --- a/type.generic/src/main/java/net/swofty/type/generic/HypixelGenericLoader.java +++ b/type.generic/src/main/java/net/swofty/type/generic/HypixelGenericLoader.java @@ -18,9 +18,9 @@ import net.minestom.server.monitoring.TickMonitor; import net.minestom.server.timer.TaskSchedule; import net.minestom.server.utils.time.TimeUnit; -import net.swofty.commons.Configuration; import net.swofty.commons.CustomWorlds; import net.swofty.commons.ServerType; +import net.swofty.commons.config.ConfigProvider; import net.swofty.type.generic.block.PlayerHeadBlockHandler; import net.swofty.type.generic.block.SignBlockHandler; import net.swofty.type.generic.command.HypixelCommand; @@ -178,7 +178,7 @@ public void initialize(MinecraftServer server) { /** * Register databases */ - ConnectionString cs = new ConnectionString(Configuration.get("mongodb")); + ConnectionString cs = new ConnectionString(ConfigProvider.settings().getMongodb()); MongoClientSettings settings = MongoClientSettings.builder().applyConnectionString(cs).build(); MongoClient mongoClient = MongoClients.create(settings); @@ -189,7 +189,7 @@ public void initialize(MinecraftServer server) { BedWarsStatsDatabase.connect(mongoClient); // Initialize leaderboard service (uses Redis for O(log N) leaderboard operations) - LeaderboardService.connect(Configuration.get("redis-uri")); + LeaderboardService.connect(ConfigProvider.settings().getRedisUri()); // Load achievement and quest registries from YAML configuration AchievementRegistry.loadFromConfiguration(); diff --git a/type.generic/src/main/java/net/swofty/type/generic/command/commands/ThrowExceptionCommand.java b/type.generic/src/main/java/net/swofty/type/generic/command/commands/ThrowExceptionCommand.java new file mode 100644 index 000000000..41d728789 --- /dev/null +++ b/type.generic/src/main/java/net/swofty/type/generic/command/commands/ThrowExceptionCommand.java @@ -0,0 +1,19 @@ +package net.swofty.type.generic.command.commands; + +import net.swofty.type.generic.command.CommandParameters; +import net.swofty.type.generic.command.HypixelCommand; +import net.swofty.type.generic.user.categories.Rank; + +@CommandParameters(permission = Rank.STAFF, description = "Throws an exception for testing purposes", usage = "/throwexception", aliases = "throwexception", allowsConsole = true) +public class ThrowExceptionCommand extends HypixelCommand { + + @Override + public void registerUsage(MinestomCommand command) { + command.addSyntax((sender, context) -> { + if (!permissionCheck(sender)) return; + + throw new RuntimeException("This is a test exception thrown with /throwexception command."); + }); + } + +} diff --git a/type.generic/src/main/java/net/swofty/type/generic/data/HypixelDataHandler.java b/type.generic/src/main/java/net/swofty/type/generic/data/HypixelDataHandler.java index 7b5f472d2..d5ba0d2ec 100644 --- a/type.generic/src/main/java/net/swofty/type/generic/data/HypixelDataHandler.java +++ b/type.generic/src/main/java/net/swofty/type/generic/data/HypixelDataHandler.java @@ -1,5 +1,6 @@ package net.swofty.type.generic.data; +import io.sentry.Sentry; import lombok.Getter; import net.kyori.adventure.text.Component; import net.minestom.server.MinecraftServer; @@ -59,6 +60,7 @@ public HypixelDataHandler fromDocument(Document document) { } catch (Exception e) { this.datapoints.put(key, data.getDefaultDatapoint().deepClone().setUser(this).setData(data)); Logger.error(e, "Issue with datapoint {} for user {} - defaulting to default value", key, this.uuid); + Sentry.captureException(e); } } return this; diff --git a/type.generic/src/main/java/net/swofty/type/generic/data/handlers/BedWarsDataHandler.java b/type.generic/src/main/java/net/swofty/type/generic/data/handlers/BedWarsDataHandler.java index 2a9bb54d6..e14be2ee1 100644 --- a/type.generic/src/main/java/net/swofty/type/generic/data/handlers/BedWarsDataHandler.java +++ b/type.generic/src/main/java/net/swofty/type/generic/data/handlers/BedWarsDataHandler.java @@ -1,5 +1,6 @@ package net.swofty.type.generic.data.handlers; +import io.sentry.Sentry; import lombok.Getter; import net.swofty.type.generic.data.DataHandler; import net.swofty.type.generic.data.Datapoint; @@ -113,6 +114,7 @@ public BedWarsDataHandler fromDocument(Document document) { } catch (Exception e) { this.datapoints.put(key, data.getDefaultDatapoint().deepClone().setUser(this).setData(data)); Logger.info("Issue with datapoint " + key + " for user " + this.uuid + " - defaulting"); + Sentry.captureException(e); e.printStackTrace(); } } @@ -182,6 +184,7 @@ public static BedWarsDataHandler initUserWithDefaultData(UUID uuid) { } catch (Exception e) { Logger.error("Issue with datapoint " + data.getKey() + " for user " + uuid + " - fix"); e.printStackTrace(); + Sentry.captureException(e); } } return handler; diff --git a/type.generic/src/main/java/net/swofty/type/generic/data/handlers/MurderMysteryDataHandler.java b/type.generic/src/main/java/net/swofty/type/generic/data/handlers/MurderMysteryDataHandler.java index 17980df9a..206d1eca2 100644 --- a/type.generic/src/main/java/net/swofty/type/generic/data/handlers/MurderMysteryDataHandler.java +++ b/type.generic/src/main/java/net/swofty/type/generic/data/handlers/MurderMysteryDataHandler.java @@ -1,5 +1,6 @@ package net.swofty.type.generic.data.handlers; +import io.sentry.Sentry; import lombok.Getter; import net.swofty.type.generic.data.DataHandler; import net.swofty.type.generic.data.Datapoint; @@ -120,6 +121,7 @@ public Document toDocument() { try { document.put(data.getKey(), getDatapoint(data.getKey()).getSerializedValue()); } catch (JacksonException e) { + Sentry.captureException(e); e.printStackTrace(); } } diff --git a/type.generic/src/main/java/net/swofty/type/generic/data/handlers/SkywarsDataHandler.java b/type.generic/src/main/java/net/swofty/type/generic/data/handlers/SkywarsDataHandler.java index 3927aca64..592707ee8 100644 --- a/type.generic/src/main/java/net/swofty/type/generic/data/handlers/SkywarsDataHandler.java +++ b/type.generic/src/main/java/net/swofty/type/generic/data/handlers/SkywarsDataHandler.java @@ -1,5 +1,6 @@ package net.swofty.type.generic.data.handlers; +import io.sentry.Sentry; import lombok.Getter; import net.swofty.type.generic.data.DataHandler; import net.swofty.type.generic.data.Datapoint; @@ -109,6 +110,7 @@ public SkywarsDataHandler fromDocument(Document document) { this.datapoints.put(key, data.getDefaultDatapoint().deepClone().setUser(this).setData(data)); Logger.info("Issue with datapoint " + key + " for user " + this.uuid + " - defaulting"); e.printStackTrace(); + Sentry.captureException(e); } } return this; diff --git a/type.prototypelobby/src/main/java/net/swofty/type/prototypelobby/TypePrototypeLobbyLoader.java b/type.prototypelobby/src/main/java/net/swofty/type/prototypelobby/TypePrototypeLobbyLoader.java index ca21813d9..7733fbb3e 100644 --- a/type.prototypelobby/src/main/java/net/swofty/type/prototypelobby/TypePrototypeLobbyLoader.java +++ b/type.prototypelobby/src/main/java/net/swofty/type/prototypelobby/TypePrototypeLobbyLoader.java @@ -1,5 +1,6 @@ package net.swofty.type.prototypelobby; +import io.sentry.Sentry; import net.minestom.server.MinecraftServer; import net.minestom.server.coordinate.Pos; import net.swofty.commons.CustomWorlds; diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/SkyBlockGenericLoader.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/SkyBlockGenericLoader.java index 077f3dcbd..48ec42f11 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/SkyBlockGenericLoader.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/SkyBlockGenericLoader.java @@ -11,7 +11,6 @@ import net.minestom.server.MinecraftServer; import net.minestom.server.coordinate.CoordConversion; import net.minestom.server.coordinate.Pos; -import net.minestom.server.event.Event; import net.minestom.server.event.server.ServerTickMonitorEvent; import net.minestom.server.instance.Chunk; import net.minestom.server.monitoring.BenchmarkManager; @@ -22,6 +21,7 @@ import net.minestom.server.world.DimensionType; import net.minestom.server.world.biome.Biome; import net.swofty.commons.*; +import net.swofty.commons.config.ConfigProvider; import net.swofty.commons.skyblock.item.ItemType; import net.swofty.commons.skyblock.item.attribute.ItemAttribute; import net.swofty.commons.skyblock.item.reforge.ReforgeLoader; @@ -29,7 +29,6 @@ import net.swofty.type.generic.HypixelGenericLoader; import net.swofty.type.generic.HypixelTypeLoader; import net.swofty.type.generic.data.mongodb.*; -import net.swofty.type.generic.event.HypixelEvent; import net.swofty.type.generic.packet.HypixelPacketClientListener; import net.swofty.type.generic.packet.HypixelPacketServerListener; import net.swofty.type.skyblockgeneric.abiphone.AbiphoneNPC; @@ -73,7 +72,6 @@ import net.swofty.type.skyblockgeneric.noteblock.SkyBlockSongsHandler; import net.swofty.type.skyblockgeneric.redis.RedisAuthenticate; import net.swofty.type.generic.redis.RedisOriginServer; -import net.swofty.type.skyblockgeneric.region.SkyBlockBiomeConfiguration; import net.swofty.type.skyblockgeneric.region.SkyBlockRegenConfiguration; import net.swofty.type.skyblockgeneric.region.SkyBlockRegion; import net.swofty.type.skyblockgeneric.server.attribute.SkyBlockServerAttributes; @@ -96,7 +94,6 @@ import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.time.Duration; import java.util.*; import java.util.concurrent.CompletableFuture; @@ -121,7 +118,7 @@ public void initialize(MinecraftServer server) { /** * Register SkyBlock databases */ - ConnectionString cs = new ConnectionString(Configuration.get("mongodb")); + ConnectionString cs = new ConnectionString(ConfigProvider.settings().getMongodb()); MongoClientSettings settings = MongoClientSettings.builder().applyConnectionString(cs).build(); MongoClient mongoClient = MongoClients.create(settings); diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/RemoveItemLoreCommand.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/RemoveItemLoreCommand.java index 8e7aa3df5..4c03dc015 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/RemoveItemLoreCommand.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/RemoveItemLoreCommand.java @@ -1,7 +1,7 @@ package net.swofty.type.skyblockgeneric.commands; import net.minestom.server.command.builder.arguments.number.ArgumentInteger; -import net.swofty.commons.Configuration; +import net.swofty.commons.config.ConfigProvider; import net.swofty.commons.skyblock.item.ItemType; import net.swofty.type.generic.command.CommandParameters; import net.swofty.type.generic.command.HypixelCommand; @@ -22,7 +22,7 @@ public void registerUsage(MinestomCommand command) { command.addSyntax((sender, context) -> { if (!permissionCheck(sender)) return; - if (Configuration.get("sandbox-mode").equals("false")) { + if (!ConfigProvider.settings().isSandbox()) { sender.sendMessage("Β§cThis command is disabled on this server."); return; } diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SandboxCommand.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SandboxCommand.java index 317980ca4..6d66203be 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SandboxCommand.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SandboxCommand.java @@ -1,6 +1,6 @@ package net.swofty.type.skyblockgeneric.commands; -import net.swofty.commons.Configuration; +import net.swofty.commons.config.ConfigProvider; import net.swofty.commons.skyblock.item.ItemType; import net.swofty.type.generic.command.CommandParameters; import net.swofty.type.generic.command.HypixelCommand; @@ -17,7 +17,7 @@ public class SandboxCommand extends HypixelCommand { public void registerUsage(MinestomCommand command) { command.addSyntax((sender, context) -> { if (!permissionCheck(sender)) return; - if (Configuration.get("sandbox-mode").equals("false")) { + if (!ConfigProvider.settings().isSandbox()) { sender.sendMessage("Β§cThis command is disabled on this server."); return; } diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SetItemLoreCommand.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SetItemLoreCommand.java index 08e3c3349..457071c8c 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SetItemLoreCommand.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SetItemLoreCommand.java @@ -2,7 +2,7 @@ import net.minestom.server.command.builder.arguments.ArgumentStringArray; import net.minestom.server.command.builder.arguments.number.ArgumentInteger; -import net.swofty.commons.Configuration; +import net.swofty.commons.config.ConfigProvider; import net.swofty.commons.skyblock.item.ItemType; import net.swofty.type.generic.command.CommandParameters; import net.swofty.type.generic.command.HypixelCommand; @@ -24,7 +24,7 @@ public void registerUsage(MinestomCommand command) { command.addSyntax((sender, context) -> { if (!permissionCheck(sender)) return; - if (Configuration.get("sandbox-mode").equals("false")) { + if (!ConfigProvider.settings().isSandbox()) { sender.sendMessage("Β§cThis command is disabled on this server."); return; } diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SetItemNameCommand.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SetItemNameCommand.java index 64e1bed95..c045c33ba 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SetItemNameCommand.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SetItemNameCommand.java @@ -1,7 +1,7 @@ package net.swofty.type.skyblockgeneric.commands; import net.minestom.server.command.builder.arguments.ArgumentString; -import net.swofty.commons.Configuration; +import net.swofty.commons.config.ConfigProvider; import net.swofty.commons.skyblock.item.ItemType; import net.swofty.type.generic.command.CommandParameters; import net.swofty.type.generic.command.HypixelCommand; @@ -22,7 +22,7 @@ public void registerUsage(MinestomCommand command) { command.addSyntax((sender, context) -> { if (!permissionCheck(sender)) return; - if (Configuration.get("sandbox-mode").equals("false")) { + if (!ConfigProvider.settings().isSandbox()) { sender.sendMessage("Β§cThis command is disabled on this server."); return; } diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SetItemStatisticCommand.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SetItemStatisticCommand.java index 3c0f1397b..69f512e82 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SetItemStatisticCommand.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SetItemStatisticCommand.java @@ -2,7 +2,7 @@ import net.minestom.server.command.builder.arguments.ArgumentEnum; import net.minestom.server.command.builder.arguments.number.ArgumentDouble; -import net.swofty.commons.Configuration; +import net.swofty.commons.config.ConfigProvider; import net.swofty.commons.skyblock.item.ItemType; import net.swofty.commons.skyblock.item.attribute.attributes.ItemAttributeSandboxItem; import net.swofty.commons.skyblock.statistics.ItemStatistic; @@ -28,7 +28,7 @@ public void registerUsage(MinestomCommand command) { command.addSyntax((sender, context) -> { if (!permissionCheck(sender)) return; - if (Configuration.get("sandbox-mode").equals("false")) { + if (!ConfigProvider.settings().isSandbox()) { sender.sendMessage("Β§cThis command is disabled on this server."); return; } diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SetItemTypeCommand.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SetItemTypeCommand.java index 84efdd8e5..5be491ddc 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SetItemTypeCommand.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/SetItemTypeCommand.java @@ -1,7 +1,7 @@ package net.swofty.type.skyblockgeneric.commands; import net.minestom.server.command.builder.arguments.ArgumentEnum; -import net.swofty.commons.Configuration; +import net.swofty.commons.config.ConfigProvider; import net.swofty.commons.skyblock.item.ItemType; import net.swofty.type.generic.command.CommandParameters; import net.swofty.type.generic.command.HypixelCommand; @@ -22,7 +22,7 @@ public void registerUsage(MinestomCommand command) { command.addSyntax((sender, context) -> { if (!permissionCheck(sender)) return; - if (Configuration.get("sandbox-mode").equals("false")) { + if (!ConfigProvider.settings().isSandbox()) { sender.sendMessage("Β§cThis command is disabled on this server."); return; } diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/ToggleLoreLinesCommand.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/ToggleLoreLinesCommand.java index 9e476be7b..a7afa1dfd 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/ToggleLoreLinesCommand.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/commands/ToggleLoreLinesCommand.java @@ -1,6 +1,6 @@ package net.swofty.type.skyblockgeneric.commands; -import net.swofty.commons.Configuration; +import net.swofty.commons.config.ConfigProvider; import net.swofty.commons.skyblock.item.ItemType; import net.swofty.type.generic.command.CommandParameters; import net.swofty.type.generic.command.HypixelCommand; @@ -19,7 +19,7 @@ public class ToggleLoreLinesCommand extends HypixelCommand { public void registerUsage(MinestomCommand command) { command.addSyntax((sender, context) -> { if (!permissionCheck(sender)) return; - if (Configuration.get("sandbox-mode").equals("false")) { + if (!ConfigProvider.settings().isSandbox()) { sender.sendMessage("Β§cThis command is disabled on this server."); return; } diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/ItemConfigParser.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/ItemConfigParser.java index b54371643..dae84b3ac 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/ItemConfigParser.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/ItemConfigParser.java @@ -1,5 +1,6 @@ package net.swofty.type.skyblockgeneric.item; +import io.sentry.Sentry; import net.minestom.server.color.Color; import net.minestom.server.item.ItemAnimation; import net.minestom.server.item.Material; @@ -75,6 +76,7 @@ public static ConfigurableSkyBlockItem parseItem(Map config) { } catch (Exception e) { Logger.error("Unexpected error parsing item: {}", e.getMessage()); e.printStackTrace(); + Sentry.captureException(e); return null; } } diff --git a/velocity.extension/src/main/java/net/swofty/velocity/SkyBlockVelocity.java b/velocity.extension/src/main/java/net/swofty/velocity/SkyBlockVelocity.java index ba51b9e98..eb94a60f4 100644 --- a/velocity.extension/src/main/java/net/swofty/velocity/SkyBlockVelocity.java +++ b/velocity.extension/src/main/java/net/swofty/velocity/SkyBlockVelocity.java @@ -35,8 +35,9 @@ import io.netty.channel.ChannelPipeline; import lombok.Getter; import net.kyori.adventure.text.Component; -import net.swofty.commons.Configuration; import net.swofty.commons.ServerType; +import net.swofty.commons.config.ConfigProvider; +import net.swofty.commons.config.Settings; import net.swofty.commons.proxy.FromProxyChannels; import net.swofty.redisapi.api.RedisAPI; import net.swofty.velocity.command.ProtocolVersionCommand; @@ -99,25 +100,22 @@ public SkyBlockVelocity(ProxyServer tempServer, Logger tempLogger, @DataDirector plugin = this; server = tempServer; - limboServer = server.registerServer(new ServerInfo("limbo", new InetSocketAddress(Configuration.get("limbo-host-name"), - Integer.parseInt(Configuration.get("limbo-port"))))); + Settings.LimboSettings limbo = ConfigProvider.settings().getLimbo(); + limboServer = server.registerServer(new ServerInfo("limbo", new InetSocketAddress(limbo.getHostName(), limbo.getPort()))); } @Subscribe public void onProxyInitialization(ProxyInitializeEvent event) { server = proxy; - shouldAuthenticate = Configuration.getOrDefault("require-authentication", false); - supportCrossVersion = Configuration.getOrDefault("cross-version-support", false); + shouldAuthenticate = ConfigProvider.settings().isRequireAuth(); + supportCrossVersion = ConfigProvider.settings().getIntegrations().isViaVersion(); - /** - * initialize cross version support - */ + // Initialize ViaVersion for cross-version support if (supportCrossVersion) { ViaLoader.init(null, new SkyBlockVLLoader(), new SkyBlockViaInjector(), null, ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new); } - /** - * Register packets - */ + + // Register packets server.getEventManager().register(this, PostLoginEvent.class, (AwaitingEventExecutor) postLoginEvent -> EventTask.withContinuation(continuation -> { injectPlayer(postLoginEvent.getPlayer()); @@ -185,17 +183,13 @@ public void onProxyInitialization(ProxyInitializeEvent event) { commandManager.register(protocolVersionMeta, new ProtocolVersionCommand()); - /** - * Handle database - */ - new ProfilesDatabase("_placeHolder").connect(Configuration.get("mongodb")); - UserDatabase.connect(Configuration.get("mongodb")); - CoopDatabase.connect(Configuration.get("mongodb")); + // Handle database + new ProfilesDatabase("_placeHolder").connect(ConfigProvider.settings().getMongodb()); + UserDatabase.connect(ConfigProvider.settings().getMongodb()); + CoopDatabase.connect(ConfigProvider.settings().getMongodb()); - /** - * Setup Redis - */ - RedisAPI.generateInstance(Configuration.get("redis-uri")); + // Setup Redis + RedisAPI.generateInstance(ConfigProvider.settings().getRedisUri()); RedisAPI.getInstance().setFilterID("proxy"); loopThroughPackage("net.swofty.velocity.redis.listeners", RedisListener.class) .forEach(listener -> { diff --git a/velocity.extension/src/main/java/net/swofty/velocity/gamemanager/GameManager.java b/velocity.extension/src/main/java/net/swofty/velocity/gamemanager/GameManager.java index a248caf2e..fdc209f91 100644 --- a/velocity.extension/src/main/java/net/swofty/velocity/gamemanager/GameManager.java +++ b/velocity.extension/src/main/java/net/swofty/velocity/gamemanager/GameManager.java @@ -4,8 +4,8 @@ import com.velocitypowered.api.proxy.server.RegisteredServer; import com.velocitypowered.api.proxy.server.ServerInfo; import lombok.Getter; -import net.swofty.commons.Configuration; import net.swofty.commons.ServerType; +import net.swofty.commons.config.ConfigProvider; import net.swofty.commons.proxy.FromProxyChannels; import net.swofty.velocity.SkyBlockVelocity; import net.swofty.velocity.redis.RedisMessage; @@ -25,7 +25,7 @@ public class GameManager { public static GameServer addServer(ServerType type, UUID serverID, String host, int port, int maxPlayers) { port = port == -1 ? getNextAvailablePort() : port; // if port is -1 then get next available port - host = (host == null || host.isEmpty()) ? Configuration.get("host-name") : host; // if host is null then get from config + host = (host == null || host.isEmpty()) ? ConfigProvider.settings().getHostName() : host; // if host is null then get from config RegisteredServer registeredServer = SkyBlockVelocity.getServer().registerServer( new ServerInfo(serverID.toString(), new InetSocketAddress(host, port)) ); diff --git a/velocity.extension/src/main/java/net/swofty/velocity/gamemanager/TransferHandler.java b/velocity.extension/src/main/java/net/swofty/velocity/gamemanager/TransferHandler.java index df0104ae0..fcbdec429 100644 --- a/velocity.extension/src/main/java/net/swofty/velocity/gamemanager/TransferHandler.java +++ b/velocity.extension/src/main/java/net/swofty/velocity/gamemanager/TransferHandler.java @@ -3,8 +3,8 @@ import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.server.RegisteredServer; import net.kyori.adventure.text.Component; -import net.swofty.commons.Configuration; import net.swofty.commons.ServerType; +import net.swofty.commons.config.ConfigProvider; import net.swofty.commons.proxy.FromProxyChannels; import net.swofty.velocity.SkyBlockVelocity; import net.swofty.velocity.redis.RedisMessage; @@ -126,7 +126,7 @@ public void previousServerIsFinished() { playersGoalServerType.remove(player); try { - Thread.sleep(Long.parseLong(Configuration.get("transfer-timeout"))); + Thread.sleep(ConfigProvider.settings().getTransferTimeout()); } catch (InterruptedException e) { throw new RuntimeException(e); } diff --git a/velocity.extension/src/main/java/net/swofty/velocity/redis/listeners/ListenerPlayerHandler.java b/velocity.extension/src/main/java/net/swofty/velocity/redis/listeners/ListenerPlayerHandler.java index 7149e2168..7aeb7efe5 100644 --- a/velocity.extension/src/main/java/net/swofty/velocity/redis/listeners/ListenerPlayerHandler.java +++ b/velocity.extension/src/main/java/net/swofty/velocity/redis/listeners/ListenerPlayerHandler.java @@ -4,10 +4,10 @@ import com.velocitypowered.api.proxy.ServerConnection; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.json.JSONComponentSerializer; -import net.swofty.commons.Configuration; import net.swofty.commons.ServerType; import net.swofty.commons.StringUtility; import net.swofty.commons.UnderstandableProxyServer; +import net.swofty.commons.config.ConfigProvider; import net.swofty.commons.proxy.FromProxyChannels; import net.swofty.commons.proxy.ToProxyChannels; import net.swofty.commons.proxy.requirements.to.PlayerHandlerRequirements; @@ -98,7 +98,7 @@ public JSONObject receivedMessage(JSONObject message, UUID serverUUID) { // Trick the packet blocker into thinking player is in normal transfer process TransferHandler.playersGoalServerType.put(player, ServerType.SKYBLOCK_HUB); - CompletableFuture.delayedExecutor(Long.parseLong(Configuration.get("transfer-timeout")), TimeUnit.MILLISECONDS) + CompletableFuture.delayedExecutor(ConfigProvider.settings().getTransferTimeout(), TimeUnit.MILLISECONDS) .execute(() -> { TransferHandler.playersGoalServerType.remove(player); transferHandler.noLimboTransferTo(serverInfo.registeredServer()); diff --git a/velocity.extension/src/main/java/net/swofty/velocity/redis/listeners/ListenerServerInitialized.java b/velocity.extension/src/main/java/net/swofty/velocity/redis/listeners/ListenerServerInitialized.java index e5b3060dd..d6b3f7ddb 100644 --- a/velocity.extension/src/main/java/net/swofty/velocity/redis/listeners/ListenerServerInitialized.java +++ b/velocity.extension/src/main/java/net/swofty/velocity/redis/listeners/ListenerServerInitialized.java @@ -1,8 +1,8 @@ package net.swofty.velocity.redis.listeners; import net.swofty.commons.ServerType; +import net.swofty.commons.config.ConfigProvider; import net.swofty.commons.proxy.ToProxyChannels; -import net.swofty.commons.Configuration; import net.swofty.velocity.gamemanager.GameManager; import net.swofty.velocity.redis.ChannelListener; import net.swofty.velocity.redis.RedisListener; @@ -22,7 +22,7 @@ public JSONObject receivedMessage(JSONObject message, UUID serverUUID) { String host = message.has("host") ? message.getString("host") - : Configuration.get("host-name"); // fallback to config if not present + : ConfigProvider.settings().getHostName(); // fallback to config if not present int maxPlayers = message.getInt("max_players"); diff --git a/website/docs/docker/setup.md b/website/docs/docker/setup.md index 47fe1116c..3944b6598 100644 --- a/website/docs/docker/setup.md +++ b/website/docs/docker/setup.md @@ -20,12 +20,12 @@ cd HypixelSkyBlock Download the [world files](https://files.catbox.moe/of7snu.zip) and extract them directly into the `configuration/` folder. The zip already contains the correct folder structure. -### 3. Configure resources.json +### 3. Configure config.yml In your `configuration` folder: -1. Remove the default `resources.json` -2. Rename `resources.json.docker` to `resources.json` +1. Remove the default `config.yml` +2. Rename `config.docker.yml` to `config.yml` ### 4. Build and Run diff --git a/website/docs/reference/configuration.md b/website/docs/reference/configuration.md index ceaa27c7a..87c94bd56 100644 --- a/website/docs/reference/configuration.md +++ b/website/docs/reference/configuration.md @@ -2,20 +2,27 @@ This page documents all configuration files and their options. -## resources.json +## config.yml The main configuration file shared by all servers and services. -**Location**: `configuration/resources.json` +**Location**: `configuration/config.yml` + +```yml +host-name: 0.0.0.0 +transfer-timeout: 800 +mongodb: mongodb://localhost +redis-url: redis://localhost:6379 +velocity-secret: your-forwarding-secret-here +require-auth: false +sandbox: false +spark: false +anticheat: false +redis-uri: redis://localhost:6379 +limbo: + host-name: 127.0.0.1 + port: 65535 -```json -{ - "velocity-secret": "your-forwarding-secret-here", - "mongodb-uri": "mongodb://localhost:27017", - "redis-uri": "redis://localhost:6379", - "resource-pack-url": "https://example.com/pack.zip", - "resource-pack-hash": "sha1-hash-of-pack" -} ``` ### Fields @@ -25,19 +32,16 @@ The main configuration file shared by all servers and services. | `velocity-secret` | Yes | Must match `forwarding.secret` from Velocity | | `mongodb-uri` | Yes | MongoDB connection string | | `redis-uri` | Yes | Redis connection string | -| `resource-pack-url` | No | URL to download resource pack | -| `resource-pack-hash` | No | SHA1 hash for pack verification | ### Docker Configuration -For Docker deployments, use `resources.json.docker`: +For Docker deployments, use `config.docker.yml`: -```json -{ - "velocity-secret": "docker-secret", - "mongodb-uri": "mongodb://mongodb:27017", - "redis-uri": "redis://redis:6379" -} +```yml +velocity-secret: "docker-secret" +mongodb-uri: "mongodb://mongodb:27017" +redis-uri: "redis://redis:6379" +... ``` Note the hostnames `mongodb` and `redis` match Docker service names. @@ -104,7 +108,7 @@ proxy/ β”œβ”€β”€ velocity.toml β”œβ”€β”€ forwarding.secret # Generated by Velocity β”œβ”€β”€ configuration/ -β”‚ └── resources.json +β”‚ └── config.yml └── plugins/ └── SkyBlockProxy.jar ``` @@ -114,7 +118,7 @@ proxy/ gameserver/ β”œβ”€β”€ HypixelCore.jar └── configuration/ - β”œβ”€β”€ resources.json + β”œβ”€β”€ config.yml β”œβ”€β”€ hypixel_prototype_lobby/ └── skyblock/ β”œβ”€β”€ islands/ @@ -133,7 +137,7 @@ services/ β”œβ”€β”€ ServiceBazaar.jar β”œβ”€β”€ ... └── configuration/ - └── resources.json + └── config.yml ``` ## Environment Variables diff --git a/website/docs/setup/game-servers.md b/website/docs/setup/game-servers.md index bdc0516fe..4259603b1 100644 --- a/website/docs/setup/game-servers.md +++ b/website/docs/setup/game-servers.md @@ -5,7 +5,7 @@ Game servers run the actual gameplay using Minestom. Each server runs as a speci ## Download Required Files 1. Download `HypixelCore.jar` from the [releases page](https://github.com/Swofty-Developments/HypixelSkyBlock/releases/tag/latest) -2. Download [`resources.json`](https://github.com/Swofty-Developments/HypixelSkyBlock/tree/master/configuration) +2. Download [`config.yml`](https://github.com/Swofty-Developments/HypixelSkyBlock/tree/master/configuration) 3. Download [world files](https://files.catbox.moe/of7snu.zip) 4. Download [`NanoLimbo.jar`](https://github.com/Swofty-Developments/HypixelSkyBlock/tree/master/configuration) and its config @@ -15,7 +15,7 @@ Game servers run the actual gameplay using Minestom. Each server runs as a speci gameserver/ β”œβ”€β”€ HypixelCore.jar β”œβ”€β”€ configuration/ -β”‚ β”œβ”€β”€ resources.json +β”‚ β”œβ”€β”€ config.yml β”‚ β”œβ”€β”€ skyblock/ β”‚ β”‚ β”œβ”€β”€ islands/ β”‚ β”‚ β”‚ β”œβ”€β”€ hypixel_skyblock_hub/ @@ -43,16 +43,24 @@ gameserver/ mkdir -p gameserver/configuration/skyblock/islands ``` -### 2. Configure resources.json - -Copy the `forwarding.secret` from your Velocity proxy directory and add it to `resources.json`: - -```json -{ - "velocity-secret": "PASTE_YOUR_SECRET_HERE", - "mongodb-uri": "mongodb://localhost:27017", - "redis-uri": "redis://localhost:6379" -} +### 2. Configure config.yml + +Copy the `forwarding.secret` from your Velocity proxy directory and add it to `config.yml`: + +```yaml +host-name: 0.0.0.0 +transfer-timeout: 800 +mongodb: mongodb://localhost +redis-url: redis://localhost:6379 +velocity-secret: your-forwarding-secret-here +require-auth: false +sandbox: false +spark: false +anticheat: false +redis-uri: redis://localhost:6379 +limbo: + host-name: 127.0.0.1 + port: 65535 ``` ### 3. Install World Files diff --git a/website/docs/setup/proxy.md b/website/docs/setup/proxy.md index d2888d87b..1d9e1574d 100644 --- a/website/docs/setup/proxy.md +++ b/website/docs/setup/proxy.md @@ -7,7 +7,7 @@ The Velocity proxy acts as the entry point for all player connections and routes 1. Download `SkyBlockProxy.jar` from the [releases page](https://github.com/Swofty-Developments/HypixelSkyBlock/releases/tag/latest) 2. Download [Velocity 3.4.0](https://fill-data.papermc.io/v1/objects/ef1a852bfae7397e84907837925e7ad21c6312066290edaae401b77f6f423ac3/velocity-3.4.0-SNAPSHOT-558.jar) 3. Download [`velocity.toml`](https://github.com/Swofty-Developments/HypixelSkyBlock/tree/master/configuration) -4. Download [`resources.json`](https://github.com/Swofty-Developments/HypixelSkyBlock/tree/master/configuration) +4. Download [`config.yml`](https://github.com/Swofty-Developments/HypixelSkyBlock/tree/master/configuration) ## Directory Structure @@ -18,7 +18,7 @@ proxy/ β”œβ”€β”€ velocity-3.4.0-SNAPSHOT-558.jar β”œβ”€β”€ velocity.toml β”œβ”€β”€ configuration/ -β”‚ └── resources.json +β”‚ └── config.yml └── plugins/ └── SkyBlockProxy.jar ``` @@ -38,7 +38,7 @@ proxy/ 5. **Create configuration folder** - Make a `configuration` folder next to `velocity.toml` -6. **Add resources.json** - Move `resources.json` into the `configuration` folder +6. **Add config.yml** - Move `config.yml` into the `configuration` folder 7. **Start the proxy**: ```bash @@ -57,16 +57,24 @@ online-mode = true # Set to false for cracked servers player-info-forwarding-mode = "modern" ``` -### resources.json +### config.yml This file contains shared configuration used by both the proxy and game servers. Key fields: -```json -{ - "velocity-secret": "YOUR_FORWARDING_SECRET", - "mongodb-uri": "mongodb://localhost:27017", - "redis-uri": "redis://localhost:6379" -} +```yml +host-name: 0.0.0.0 +transfer-timeout: 800 +mongodb: mongodb://localhost +redis-url: redis://localhost:6379 +velocity-secret: your-forwarding-secret-here +require-auth: false +sandbox: false +spark: false +anticheat: false +redis-uri: redis://localhost:6379 +limbo: + host-name: 127.0.0.1 + port: 65535 ``` :::alert warning diff --git a/website/docs/setup/resource-pack.md b/website/docs/setup/resource-pack.md index 80e6cf749..d5cba139f 100644 --- a/website/docs/setup/resource-pack.md +++ b/website/docs/setup/resource-pack.md @@ -43,17 +43,15 @@ After generation: 1. The resource pack will be in your output directory 2. Apply it in Minecraft under Options β†’ Resource Packs -3. For server-side distribution, host the pack and configure in `resources.json` +3. For server-side distribution, host the pack and configure in `config.yml` ## Server-Side Distribution -To automatically send the pack to players, add to your `resources.json`: +To automatically send the pack to players, add to your `config.yml`: -```json -{ - "resource-pack-url": "https://your-host.com/pack.zip", - "resource-pack-hash": "SHA1_HASH_HERE" -} +```yaml +resource-pack-url: "https://your-host.com/pack.zip" +resource-pack-hash: "SHA1_HASH_HERE" ``` Generate the SHA1 hash: diff --git a/website/docs/setup/services.md b/website/docs/setup/services.md index c128a80dd..3834a84a3 100644 --- a/website/docs/setup/services.md +++ b/website/docs/setup/services.md @@ -34,7 +34,7 @@ services/ β”œβ”€β”€ ServiceDarkAuction.jar β”œβ”€β”€ ServiceOrchestrator.jar └── configuration/ - └── resources.json # Same as game servers + └── config.yml # Same as game servers ``` ## Starting Services diff --git a/website/docs/troubleshooting.md b/website/docs/troubleshooting.md index bfafc6d4a..4b56f67c0 100644 --- a/website/docs/troubleshooting.md +++ b/website/docs/troubleshooting.md @@ -10,7 +10,7 @@ Common issues and their solutions. **Solutions**: 1. Verify Redis/Memurai is running -2. Check the `redis-uri` in `resources.json` +2. Check the `redis-uri` in `config.yml` 3. On Windows, try [this Redis port](https://github.com/tporadowski/redis/releases) instead of Memurai ### Can't Connect to Server @@ -23,14 +23,14 @@ Common issues and their solutions. 3. Is NanoLimbo running? 4. Check if the `velocity-secret` matches everywhere: - `forwarding.secret` (Velocity) - - `resources.json` (game servers) + - `config.yml` (game servers) - `settings.yml` (NanoLimbo) ### MongoDB Connection Failed **Solutions**: 1. Verify MongoDB is running on port 27017 -2. Check `mongodb-uri` in `resources.json` +2. Check `mongodb-uri` in `config.yml` 3. If using authentication, include credentials in URI: ``` mongodb://username:password@localhost:27017 @@ -118,7 +118,7 @@ docker-compose logs -f Common causes: - Missing configuration files -- Invalid `resources.json` +- Invalid `config.yml` - Database connection failures ## Performance Issues @@ -149,7 +149,7 @@ If you're still having issues: 3. **Join Discord** at [discord.gg/ZaGW5wzUJ3](https://discord.gg/ZaGW5wzUJ3) 4. **Ask in #code-help** with: - Screenshots of all console outputs - - Your `resources.json` (remove secrets) + - Your `config.yml` (remove secrets) - Steps you've already tried :::alert warning