mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-22 14:34:59 +01:00
Search for key in Geyser plugin folder in plugin versions
This commit is contained in:
parent
ba724bb7d6
commit
cc3cf70257
8 changed files with 24 additions and 14 deletions
|
@ -28,12 +28,14 @@ package org.geysermc.platform.bukkit;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.geysermc.common.IGeyserConfiguration;
|
import org.geysermc.common.IGeyserConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class GeyserBukkitConfiguration implements IGeyserConfiguration {
|
public class GeyserBukkitConfiguration implements IGeyserConfiguration {
|
||||||
|
|
||||||
private FileConfiguration config;
|
private FileConfiguration config;
|
||||||
|
private File dataFolder;
|
||||||
|
|
||||||
private BukkitBedrockConfiguration bedrockConfig;
|
private BukkitBedrockConfiguration bedrockConfig;
|
||||||
private BukkitRemoteConfiguration remoteConfig;
|
private BukkitRemoteConfiguration remoteConfig;
|
||||||
|
@ -41,7 +43,8 @@ public class GeyserBukkitConfiguration implements IGeyserConfiguration {
|
||||||
|
|
||||||
private Map<String, BukkitUserAuthenticationInfo> userAuthInfo = new HashMap<>();
|
private Map<String, BukkitUserAuthenticationInfo> userAuthInfo = new HashMap<>();
|
||||||
|
|
||||||
public GeyserBukkitConfiguration(FileConfiguration config) {
|
public GeyserBukkitConfiguration(File dataFolder, FileConfiguration config) {
|
||||||
|
this.dataFolder = dataFolder;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
bedrockConfig = new BukkitBedrockConfiguration();
|
bedrockConfig = new BukkitBedrockConfiguration();
|
||||||
|
@ -97,8 +100,8 @@ public class GeyserBukkitConfiguration implements IGeyserConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFloodgateKeyFile() {
|
public File getFloodgateKeyFile() {
|
||||||
return config.getString("floodgate-key-file", "public-key.pem");
|
return new File(dataFolder.toString() + config.getString("floodgate-key-file", "public-key.pem"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class GeyserBukkitPlugin extends JavaPlugin implements IGeyserBootstrap {
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
|
|
||||||
geyserConfig = new GeyserBukkitConfiguration(getConfig());
|
geyserConfig = new GeyserBukkitConfiguration(getDataFolder(), getConfig());
|
||||||
|
|
||||||
if (geyserConfig.getMetrics().getUniqueId().equals("generateduuid")) {
|
if (geyserConfig.getMetrics().getUniqueId().equals("generateduuid")) {
|
||||||
getConfig().set("metrics.uuid", UUID.randomUUID().toString());
|
getConfig().set("metrics.uuid", UUID.randomUUID().toString());
|
||||||
|
|
|
@ -29,11 +29,13 @@ import net.md_5.bungee.config.Configuration;
|
||||||
|
|
||||||
import org.geysermc.common.IGeyserConfiguration;
|
import org.geysermc.common.IGeyserConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class GeyserBungeeConfiguration implements IGeyserConfiguration {
|
public class GeyserBungeeConfiguration implements IGeyserConfiguration {
|
||||||
|
|
||||||
|
private File dataFolder;
|
||||||
private Configuration config;
|
private Configuration config;
|
||||||
|
|
||||||
private BungeeBedrockConfiguration bedrockConfig;
|
private BungeeBedrockConfiguration bedrockConfig;
|
||||||
|
@ -42,7 +44,8 @@ public class GeyserBungeeConfiguration implements IGeyserConfiguration {
|
||||||
|
|
||||||
private Map<String, BungeeUserAuthenticationInfo> userAuthInfo = new HashMap<>();
|
private Map<String, BungeeUserAuthenticationInfo> userAuthInfo = new HashMap<>();
|
||||||
|
|
||||||
public GeyserBungeeConfiguration(Configuration config) {
|
public GeyserBungeeConfiguration(File dataFolder, Configuration config) {
|
||||||
|
this.dataFolder = dataFolder;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
bedrockConfig = new BungeeBedrockConfiguration();
|
bedrockConfig = new BungeeBedrockConfiguration();
|
||||||
|
@ -98,8 +101,8 @@ public class GeyserBungeeConfiguration implements IGeyserConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFloodgateKeyFile() {
|
public File getFloodgateKeyFile() {
|
||||||
return config.getString("floodgate-key-file", "public-key.pem");
|
return new File(dataFolder, config.getString("floodgate-key-file", "public-key.pem"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class GeyserBungeePlugin extends Plugin implements IGeyserBootstrap {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
geyserConfig = new GeyserBungeeConfiguration(configuration);
|
geyserConfig = new GeyserBungeeConfiguration(getDataFolder(), configuration);
|
||||||
|
|
||||||
if (geyserConfig.getMetrics().getUniqueId().equals("generateduuid")) {
|
if (geyserConfig.getMetrics().getUniqueId().equals("generateduuid")) {
|
||||||
configuration.set("metrics.uuid", UUID.randomUUID().toString());
|
configuration.set("metrics.uuid", UUID.randomUUID().toString());
|
||||||
|
|
|
@ -31,12 +31,14 @@ import ninja.leaping.configurate.ConfigurationNode;
|
||||||
|
|
||||||
import org.geysermc.common.IGeyserConfiguration;
|
import org.geysermc.common.IGeyserConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class GeyserSpongeConfiguration implements IGeyserConfiguration {
|
public class GeyserSpongeConfiguration implements IGeyserConfiguration {
|
||||||
|
|
||||||
|
private File dataFolder;
|
||||||
private ConfigurationNode node;
|
private ConfigurationNode node;
|
||||||
|
|
||||||
private SpongeBedrockConfiguration bedrockConfig;
|
private SpongeBedrockConfiguration bedrockConfig;
|
||||||
|
@ -45,7 +47,8 @@ public class GeyserSpongeConfiguration implements IGeyserConfiguration {
|
||||||
|
|
||||||
private Map<String, SpongeUserAuthenticationInfo> userAuthInfo = new HashMap<>();
|
private Map<String, SpongeUserAuthenticationInfo> userAuthInfo = new HashMap<>();
|
||||||
|
|
||||||
public GeyserSpongeConfiguration(ConfigurationNode node) {
|
public GeyserSpongeConfiguration(File dataFolder, ConfigurationNode node) {
|
||||||
|
this.dataFolder = dataFolder;
|
||||||
this.node = node;
|
this.node = node;
|
||||||
|
|
||||||
this.bedrockConfig = new SpongeBedrockConfiguration(node.getNode("bedrock"));
|
this.bedrockConfig = new SpongeBedrockConfiguration(node.getNode("bedrock"));
|
||||||
|
@ -101,8 +104,8 @@ public class GeyserSpongeConfiguration implements IGeyserConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFloodgateKeyFile() {
|
public File getFloodgateKeyFile() {
|
||||||
return node.getNode("floodgate-key-file").getString("public-key.pem");
|
return new File(dataFolder, node.getNode("floodgate-key-file").getString("public-key.pem"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class GeyserSpongePlugin implements IGeyserBootstrap {
|
||||||
|
|
||||||
ConfigurationLoader loader = YAMLConfigurationLoader.builder().setPath(configFile.toPath()).build();
|
ConfigurationLoader loader = YAMLConfigurationLoader.builder().setPath(configFile.toPath()).build();
|
||||||
try {
|
try {
|
||||||
this.geyserConfig = new GeyserSpongeConfiguration(loader.load());
|
this.geyserConfig = new GeyserSpongeConfiguration(configDir, loader.load());
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.warn("Failed to load config.yml!");
|
logger.warn("Failed to load config.yml!");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
package org.geysermc.common;
|
package org.geysermc.common;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface IGeyserConfiguration {
|
public interface IGeyserConfiguration {
|
||||||
|
@ -45,7 +46,7 @@ public interface IGeyserConfiguration {
|
||||||
|
|
||||||
boolean isAllowThirdPartyCapes();
|
boolean isAllowThirdPartyCapes();
|
||||||
|
|
||||||
String getFloodgateKeyFile();
|
File getFloodgateKeyFile();
|
||||||
|
|
||||||
IMetricsInfo getMetrics();
|
IMetricsInfo getMetrics();
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,7 @@ public class GeyserSession implements CommandSender {
|
||||||
PublicKey key = null;
|
PublicKey key = null;
|
||||||
try {
|
try {
|
||||||
key = EncryptionUtil.getKeyFromFile(
|
key = EncryptionUtil.getKeyFromFile(
|
||||||
Paths.get(connector.getConfig().getFloodgateKeyFile()),
|
Paths.get(connector.getConfig().getFloodgateKeyFile().getPath()),
|
||||||
PublicKey.class
|
PublicKey.class
|
||||||
);
|
);
|
||||||
} catch (IOException | InvalidKeySpecException | NoSuchAlgorithmException e) {
|
} catch (IOException | InvalidKeySpecException | NoSuchAlgorithmException e) {
|
||||||
|
|
Loading…
Reference in a new issue