From cc3cf702572ca81707e129f0172ad39810e0540e Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Sat, 25 Jan 2020 22:59:00 -0600 Subject: [PATCH] Search for key in Geyser plugin folder in plugin versions --- .../platform/bukkit/GeyserBukkitConfiguration.java | 9 ++++++--- .../org/geysermc/platform/bukkit/GeyserBukkitPlugin.java | 2 +- .../platform/bungeecord/GeyserBungeeConfiguration.java | 9 ++++++--- .../geysermc/platform/bungeecord/GeyserBungeePlugin.java | 2 +- .../platform/sponge/GeyserSpongeConfiguration.java | 9 ++++++--- .../org/geysermc/platform/sponge/GeyserSpongePlugin.java | 2 +- .../java/org/geysermc/common/IGeyserConfiguration.java | 3 ++- .../connector/network/session/GeyserSession.java | 2 +- 8 files changed, 24 insertions(+), 14 deletions(-) diff --git a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitConfiguration.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitConfiguration.java index 8a2a7a9a0..f4c4b008c 100644 --- a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitConfiguration.java +++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitConfiguration.java @@ -28,12 +28,14 @@ package org.geysermc.platform.bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.geysermc.common.IGeyserConfiguration; +import java.io.File; import java.util.HashMap; import java.util.Map; public class GeyserBukkitConfiguration implements IGeyserConfiguration { private FileConfiguration config; + private File dataFolder; private BukkitBedrockConfiguration bedrockConfig; private BukkitRemoteConfiguration remoteConfig; @@ -41,7 +43,8 @@ public class GeyserBukkitConfiguration implements IGeyserConfiguration { private Map userAuthInfo = new HashMap<>(); - public GeyserBukkitConfiguration(FileConfiguration config) { + public GeyserBukkitConfiguration(File dataFolder, FileConfiguration config) { + this.dataFolder = dataFolder; this.config = config; bedrockConfig = new BukkitBedrockConfiguration(); @@ -97,8 +100,8 @@ public class GeyserBukkitConfiguration implements IGeyserConfiguration { } @Override - public String getFloodgateKeyFile() { - return config.getString("floodgate-key-file", "public-key.pem"); + public File getFloodgateKeyFile() { + return new File(dataFolder.toString() + config.getString("floodgate-key-file", "public-key.pem")); } @Override diff --git a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java index 6bb77df1a..21f130da3 100644 --- a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java +++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java @@ -41,7 +41,7 @@ public class GeyserBukkitPlugin extends JavaPlugin implements IGeyserBootstrap { public void onEnable() { saveDefaultConfig(); - geyserConfig = new GeyserBukkitConfiguration(getConfig()); + geyserConfig = new GeyserBukkitConfiguration(getDataFolder(), getConfig()); if (geyserConfig.getMetrics().getUniqueId().equals("generateduuid")) { getConfig().set("metrics.uuid", UUID.randomUUID().toString()); diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeConfiguration.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeConfiguration.java index 43c77733b..0aaf714b3 100644 --- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeConfiguration.java +++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeConfiguration.java @@ -29,11 +29,13 @@ import net.md_5.bungee.config.Configuration; import org.geysermc.common.IGeyserConfiguration; +import java.io.File; import java.util.HashMap; import java.util.Map; public class GeyserBungeeConfiguration implements IGeyserConfiguration { + private File dataFolder; private Configuration config; private BungeeBedrockConfiguration bedrockConfig; @@ -42,7 +44,8 @@ public class GeyserBungeeConfiguration implements IGeyserConfiguration { private Map userAuthInfo = new HashMap<>(); - public GeyserBungeeConfiguration(Configuration config) { + public GeyserBungeeConfiguration(File dataFolder, Configuration config) { + this.dataFolder = dataFolder; this.config = config; bedrockConfig = new BungeeBedrockConfiguration(); @@ -98,8 +101,8 @@ public class GeyserBungeeConfiguration implements IGeyserConfiguration { } @Override - public String getFloodgateKeyFile() { - return config.getString("floodgate-key-file", "public-key.pem"); + public File getFloodgateKeyFile() { + return new File(dataFolder, config.getString("floodgate-key-file", "public-key.pem")); } @Override diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java index bf7cfff8a..b396ede5d 100644 --- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java +++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java @@ -73,7 +73,7 @@ public class GeyserBungeePlugin extends Plugin implements IGeyserBootstrap { return; } - geyserConfig = new GeyserBungeeConfiguration(configuration); + geyserConfig = new GeyserBungeeConfiguration(getDataFolder(), configuration); if (geyserConfig.getMetrics().getUniqueId().equals("generateduuid")) { configuration.set("metrics.uuid", UUID.randomUUID().toString()); diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeConfiguration.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeConfiguration.java index 1b30c4393..86b3ef342 100644 --- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeConfiguration.java +++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeConfiguration.java @@ -31,12 +31,14 @@ import ninja.leaping.configurate.ConfigurationNode; import org.geysermc.common.IGeyserConfiguration; +import java.io.File; import java.util.HashMap; import java.util.List; import java.util.Map; public class GeyserSpongeConfiguration implements IGeyserConfiguration { + private File dataFolder; private ConfigurationNode node; private SpongeBedrockConfiguration bedrockConfig; @@ -45,7 +47,8 @@ public class GeyserSpongeConfiguration implements IGeyserConfiguration { private Map userAuthInfo = new HashMap<>(); - public GeyserSpongeConfiguration(ConfigurationNode node) { + public GeyserSpongeConfiguration(File dataFolder, ConfigurationNode node) { + this.dataFolder = dataFolder; this.node = node; this.bedrockConfig = new SpongeBedrockConfiguration(node.getNode("bedrock")); @@ -101,8 +104,8 @@ public class GeyserSpongeConfiguration implements IGeyserConfiguration { } @Override - public String getFloodgateKeyFile() { - return node.getNode("floodgate-key-file").getString("public-key.pem"); + public File getFloodgateKeyFile() { + return new File(dataFolder, node.getNode("floodgate-key-file").getString("public-key.pem")); } @Override diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java index ecac6353c..15ab0d1fe 100644 --- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java +++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java @@ -73,7 +73,7 @@ public class GeyserSpongePlugin implements IGeyserBootstrap { ConfigurationLoader loader = YAMLConfigurationLoader.builder().setPath(configFile.toPath()).build(); try { - this.geyserConfig = new GeyserSpongeConfiguration(loader.load()); + this.geyserConfig = new GeyserSpongeConfiguration(configDir, loader.load()); } catch (IOException ex) { logger.warn("Failed to load config.yml!"); ex.printStackTrace(); diff --git a/common/src/main/java/org/geysermc/common/IGeyserConfiguration.java b/common/src/main/java/org/geysermc/common/IGeyserConfiguration.java index 1414e6c21..0a1da2d35 100644 --- a/common/src/main/java/org/geysermc/common/IGeyserConfiguration.java +++ b/common/src/main/java/org/geysermc/common/IGeyserConfiguration.java @@ -25,6 +25,7 @@ package org.geysermc.common; +import java.io.File; import java.util.Map; public interface IGeyserConfiguration { @@ -45,7 +46,7 @@ public interface IGeyserConfiguration { boolean isAllowThirdPartyCapes(); - String getFloodgateKeyFile(); + File getFloodgateKeyFile(); IMetricsInfo getMetrics(); diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index 54577296a..f38e810d4 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -190,7 +190,7 @@ public class GeyserSession implements CommandSender { PublicKey key = null; try { key = EncryptionUtil.getKeyFromFile( - Paths.get(connector.getConfig().getFloodgateKeyFile()), + Paths.get(connector.getConfig().getFloodgateKeyFile().getPath()), PublicKey.class ); } catch (IOException | InvalidKeySpecException | NoSuchAlgorithmException e) {