forked from GeyserMC/Geyser
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:
parent
692e46146c
commit
9c6ac1b41c
7 changed files with 99 additions and 7 deletions
|
@ -27,13 +27,18 @@ package org.geysermc.platform.velocity;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.geysermc.common.FloodgateKeyLoader;
|
||||
import org.geysermc.common.IGeyserConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@Getter
|
||||
|
@ -67,9 +72,16 @@ public class GeyserVelocityConfiguration implements IGeyserConfiguration {
|
|||
|
||||
private MetricsInfo metrics;
|
||||
|
||||
private Path floodgateKey;
|
||||
|
||||
public void loadFloodgate(GeyserVelocityPlugin plugin, ProxyServer proxyServer, File dataFolder) {
|
||||
Optional<PluginContainer> floodgate = proxyServer.getPluginManager().getPlugin("floodgate");
|
||||
floodgateKey = FloodgateKeyLoader.getKey(plugin.getGeyserLogger(), this, Paths.get(dataFolder.toString(), floodgateKeyFile.isEmpty() ? floodgateKeyFile : "public-key.pem"), floodgate.get(), Paths.get("plugins/floodgate/"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getFloodgateKeyFile() {
|
||||
return Paths.get(floodgateKeyFile);
|
||||
return floodgateKey;
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
|
|
@ -54,7 +54,7 @@ public class GeyserVelocityPlugin implements IGeyserBootstrap {
|
|||
private Logger logger;
|
||||
|
||||
@Inject
|
||||
private ProxyServer server;
|
||||
private ProxyServer proxyServer;
|
||||
|
||||
@Inject
|
||||
private CommandManager commandManager;
|
||||
|
@ -67,8 +67,9 @@ public class GeyserVelocityPlugin implements IGeyserBootstrap {
|
|||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
File configDir = new File("plugins/" + GeyserConnector.NAME + "-Velocity/");
|
||||
|
||||
try {
|
||||
File configDir = new File("plugins/" + GeyserConnector.NAME + "-Velocity/");
|
||||
if (!configDir.exists())
|
||||
configDir.mkdir();
|
||||
File configFile = FileUtils.fileOrCopiedFromResource(new File(configDir, "config.yml"), "config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
|
||||
|
@ -78,7 +79,7 @@ public class GeyserVelocityPlugin implements IGeyserBootstrap {
|
|||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
InetSocketAddress javaAddr = server.getBoundAddress();
|
||||
InetSocketAddress javaAddr = proxyServer.getBoundAddress();
|
||||
|
||||
// Don't change the ip if its listening on all interfaces
|
||||
// By default this should be 127.0.0.1 but may need to be changed in some circumstances
|
||||
|
@ -89,6 +90,9 @@ public class GeyserVelocityPlugin implements IGeyserBootstrap {
|
|||
geyserConfig.getRemote().setPort(javaAddr.getPort());
|
||||
|
||||
this.geyserLogger = new GeyserVelocityLogger(logger, geyserConfig.isDebugMode());
|
||||
|
||||
geyserConfig.loadFloodgate(this, proxyServer, configDir);
|
||||
|
||||
this.connector = GeyserConnector.start(PlatformType.VELOCITY, this);
|
||||
|
||||
this.geyserCommandManager = new GeyserVelocityCommandManager(connector);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue