3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-19 14:30:17 +01:00

Use Path instead of File for floodgate key file in config

...and fix related issues with the file not being found.
Dieser Commit ist enthalten in:
RednedEpic 2020-01-26 11:22:21 -06:00
Ursprung c4857c6a54
Commit 240f41ff03
6 geänderte Dateien mit 21 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -29,6 +29,8 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.geysermc.common.IGeyserConfiguration; import org.geysermc.common.IGeyserConfiguration;
import java.io.File; import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -100,8 +102,8 @@ public class GeyserBukkitConfiguration implements IGeyserConfiguration {
} }
@Override @Override
public File getFloodgateKeyFile() { public Path getFloodgateKeyFile() {
return new File(dataFolder.toString() + config.getString("floodgate-key-file", "public-key.pem")); return Paths.get(dataFolder.toString(), config.getString("floodgate-key-file", "public-key.pem"));
} }
@Override @Override

Datei anzeigen

@ -30,6 +30,8 @@ import net.md_5.bungee.config.Configuration;
import org.geysermc.common.IGeyserConfiguration; import org.geysermc.common.IGeyserConfiguration;
import java.io.File; import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -101,8 +103,8 @@ public class GeyserBungeeConfiguration implements IGeyserConfiguration {
} }
@Override @Override
public File getFloodgateKeyFile() { public Path getFloodgateKeyFile() {
return new File(dataFolder, config.getString("floodgate-key-file", "public-key.pem")); return Paths.get(dataFolder.toString(), config.getString("floodgate-key-file", "public-key.pem"));
} }
@Override @Override

Datei anzeigen

@ -32,6 +32,8 @@ import ninja.leaping.configurate.ConfigurationNode;
import org.geysermc.common.IGeyserConfiguration; import org.geysermc.common.IGeyserConfiguration;
import java.io.File; import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -104,8 +106,8 @@ public class GeyserSpongeConfiguration implements IGeyserConfiguration {
} }
@Override @Override
public File getFloodgateKeyFile() { public Path getFloodgateKeyFile() {
return new File(dataFolder, node.getNode("floodgate-key-file").getString("public-key.pem")); return Paths.get(dataFolder.toString(), node.getNode("floodgate-key-file").getString("public-key.pem"));
} }
@Override @Override

Datei anzeigen

@ -27,10 +27,13 @@ package org.geysermc.platform.standalone;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter; import lombok.Getter;
import org.geysermc.common.IGeyserConfiguration; 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.Map;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
@ -63,8 +66,8 @@ public class GeyserConfiguration implements IGeyserConfiguration {
private MetricsInfo metrics; private MetricsInfo metrics;
@Override @Override
public File getFloodgateKeyFile() { public Path getFloodgateKeyFile() {
return new File(floodgateKeyFile); return Paths.get(floodgateKeyFile);
} }
@Getter @Getter

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.common; package org.geysermc.common;
import java.io.File; import java.nio.file.Path;
import java.util.Map; import java.util.Map;
public interface IGeyserConfiguration { public interface IGeyserConfiguration {
@ -46,7 +46,7 @@ public interface IGeyserConfiguration {
boolean isAllowThirdPartyCapes(); boolean isAllowThirdPartyCapes();
File getFloodgateKeyFile(); Path getFloodgateKeyFile();
IMetricsInfo getMetrics(); IMetricsInfo getMetrics();

Datei anzeigen

@ -66,7 +66,6 @@ import org.geysermc.floodgate.util.EncryptionUtil;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.file.Paths;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.security.PublicKey; import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException; import java.security.spec.InvalidKeySpecException;
@ -190,7 +189,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().getPath()), connector.getConfig().getFloodgateKeyFile(),
PublicKey.class PublicKey.class
); );
} catch (IOException | InvalidKeySpecException | NoSuchAlgorithmException e) { } catch (IOException | InvalidKeySpecException | NoSuchAlgorithmException e) {