Auto load floodgate key if floodgate installed and set authtype (#454)

* Added floodgate key auto loading for Bukkit

* Added floodgate key auto loading for Bungee

* Added floodgate key auto loading for Velocity and fixed key location

* Moved key loading to common
This commit is contained in:
rtm516 2020-05-03 21:30:20 +01:00 committed by GitHub
parent 692e46146c
commit 9c6ac1b41c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 99 additions and 7 deletions

View file

@ -25,7 +25,10 @@
package org.geysermc.platform.bukkit;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.Plugin;
import org.geysermc.common.FloodgateKeyLoader;
import org.geysermc.common.IGeyserConfiguration;
import java.io.File;
@ -45,6 +48,8 @@ public class GeyserBukkitConfiguration implements IGeyserConfiguration {
private Map<String, BukkitUserAuthenticationInfo> userAuthInfo = new HashMap<>();
private Path floodgateKey;
public GeyserBukkitConfiguration(File dataFolder, FileConfiguration config) {
this.dataFolder = dataFolder;
this.config = config;
@ -61,6 +66,11 @@ public class GeyserBukkitConfiguration implements IGeyserConfiguration {
}
}
public void loadFloodgate(GeyserBukkitPlugin plugin) {
Plugin floodgate = Bukkit.getPluginManager().getPlugin("floodgate-bukkit");
floodgateKey = FloodgateKeyLoader.getKey(plugin.getGeyserLogger(), this, Paths.get(dataFolder.toString(), config.getString("floodgate-key-file", "public-key.pem")), floodgate, floodgate != null ? floodgate.getDataFolder().toPath() : null);
}
@Override
public IBedrockConfiguration getBedrock() {
return bedrockConfig;
@ -108,7 +118,7 @@ public class GeyserBukkitConfiguration implements IGeyserConfiguration {
@Override
public Path getFloodgateKeyFile() {
return Paths.get(dataFolder.toString(), config.getString("floodgate-key-file", "public-key.pem"));
return floodgateKey;
}
@Override

View file

@ -64,6 +64,9 @@ public class GeyserBukkitPlugin extends JavaPlugin implements IGeyserBootstrap {
saveConfig();
this.geyserLogger = new GeyserBukkitLogger(getLogger(), geyserConfig.isDebugMode());
geyserConfig.loadFloodgate(this);
this.connector = GeyserConnector.start(PlatformType.BUKKIT, this);
this.geyserCommandManager = new GeyserBukkitCommandManager(this, connector);