Skip to content

Commit

Permalink
fix: exception when reading server defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
WiIIiam278 committed Jan 26, 2024
1 parent 267cf1f commit fa7f6f0
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions common/src/main/java/net/william278/husksync/config/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,13 @@
package net.william278.husksync.config;

import de.exlll.configlib.Configuration;
import de.exlll.configlib.YamlConfigurations;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;

@Getter
@Configuration
Expand Down Expand Up @@ -59,17 +55,7 @@ public static Server of(@NotNull String name) {
@NotNull
private static String getDefault() {
final String serverFolder = System.getProperty("user.dir");
return serverFolder == null ? "server" : Stream
.of("HuskHomes", "HuskTowns", "HuskClaims")
.map(s -> Paths.get(serverFolder, "plugins", s, "server.yml").toFile())
.filter(File::exists).findFirst()
.map(file -> YamlConfigurations.load(
file.toPath(),
Server.class,
ConfigProvider.YAML_CONFIGURATION_PROPERTIES.header(CONFIG_HEADER).build()
))
.map(Server::getName)
.orElse(Path.of(serverFolder).getFileName().toString().trim());
return serverFolder == null ? "server" : Path.of(serverFolder).getFileName().toString().trim();
}

@Override
Expand Down

0 comments on commit fa7f6f0

Please sign in to comment.