From 5418b9e26307d8a2a915e279f92ef021eadc883c Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Thu, 1 Apr 2021 20:07:32 -0400 Subject: [PATCH] Update for Floodgate 2.0 --- bootstrap/fabric/build.gradle | 4 ++-- bootstrap/fabric/gradle.properties | 2 +- .../fabric/GeyserFabricConfiguration.java | 17 ++++++++++++++++- .../platform/fabric/GeyserFabricMod.java | 19 +++++++++++++++---- .../fabric/src/main/resources/fabric.mod.json | 2 +- 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/bootstrap/fabric/build.gradle b/bootstrap/fabric/build.gradle index 0e8c2d181..cb63756b2 100644 --- a/bootstrap/fabric/build.gradle +++ b/bootstrap/fabric/build.gradle @@ -27,8 +27,8 @@ dependencies { // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. // You may need to force-disable transitiveness on them. - implementation 'org.geysermc:connector:1.2.0-SNAPSHOT' - shadow 'org.geysermc:connector:1.2.0-SNAPSHOT' + implementation 'org.geysermc:connector:1.3.0-SNAPSHOT' + shadow 'org.geysermc:connector:1.3.0-SNAPSHOT' } repositories { diff --git a/bootstrap/fabric/gradle.properties b/bootstrap/fabric/gradle.properties index 7fe0d5d14..43be1e478 100644 --- a/bootstrap/fabric/gradle.properties +++ b/bootstrap/fabric/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.16.3 yarn_mappings=1.16.3+build.28 loader_version=0.10.1+build.209 # Mod Properties -mod_version=1.0-SNAPSHOT +mod_version=1.3.0-SNAPSHOT maven_group=org.geysermc.platform archives_base_name=Geyser-Fabric # Dependencies diff --git a/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/GeyserFabricConfiguration.java b/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/GeyserFabricConfiguration.java index 9f843693a..f3b446760 100644 --- a/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/GeyserFabricConfiguration.java +++ b/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/GeyserFabricConfiguration.java @@ -25,13 +25,28 @@ package org.geysermc.platform.fabric; +import com.fasterxml.jackson.annotation.JsonIgnore; +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; +import org.geysermc.connector.FloodgateKeyLoader; import org.geysermc.connector.configuration.GeyserJacksonConfiguration; import java.nio.file.Path; +import java.util.Optional; public class GeyserFabricConfiguration extends GeyserJacksonConfiguration { + @JsonIgnore + private Path floodgateKeyPath; + + public void loadFloodgate(GeyserFabricMod geyser, ModContainer floodgate) { + Path geyserDataFolder = geyser.getConfigFolder(); + Path floodgateDataFolder = FabricLoader.getInstance().getConfigDir().resolve("floodgate"); + + floodgateKeyPath = FloodgateKeyLoader.getKeyPath(this, floodgate, floodgateDataFolder, geyserDataFolder, geyser.getGeyserLogger()); + } + @Override public Path getFloodgateKeyPath() { - return null; + return floodgateKeyPath; } } diff --git a/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/GeyserFabricMod.java b/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/GeyserFabricMod.java index 7c87b5ede..cbcc452bf 100644 --- a/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/GeyserFabricMod.java +++ b/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/GeyserFabricMod.java @@ -30,6 +30,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; import org.apache.logging.log4j.LogManager; @@ -55,10 +56,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.nio.file.Path; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; public class GeyserFabricMod implements ModInitializer, GeyserBootstrap { @@ -144,6 +142,19 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap { geyserConfig.getBedrock().setPort(geyserConfig.getRemote().getPort()); } + Optional floodgate = FabricLoader.getInstance().getModContainer("floodgate"); + boolean floodgatePresent = floodgate.isPresent(); + if (geyserConfig.getRemote().getAuthType().equals("floodgate") && !floodgatePresent) { + geyserLogger.severe(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.disabling")); + return; + } else if (geyserConfig.isAutoconfiguredRemote() && floodgatePresent) { + // Floodgate installed means that the user wants Floodgate authentication + geyserLogger.debug("Auto-setting to Floodgate authentication."); + geyserConfig.getRemote().setAuthType("floodgate"); + } + + geyserConfig.loadFloodgate(this, floodgate.orElse(null)); + this.connector = GeyserConnector.start(PlatformType.FABRIC, this); this.geyserPingPassthrough = GeyserLegacyPingPassthrough.init(connector); diff --git a/bootstrap/fabric/src/main/resources/fabric.mod.json b/bootstrap/fabric/src/main/resources/fabric.mod.json index 89cbd12b5..ceb37daf3 100644 --- a/bootstrap/fabric/src/main/resources/fabric.mod.json +++ b/bootstrap/fabric/src/main/resources/fabric.mod.json @@ -12,7 +12,7 @@ "repo": "https://github.com/GeyserMC/Geyser-Fabric" }, "license": "MIT", - "icon": "assets/fabric/icon.png", + "icon": "assets/geyser-fabric/icon.png", "environment": "*", "entrypoints": { "main": [