Search for key in Geyser plugin folder in plugin versions

This commit is contained in:
RednedEpic 2020-01-25 22:59:00 -06:00
parent ba724bb7d6
commit cc3cf70257
8 changed files with 24 additions and 14 deletions

View file

@ -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<String, BukkitUserAuthenticationInfo> 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

View file

@ -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());

View file

@ -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<String, BungeeUserAuthenticationInfo> 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

View file

@ -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());

View file

@ -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<String, SpongeUserAuthenticationInfo> 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

View file

@ -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();

View file

@ -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();

View file

@ -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) {